A Node.js RESTful API Services with beautiful code written in JavaScript.
Inspired by the awesome framework Express.js in Node.js.
Made with ❤️ by Julian Nwadinobi(wackydawg)
Our main goal with this project is to create a users CRUD system for the HNGX Internship Backend Track Task. Try it!! We are happy to hear your feedback or any kind of new features.
- Beautiful Code thanks to the awesome annotations of the libraries from prettier.
- Easy API Testing with included e2e testing.
- Clear Structure with different layers such as controllers, services, repositories, models, middlewares...
- Easy Exception Handling thanks to [routing-controllers].
- Smart Validation thanks to [express-validator].
- API Documentation thanks to swagger and routing-controllers-openapi.
- API Monitoring thanks to express-status-monitor.
- Integrated Testing Tool thanks to Jest.
- E2E API Testing thanks to supertest and [mocha] (https://github.com/mochajs/mocha), [chai] (https://github.com/chaijs/chai).
- Basic Security Features thanks to Helmet.
- Getting Started
- Scripts and Tasks
- API Routes
- Project Structure
- Further Documentations
- Related Projects
- License
You need to set up your development environment before you can do anything.
Install Node.js and NPM
- on OSX use homebrew
brew install node - on Windows use chocolatey
choco install nodejs
Install yarn globally
yarn global add yarnFork or download this project. Configure your package.json for your new project.
Then copy the .env.example file and rename it to .env. In this file you have to add your database connection information.
Create a new database with the name you have in your .env-file.
Then setup your application environment.
Go to the project dir and start your app with this yarn script.
yarn start serveThis starts a local server using
nodemon, which will watch for any file changes and will restart the server according to these changes. The server address will be displayed to you ashttp://0.0.0.0:3000.
- Install all dependencies with
npm install
- Run the e2e tests using
npm test.
- Run
npm startto start nodemon with ts-node, to serve the app. - The server address will be displayed to you as
http://0.0.0.0:3000
The route prefix is /api by default, but you can change this in the .env file.
The swagger and the monitor route can be altered in the .env file.
| Route | Description |
|---|---|
| /api | When a POST request is made to this endpoint with the body parameter it inserts the data to the cloud servers. |
| /api/:userID | Allowed request GET,PUT,DELETE |
Use Postman for testing the API. You can use any client :). So open postman and create a new post request to http://localhost:3000/api with this in the body
{
"name": "Clark Kent"
}POST /api{
"message": "Person created successfully🎉",
"newPerson": {
"_id": "6502152763bcef1970ba0a28",
"name": "Clark Kent",
"__v": 0
}
}create a new Get request to http://localhost:3000/api/6502152763bcef1970ba0a28
GET /api/:user_id{
"Person": {
"_id": "6502152763bcef1970ba0a28",
"name": "Clark Kent",
"__v": 0
}
}create a new PUT request to http://localhost:3000/api/64ff1ea91539022f0c4d1d98
PUT /api/:user_id{
"message": "Successfully Updated",
"updatedPerson": {
"_id": "64ff1ea91539022f0c4d1d98",
"name": "Julian Nwadinobi",
"__v": 0
}
}create a new DELETE request to http://localhost:3000/api/64ff1ea91539022f0c4d1d98
DELETE /api/:user_id{
"message": "User has been deleted successfully!🗑️"
}| Name | Description |
|---|---|
| .vscode/ | VSCode tasks, launch configuration, and other settings |
| controllers/ | CRUD operations for managing user resources |
| coverage | Validation rules for request bodies and code coverage |
| models | Data models and response interfaces for user resources |
| node_modules * | Custom type definitions and non-DefinitelyTyped files |
| router/ | API routing for user-related endpoints |
| test/e2e/ *.test.js | End-to-End tests for user creation and management |
| .env.example | Example environment configuration settings |
| .env.test | Test environment configuration settings |
| .gitignore | Ignore file for version control |
| index.js | Main application entry point |
| package-lock.json | Dependency lock file for package consistency |
| package.json | Project dependencies and configurations |
| Name & Link | Description |
|---|---|
| Express | Express is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications. |
| Helmet | Helmet helps you secure your Express apps by setting various HTTP headers. It’s not a silver bullet, but it can help! |
| Jest | Delightful JavaScript Testing Library for unit and e2e tests |
| supertest | Super-agent driven library for testing node.js HTTP servers using a fluent API |
| nock | HTTP mocking and expectations library |
| swagger Documentation | API Tool to describe and document your api. |





