Skip to content

Commit 997db48

Browse files
committed
Modified README.md, Removed unnecessary file.
1 parent 12c466b commit 997db48

File tree

2 files changed

+92
-11
lines changed

2 files changed

+92
-11
lines changed

README.md

Lines changed: 92 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,92 @@
1-
# rest-api-nodejs-mongodb
2-
A boilerplate for REST API Development with Node.js, Express, and MongoDB
1+
# Nodejs Expressjs MongoDB Ready-to-use API Project Structure
2+
A ready-to-use boilerplate for REST API Development with Node.js, Express, and MongoDB
3+
4+
## Getting started
5+
6+
7+
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).
8+
9+
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.
10+
11+
## Features
12+
13+
- Basic Authentication (Register/Login with hashed password)
14+
- JWT Tokens, make requests with a token after login with `Authorization` header with value `Bearer yourToken` where `yourToken` will be returned in Login response.
15+
- Pre-defined response structures with proper status codes.
16+
- Included CORS.
17+
- **Book** example with **CRUD** operations.
18+
- Validations added.
19+
- Included API collection for Postman.
20+
- Light-weight project.
21+
22+
## Software Requirements
23+
24+
- Node.js **10+**
25+
- MongoDB **3.6+** (Recommended **4+**)
26+
## How to install
27+
28+
### Using Git (recommended)
29+
30+
1. Clone the project from github. Change "myproject" to your project name.
31+
32+
```bash
33+
git clone https://github.com/maitraysuthar/rest-api-nodejs-mongodb.git ./myproject
34+
```
35+
36+
### Using manual download ZIP
37+
38+
1. Download repository
39+
2. Uncompress to your desired directory
40+
41+
### Install npm dependencies after installing (Git or manual download)
42+
43+
```bash
44+
cd myproject
45+
npm install
46+
npm update
47+
```
48+
49+
### Setting up environments
50+
51+
1. You will find a file named `.env.example` on root directory of project.
52+
2. Create a new file by copying and pasting the file and then renaming it to just `.env`
53+
3. The file `.env` is already ignored, so you never commit your credentials.
54+
4. Change the values of the file to your environment.
55+
56+
## How to run
57+
58+
### Running API server locally
59+
60+
```bash
61+
npm run dev
62+
```
63+
64+
You will know server is running by checking the output of the command `npm run dev`
65+
66+
```bash
67+
Connected to mongodb:YOUR_DB_CONNECTION_STRING
68+
App is running ...
69+
70+
Press CTRL + C to stop the process.
71+
```
72+
**Note:** `YOUR_DB_CONNECTION_STRING` will be your MongoDB connection string.
73+
74+
### Creating new models
75+
76+
If you need to add more models to the project just create a new file in `/models/` and use them in the controllers.
77+
78+
### Creating new routes
79+
80+
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.
81+
82+
### Creating new controllers
83+
84+
If you need to add more controllers to the project just create a new file in `/controllers/` and use them in the routes.
85+
86+
## Bugs or improvements
87+
88+
Every project needs improvements, Feel free to report any bugs or improvements. Pull requests are always welcome.
89+
90+
## License
91+
92+
This project is open-sourced software licensed under the MIT License. See the LICENSE file for more information.

routes/users.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)