Skip to content

Commit ae6515f

Browse files
committed
updated readmes
1 parent ee00873 commit ae6515f

File tree

5 files changed

+155
-8
lines changed

5 files changed

+155
-8
lines changed

CODE_OF_CONDUCT.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Contributor Code of Conduct
2+
3+
As contributors and maintainers of this project, we pledge to respect everyone who contributes by posting issues, updating documentation, submitting pull requests, providing feedback in comments, and any other activities.
4+
5+
Communication through any of the project channels must be constructive and never resort to personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
6+
7+
We promise to extend courtesy and respect to everyone involved in this project regardless of gender, gender identity, sexual orientation, disability, age, race, ethnicity, religion, or level of experience. We expect anyone contributing to this project to do the same.
8+
9+
If any member of the community violates this code of conduct, the maintainers of the project may take action, removing issues, comments, and PRs or blocking accounts as deemed appropriate.
10+
11+
If you are subject to or witness unacceptable behavior, or have any other concerns, please email us at [[email protected]](mailto:[email protected])

CONTRIBUTING.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Contributing to Express REST API Generator
2+
3+
1. Clone the repo
4+
2. Create a new branch for the bugfix, enhancement or feature you want to add. The branch name should follow this format. eg. feature/featureName or bugFix/someBugName or enhancement/someImprovement
5+
3. When committing your changes, follow angular's conventional changelog for your commit messages. eg. `feat(featureName): some message to describe this change` or `fix(featureName): more information on the bug fix`. See more details here [https://github.com/conventional-changelog-archived-repos/conventional-changelog-angular/blob/master/convention.md](https://github.com/conventional-changelog-archived-repos/conventional-changelog-angular/blob/master/convention.md)
6+
4. Push your changes to your repo
7+
5. Create a pull request to this repo
8+
9+
> NOTE: you are required to write a complete test suit for all changes you make.
10+
11+
Please feel free to add your name to the contributor list when you make a contribution
12+
13+
View our [code of conduct](https://github.com/iolufemi/Express-REST-API-Generator/blob/master/CODE_OF_CONDUCT.md).

README.md

+122-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,129 @@
1-
# API Template
1+
# Express REST API Generator
22

3-
[![Build Status](https://travis-ci.org/iolufemi/Express-API-Template.svg?branch=dev)](https://travis-ci.org/iolufemi/Express-API-Template) [![codecov](https://codecov.io/gh/iolufemi/Express-API-Template/branch/master/graph/badge.svg)](https://codecov.io/gh/iolufemi/Express-API-Template)
3+
[![Build Status](https://travis-ci.org/iolufemi/Express-REST-API-Generator.svg?branch=dev)](https://travis-ci.org/iolufemi/Express-REST-API-Generator) [![codecov](https://codecov.io/gh/iolufemi/Express-REST-API-Generator/branch/master/graph/badge.svg)](https://codecov.io/gh/iolufemi/Express-REST-API-Generator)
44

5+
Express REST API Generator is an Express Based API skeleton. A template for starting projects with express as an API. This project can be used for creating a RESTful API using Node JS, Express as the framework and Mongoose to interact with a MongoDB instance. Mocha is also used for running unit tests in the project.
56

7+
The resulting API from this project is a JSON REST API which will respond to requests over HTTP. REST Clients can, therefore, connect to the resulting REST server.
68

7-
API Development Template
9+
## What is API?
810

11+
In computer programming, an application programming interface (API) is a set of clearly defined methods of communication between various software components. A good API makes it easier to develop a computer program by providing all the building blocks, which are then put together by the programmer. An API may be for a web-based system, operating system, database system, computer hardware or software library. Just as a graphical user interface makes it easier for people to use programs, application programming interfaces make it easier for developers to use certain technologies in building applications. - [Wikipedia](https://en.wikipedia.org/wiki/Application_programming_interface)
912

13+
## What is REST?
1014

15+
Representational state transfer (REST) or RESTful web services is a way of providing interoperability between computer systems on the Internet. REST-compliant Web services allow requesting systems to access and manipulate textual representations of Web resources using a uniform and predefined set of stateless operations. - [Wikipedia](https://en.wikipedia.org/wiki/Representational_state_transfer)
16+
17+
> NOTE: The use of this project requires that you have a basic knowledge of using express in building a REST API. If you are a newbie, here are some awesome tutorials to get you started.
18+
19+
- [Build Node.js RESTful APIs in 10 Minutes](https://www.codementor.io/olatundegaruba/nodejs-restful-apis-in-10-minutes-q0sgsfhbd)
20+
- [Easily Develop Node.js and MongoDB Apps with Mongoose](https://scotch.io/tutorials/using-mongoosejs-in-node-js-and-mongodb-applications)
21+
- [Build a RESTful API Using Node and Express 4](https://scotch.io/tutorials/build-a-restful-api-using-node-and-express-4)
22+
23+
## Why use Express REST API Generator?
24+
25+
1. To enable you to develop REST APIs in the fastest way possible.
26+
2. To encourage endpoint versioning.
27+
3. To encourage unit testing and make it super easy to get started with writing unit tests by generating basic unit tests for generated components.
28+
4. To enforce best practice in writing javascript apps by using lint.
29+
5. To encourage good code file structure that can be easily followed by other team members, especially new team members.
30+
6. To make it easy to build secure APIs with the ability to communicate with the frontend in an encrypted fashion.
31+
7. To encourage backing up of deleted data.
32+
8. To encourage logging API requests and responses for audit purposes.
33+
9. To encourage proper Error handling and logging.
34+
10. To encourage a uniform API response format across teams.
35+
11. To make it easy to write asynchronous logic and applications using the inbuilt distributed job queue.
36+
37+
## Installation
38+
39+
To start your project with Express REST API Generator, clone the repository from GitHub and install the dependencies.
40+
41+
```
42+
$ git clone https://github.com/iolufemi/Express-REST-API-Generator.git ./yourProjectName
43+
$ cd yourProjectName
44+
$ npm install
45+
$ npm install -g mocha gulp
46+
```
47+
48+
Then generate your first API endpoint
49+
50+
```
51+
$ gulp service --name yourFirstEndpoint // This command will create a CRUD endpoint for yourFirstEndpoint.
52+
```
53+
54+
Try out your new endpoint.
55+
56+
Start the app
57+
58+
```
59+
$ npm start
60+
```
61+
by default, the app will start on `POST 8080`
62+
63+
You can change the PORT by adding a `PORT` environment variable.
64+
eg.
65+
66+
```
67+
$ PORT=6000 npm start
68+
```
69+
now the app will start on `PORT 6000`
70+
71+
To start the app for development, run
72+
73+
```
74+
$ gulp
75+
```
76+
This will automatically restart your app whenever a change is detected.
77+
78+
You will now be able to access CRUD (create, read, update and delete) endpoints
79+
80+
`[POST] http://localhost:8080/yourFirstEndpoint` Create yourFirstEndpoint resources
81+
`[GET] http://localhost:8080/yourFirstEndpoint` Get yourFirstEndpoint resources. Supports limits, sorting, pagination, select (projection), search and date range
82+
`[GET] http://localhost:8080/yourFirstEndpoint/:id` Get a yourFirstEndpoint resource
83+
`[PUT] http://localhost:8080/yourFirstEndpoint` Update yourFirstEndpoint resources
84+
`[PATCH] http://localhost:8080/yourFirstEndpoint/:id` Update one yourFirstEndpoint resource
85+
`[DELETE] http://localhost:8080/yourFirstEndpoint?key=value` Delete yourFirstEndpoint resources
86+
`[DELETE] http://localhost:8080/yourFirstEndpoint/:id` Delete one yourFirstEndpoint resource
87+
`[POST] http://localhost:8080/yourFirstEndpoint/:id/restore` Restore a previously deleted yourFirstEndpoint resource
88+
89+
## Versioning your API endpoints
90+
91+
You can create multiple versions of your API endpoints by simply adding the version number to your route file name. eg. `users.v1.js` will put a version of the users resources on the `/v1/users` endpoint. users.v2.js will put a version of the users resources on the `/v2/users` endpoint. The latest version of the resources will always be available at the `/users` endpoint.
92+
93+
> NOTE: This project will automatically load route files found in the routes folder.
94+
95+
## File Structure
96+
97+
- config
98+
- controllers
99+
- models
100+
- routes
101+
- services
102+
- templates
103+
- test
104+
105+
## Getting support, Reporting Bugs and Issues
106+
107+
If you need support or want to report a bug, please log an issue [here](https://github.com/iolufemi/Express-REST-API-Generator/issues)
108+
109+
## Running Unit Tests
110+
111+
All generated endpoints come with complete test suits, we encourage you to update the tests as you extend the logic
112+
113+
```
114+
$ npm test
115+
```
116+
117+
## How to contribute
118+
119+
View how to contribute [here](https://github.com/iolufemi/Express-REST-API-Generator/blob/master/CONTRIBUTING.md)
120+
121+
## Code of Conduct
122+
123+
View the code of conduct [here](https://github.com/iolufemi/Express-REST-API-Generator/blob/master/CODE_OF_CONDUCT.md)
124+
125+
## Contributors
126+
127+
- [Olufemi Olanipekun](https://github.com/iolufemi)
128+
129+
## FAQs

TODO.md

+9-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@
44
| app.js | 62 | Write a complete Documentation for this project
55
| routes/index.js | 291 | Test API versioning
66
| routes/index.js | 292 | Test rate limiting
7-
| routes/index.js | 293 | Develop the route loader into a separate node module to be publish on npm
8-
| routes/index.js | 294 | Develop all services onto separate node module to be publish on npm
7+
| routes/index.js | 293 | Test complete route Loader test
8+
| routes/index.js | 294 | Test _sanitizeRequestUrl middleware function
9+
| routes/index.js | 295 | Test _allRequestData middleware function for default value scenario
10+
| routes/index.js | 296 | Test _enforceUserIdAndAppId middle function for when req.body is an array
11+
| routes/index.js | 297 | Make Log requests testable and write unit tests for it
12+
| routes/index.js | 298 | Develop the route loader into a separate node module to be publish on npm
13+
| routes/index.js | 299 | Develop all services onto separate node module to be publish on npm
14+
| config/index.js | 12 | Test for production and development senarios
15+
| services/logger/index.js | 36 | Test Error Handler
916
| services/queue/clock.js | 11 | work on a clock functionality so kue can support scheduled jobs
1017
| services/queue/clock.js | 12 | Use the cron package here https://www.npmjs.com/package/cron for timer

package.json

-3
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,9 @@
6767
"kue": "^0.11.6",
6868
"lodash": "^4.17.4",
6969
"mongoose": "^4.9.0",
70-
"mongoose-delete": "^0.3.4",
71-
"node-rest-client": "^3.1.0",
7270
"q": "^1.4.1",
7371
"randomstring": "^1.1.5",
7472
"redis": "^2.7.1",
75-
"request": "^2.81.0",
7673
"request-promise": "^4.2.1",
7774
"util": "^0.10.3",
7875
"winston": "^2.3.1",

0 commit comments

Comments
 (0)