This repository is to explore basics of node.js covering
- ES6
- Express
- MongoDB
- Mocha, Chai
- Use
npm init
to create new node project. - Use
npm install -D <dependency>
to add dev dependency. - Using
Babel
to transpile ES6 code to native javascript.- Make sure that babel dependencies specified in
package.json
are added correctly. - Make sure that
.babelrc
file is created with appropriate presets
- Make sure that babel dependencies specified in
- Using
Express
framework for building API server. - Instead of using
npm init
ratherexpress <project_name> --no-view
is used to generate this project. - Express come with many middleware like
morgan
debug
cookie-parser
- With express following project structure is followed
app.js
: Entry point of the application. Defines mapping of url to route.routes
: Defines mapping of url to REST controller endpoint.controller
: Defines actual endpoint.
- On premise
Mongo
is used to store basic books and author data. UsingMongoose
to connect to DB. - Use command
babel-node populatedb.js mongodb://localhost:27017/local_library
to add dummy data. Chai
alongMocha
is used for testing.Mocha
is a testing framework,Chai
is an assertion librarynyc
is used for generating test reports.