inspirevur.blogg.se

Todolist app javascript
Todolist app javascript








todolist app javascript todolist app javascript

The next line tells express where to serve static assets from so all our server code isn't visible to everybody. Cookies we won't use but I included anyways. telling Express to serve static objects from /publicĪpp.use(express.static(path.join(_dirname, 'public'))) Ĭonsole.log('Server listening on port ' + port)įirst we tell express where to find our templates (ie the views directory) and then tell express to use jade as our template engine. app.use(favicon(_dirname + '/public/favicon.ico')) Var cookieParser = require('cookie-parser') Īpp.set('views', path.join(_dirname, 'views')) Later we'll deploy this as a real web server for the interwebs.

todolist app javascript

With this file we'll run a local web server on our computer. Okay so now let's get coding! We're going to start but running up our server.js file to listen for hits to a specific port on our computers. To run our app we'll run node server or node server.js from the command line (terminal on mac). Server.js - this is the main executable file for everything. Package.json - defines all packages (like express and mongoose) that our application depends on If you're coming from a rails background you might think of these as controllers Routes - this is where we'll have the server side application logic. Here's where we'll put client side javascript and css.Ĭonfig - here we're going to have everything to do with configuring our environments and managing our database Public - this folder will hold files that everyone can see when they visit our page with a web browser. Here's the directory structure I'm going to use today: express-todo This was confusing to me when looking at other people's code because I wasn't sure what the best way to organize my project was. Unlike Ruby On Rails, express allows you to set up your file structure any way you want. LIVE DEMO hosted by heroku is here Set up the project Even though mongodb is a schemaless database (everything is json) mongoose lets us define models and easily chain queries. To make talking to MongoDB easier we will use the mongoose npm package. In this tutorial we'll connect an express server to a mongoDB database and serve our html using the jade templating engine. It's very popular but not quite as easy to get up and running with a database as something like Rails or Django. Express is a lightweight server side framework for node.js.

todolist app javascript

Hey everyone today we're going to build a super simple todo application using express 4.










Todolist app javascript