Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thecodersstudio/node-pg-sequelize-boilerplate
Node.js Express Sequelize Boilerplate with PostgreSQL Integration and Comprehensive Unit/Integration Test Setup
https://github.com/thecodersstudio/node-pg-sequelize-boilerplate
boilerplate express express-sequelize-boilerplate node-express-sequelize-boilerplate node-sequelize-postgres nodejs nodejs-postgres-sequelize-boilerplate nodejs-rest-boilerplate postgres sequelize
Last synced: about 1 month ago
JSON representation
Node.js Express Sequelize Boilerplate with PostgreSQL Integration and Comprehensive Unit/Integration Test Setup
- Host: GitHub
- URL: https://github.com/thecodersstudio/node-pg-sequelize-boilerplate
- Owner: TheCodersStudio
- Created: 2022-04-04T11:28:41.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-29T19:10:54.000Z (5 months ago)
- Last Synced: 2024-07-29T22:58:14.579Z (5 months ago)
- Topics: boilerplate, express, express-sequelize-boilerplate, node-express-sequelize-boilerplate, node-sequelize-postgres, nodejs, nodejs-postgres-sequelize-boilerplate, nodejs-rest-boilerplate, postgres, sequelize
- Language: JavaScript
- Homepage: https://thecodersstudio.github.io/node-pg-sequelize-boilerplate/
- Size: 1.51 MB
- Stars: 52
- Watchers: 4
- Forks: 7
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Node-Express-Sequelize-API Boilerplate
Simple boilerplate code base for creating APIs with `Node.js Express` framework using `Sequelize` with `PostgreSQL` database.
## ๐ Contents
- [Includes](#includes)
- [Prerequisite](#prerequisite)
- [Getting Started](#getting-started)
- [Local Setup](#local-setup)
- [Tests \& Coverage](#tests--coverage)
- [Migrations](#migrations)
- [Environment Variables](#environment-variables)
- [`ESDoc`](#esdoc)
- [Endpoints](#endpoints)
- [References](#references)## Includes
- **ES6** `import/export` implemented with `type: "module"` in `package.json`
- **Error handling** middlewares implemented
- `Tests` added with `mocha` configuration
- Code-coverage using Node.js' built in functionality `c8`
- `Eslint`
- `winston` logger## ๐ Prerequisite
- Install `nodemon` globally using below command if not installed already
```sh
npm i -g nodemon
```- **PostgreSQL**
## ๐ Getting Started
You can download or clone this repo using below command:
```sh
git clone [email protected]:Chetan07j/node-pg-sequelize.git
```## โ๏ธ Local Setup
- After cloning enter into folder.
- Install dependencies```sh
npm install
```- Create file called `.env`
- Copy `.env.example` file content `.env` file.- Run locally
```sh
npm run local
```## ๐งช Tests & Coverage
- Run tests *(unit/integration)*
```sh
npm test
```- Run tests with coverage
```sh
npm run coverage
```## ๐๏ธ Migrations
- Running Migrations
```sh
npm run migration
```- Undoing Migrations
```sh
npm run migration:undo
```## โน๏ธ Environment Variables
| Variable | Description | Default Value |
| -------- | ------------------------ | ------------- |
| DB_HOST | Database connection host | `localhost` |
| DB_PORT | Database port | `5432` |
| DB_NAME | Database name | `postgres` |
| DB_USER | Database username | `postgres` |
| DB_PASS | Database password | `postgres` |> NOTE: These environment variables are already passed to `npm run local` and `npm test` scripts under `package.json` with their default values. You can update as per your need.
## ๐๏ธ `ESDoc`
- Documention is created out of comments added for functions using `esdoc`.
- That documentaion is avaialbe as GH Pages site, can be found [here](https://chetan07j.github.io/node-pg-sequelize-boilerplate/).## โด๏ธ Endpoints
Create User with Skills
```sh
curl --location --request POST 'localhost:3000/v1/users' \
--header 'Content-Type: application/json' \
--data-raw '{
"firstName": "Chetan",
"lastName": "Patil",
"gender": "Male",
"skills": [
{
"name": "Node.js",
"proficiency": "Advanced"
}
]
}'
```Get all Users
```sh
# Request
curl --location --request GET 'localhost:3000/v1/users'#Response
{
"success": true,
"body": [
{
"id": 1,
"firstName": "First1",
"lastName": "Last",
"gender": "Male",
"createdAt": "2022-03-20T10:11:41.860Z",
"updatedAt": "2022-03-20T10:11:41.860Z",
"skills": [
{
"id": 1,
"userId": 1,
"name": "Node.js",
"proficiency": "Advanced",
"createdAt": "2022-03-20T10:11:41.867Z",
"updatedAt": "2022-03-20T10:11:41.867Z"
}
]
}
]
}```
Get specific User by userId
```sh
# Requestcurl --location --request GET 'localhost:3000/v1/users/1'
# Response
{
"success": true,
"body": {
"id": 1,
"firstName": "Chetan",
"lastName": "Patil",
"gender": "Male",
"createdAt": "2022-03-20T20:39:17.912Z",
"updatedAt": "2022-03-20T20:39:17.912Z",
"skills": [
{
"id": 1,
"userId": 1,
"name": "Node.js",
"proficiency": "Advanced",
"createdAt": "2022-03-20T20:39:17.962Z",
"updatedAt": "2022-03-20T20:39:17.962Z"
}
]
}
}
```## ๐ References
- [Sequelize ORM](https://sequelize.org/v6/)
## ๐ค Contributing
Contributions are welcome! Feel free to open an issue or submit a pull request if you have a way to improve this project.
Make sure your request is meaningful and you have tested the app locally before submitting a pull request.
## โฅ๏ธ Support
๐ If you like this project, give it a โญ