Home Reference Source Test

Node-Express-Sequelize-API Boilerplate

Simple boilerplate code base for creating APIs with Node.js Express framework using Sequelize with PostgreSQL database.

📚 Contents

Includes

😊 Prerequisite

🚀 Getting Started

You can download or clone this repo using below command:

git clone git@github.com:Chetan07j/node-pg-sequelize.git

⚙️ Local Setup

🧪 Tests & Coverage

🗃️ Migrations

ℹ️ 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

✴️ 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 # Request curl --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

🤗 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 ⭐