Express-Node Back-end
Building a simple back-end application with Express, Node, and MongoDB
Express-Node Back-end Building a simple back-end application with - - PowerPoint PPT Presentation
Express-Node Back-end Building a simple back-end application with Express, Node, and MongoDB Need for back-end Back-end will connect to a DB, get some results, and do some processing with those results Back-end will save data to the DB
Building a simple back-end application with Express, Node, and MongoDB
and do some processing with those results
to interact with the DB
app and use CRUD operations to interact with the DB
framework for Node.js
and mobile applications
and middleware for creating a robust API quickly and easily
> npm install express-generator -generator
your back-end application > express ContactsAppBackend
directory structure that you need to create an express application
> npm install express --save
> npm install
> npm start
the work will be done
we need to setup the DB
> mongod
create our contactsappdb > mongo > use contactsappdb
your application data.
hooks and more.
file
> npm install mongoose --save > npm install method-override --save
cellPhone, birthDay, website, address.
earlier, that points to contact.js
REST API
route controllers
var routes = require('./routes/index'); var contacts = require('./routes/contacts'); // AND app.use('/', routes); app.use('/contacts', contacts);
CRUD and REST pieces completely baked in
this will go into the routes/contacts.js file
the Contacts from the database
backend view or send a JSON response to the client
Contact
routes/contacts.js
and insert a contact in it
> db.contacts.insert( ... { ... "firstName": ”John", ... "lastName": ”Doe", ... "email": "john.doe@email.com" ... });
ready to get contacts by id
router.param('id', function(req, res, next, id) { ... });
contact to display or return to the client
router.route('/:id') .get(function(req, res) { ... });
creating a new contact
supported by using the REST API
front-end application
consume the newly created REST API
nodejs-mongodb-crud-skeleton