A ready-to-use boilerplate for REST API Development with Node.js, Express, and MongoDB
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.
I am open for a good job or work contract. You can contact me directly on my email (maitraysuthar@gmail.com) or you can download my CV from my personal website.
If you consider my project as helpful stuff, You can appreciate me or my hard work and time spent to create this helpful structure with buying me a coffee.
Authorization
header with value Bearer yourToken
where yourToken
will be returned in Login response.git clone https://github.com/maitraysuthar/rest-api-nodejs-mongodb.git ./myproject
cd myproject
npm install
.env.example
on root directory of project..env
cp .env.example .env
.env
is already ignored, so you never commit your credentials..env.example
file to understand the constants..
├── app.js
├── package.json
├── bin
│ └── www
├── controllers
│ ├── AuthController.js
│ └── BookController.js
├── models
│ ├── BookModel.js
│ └── UserModel.js
├── routes
│ ├── api.js
│ ├── auth.js
│ └── book.js
├── middlewares
│ ├── jwt.js
├── helpers
│ ├── apiResponse.js
│ ├── constants.js
│ ├── mailer.js
│ └── utility.js
├── test
│ ├── testConfig.js
│ ├── auth.js
│ └── book.js
└── public
├── index.html
└── stylesheets
└── style.css
npm run dev
You will know server is running by checking the output of the command npm run dev
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.
If you need to add more models to the project just create a new file in /models/
and use them in the controllers.
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.
If you need to add more controllers to the project just create a new file in /controllers/
and use them in the routes.
npm test
You can set custom command for test at package.json
file inside scripts
property. You can also change timeout for each assertion with --timeout
parameter of mocha command.
If you need to add more test cases to the project just create a new file in /test/
and run the command.
npm run lint
You can set custom rules for eslint in .eslintrc.json
file, Added at project root.
Every project needs improvements, Feel free to report any bugs or improvements. Pull requests are always welcome.
This project is open-sourced software licensed under the MIT License. See the LICENSE file for more information.
What is this repository for? Node.js app architecture showcase using Express, MongoDB and Mongoose as ORM. The project has an implementation of an authentication system that uses JSON Web Token to man
nodejs-restful-api How to create a RESTful CRUD API using Nodejs? This tutorial will demo how to set up a bare bonesAPI using mongodb as the database. It consist of a User model and controller. The mo
NodeJS-API-Boilerplate Always in progress �� Get Started Installation Install Mongodb Raven Log Body Whitelist Api Doc Pre-Commit Hook Scripts Dev-Debug Why toJSON() on methods model For validation o
Storm UI 守护程序提供了一个 REST API, 允许您与 Storm 集群进行交互, 其中包括检索 metrics(度量)数据和配置信息, 启动或停止 topologies(拓扑)的管理操作。 数据格式 该 REST API 返回 JSON 响应并支持 JSONP. 客户端可以传回一个回调查询参数, 以在回调函数中包装 JSON。 REST API allows CORS by defa
Setup $ yarn install && open http://localhost:4000 && yarn run start Medium: https://medium.com/@wesharehoodies/how-to-setup-a-powerful-api-with-nodejs-graphql-mongodb-hapi-and-swagger-e251ac189649?
问题内容: 此处的典型示例是Twitter的API。我从概念上了解REST API的工作原理,从本质上讲,它只是针对您的特定请求的服务器查询,然后您会在其中收到响应(JSON,XML等),很棒。 但是我不确定在后台如何使用流API。我了解如何食用。例如,使用Twitter收听回复。从响应中侦听数据,并在其中分批发送推文。在字符串缓冲区中建立块,然后等待换行指示Tweet的结束。但是他们正在做些什么