Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modified README.md, Removed unnecessary file.
- Loading branch information
1 parent
12c466b
commit 997db48
Showing
2 changed files
with
92 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,92 @@ | ||
# rest-api-nodejs-mongodb | ||
A boilerplate for REST API Development with Node.js, Express, and MongoDB | ||
# Nodejs Expressjs MongoDB Ready-to-use API Project Structure | ||
A ready-to-use boilerplate for REST API Development with Node.js, Express, and MongoDB | ||
|
||
## Getting started | ||
|
||
|
||
This is a basic API skeleton written in JavaScript ES2015. Very useful to building a RESTful web APIs for your front-end platforms like Android, iOS or JavaScript frameworks (Angular, Reactjs, etc). | ||
|
||
This project will run on **NodeJs** using **MongoDB** as database. I had tried to maintain the code structure easy as any beginner can also adopt the flow and start building an API. Project is open for suggestions, Bug reports and pull requests. | ||
|
||
## Features | ||
|
||
- Basic Authentication (Register/Login with hashed password) | ||
- JWT Tokens, make requests with a token after login with `Authorization` header with value `Bearer yourToken` where `yourToken` will be returned in Login response. | ||
- Pre-defined response structures with proper status codes. | ||
- Included CORS. | ||
- **Book** example with **CRUD** operations. | ||
- Validations added. | ||
- Included API collection for Postman. | ||
- Light-weight project. | ||
|
||
## Software Requirements | ||
|
||
- Node.js **10+** | ||
- MongoDB **3.6+** (Recommended **4+**) | ||
## How to install | ||
|
||
### Using Git (recommended) | ||
|
||
1. Clone the project from github. Change "myproject" to your project name. | ||
|
||
```bash | ||
git clone https://github.com/maitraysuthar/rest-api-nodejs-mongodb.git ./myproject | ||
``` | ||
|
||
### Using manual download ZIP | ||
|
||
1. Download repository | ||
2. Uncompress to your desired directory | ||
|
||
### Install npm dependencies after installing (Git or manual download) | ||
|
||
```bash | ||
cd myproject | ||
npm install | ||
npm update | ||
``` | ||
|
||
### Setting up environments | ||
|
||
1. You will find a file named `.env.example` on root directory of project. | ||
2. Create a new file by copying and pasting the file and then renaming it to just `.env` | ||
3. The file `.env` is already ignored, so you never commit your credentials. | ||
4. Change the values of the file to your environment. | ||
|
||
## How to run | ||
|
||
### Running API server locally | ||
|
||
```bash | ||
npm run dev | ||
``` | ||
|
||
You will know server is running by checking the output of the command `npm run dev` | ||
|
||
```bash | ||
Connected to mongodb:YOUR_DB_CONNECTION_STRING | ||
App is running ... | ||
|
||
Press CTRL + C to stop the process. | ||
``` | ||
**Note:** `YOUR_DB_CONNECTION_STRING` will be your MongoDB connection string. | ||
|
||
### Creating new models | ||
|
||
If you need to add more models to the project just create a new file in `/models/` and use them in the controllers. | ||
|
||
### Creating new routes | ||
|
||
If you need to add more routes to the project just create a new file in `/routes/` and add it in `/routes/api.js` it will be loaded dynamically. | ||
|
||
### Creating new controllers | ||
|
||
If you need to add more controllers to the project just create a new file in `/controllers/` and use them in the routes. | ||
|
||
## Bugs or improvements | ||
|
||
Every project needs improvements, Feel free to report any bugs or improvements. Pull requests are always welcome. | ||
|
||
## License | ||
|
||
This project is open-sourced software licensed under the MIT License. See the LICENSE file for more information. |
This file was deleted.
Oops, something went wrong.