- First, clone the project:
$ git clone https://github.com/thiiagoms/node-express-mongodb- Second, install dependencies:
$ cd node-express-mongodb
$ npm install- Third, create
.envand add your Mongo credentials in.envfile:
$ cp .env.example .env
$ cat .env
DATABASE_HOST=<your-mongo-host-here>
DATABASE_NAME=<your-mongo-dbname-here>
DATABASE_USER=<your-mongo-dbuser-here>
DATABASE_PASS=<your-mongo-dbass-here>- Run dev mode with
nodemon:
$ npm run dev
GET - /books- Return all books with/without authorGET - /books/:id- Return single book with/without author`POST - /books- Create new bookPUT - /books/:id- Update bookDELETE - /books/:id- Delete book
GET - /books- Return all authorsGET - /books/:id- Return single authorPOST - /books- Create new authorPUT - /books/:id- Update authorDELETE - /books/:id- Delete author