An open API service indexing awesome lists of open source software.

https://github.com/thiiagoms/node-mongodb

:leaves: :books: Books API with NodeJS and MongoDB
https://github.com/thiiagoms/node-mongodb

learning-by-doing learning-nodejs nodejs

Last synced: 4 months ago
JSON representation

:leaves: :books: Books API with NodeJS and MongoDB

Awesome Lists containing this project

README

          



Logo

Book API with NodeJs, Express and Mongodb :four_leaf_clover: :books:

## Install

- First, clone the project:

```bash
$ git clone https://github.com/thiiagoms/node-express-mongodb
```

- Second, install dependencies:

```bash
$ cd node-express-mongodb
$ npm install
```

- Third, create `.env` and add your Mongo credentials in `.env` file:

```bash
$ cp .env.example .env
$ cat .env

DATABASE_HOST=
DATABASE_NAME=
DATABASE_USER=
DATABASE_PASS=
```

## Run

- Run dev mode with `nodemon`:

```
$ npm run dev
```

## Endpoints

### Books with author

- `GET - /books` - Return all books with/without author
- `GET - /books/:id` - Return single book with/without author`
- `POST - /books` - Create new book
- `PUT - /books/:id` - Update book
- `DELETE - /books/:id` - Delete book

### Author

- `GET - /books` - Return all authors
- `GET - /books/:id` - Return single author
- `POST - /books` - Create new author
- `PUT - /books/:id` - Update author
- `DELETE - /books/:id` - Delete author