This project provides a solid foundation for creating APIs using Node.js and Express, along with PostgreSQL as the database and Sequelize as the ORM. It includes a development setup with Docker Compose, allowing you to easily set up your development environment.
- Node.js 18.15.0+
- Docker (for development environment)
- PostgreSQL server (for production)
- Set up .env file (use .env.example to know what to add)
- Use nvm, the project includes a .nvmrc
- Express.js framework
- Integration with PostgreSQL
- Validation using Joi
- Error handling using Boom
- CORS support
- Security enhancements using helmet
- JSON Web Token Based authentication
- Basic authentication using basic-auth and bcrypt
- Code formatting with ESLint and Prettier
- Unit testing with Jest
- Auto-reloading with Nodemon
- Docker (for development environment)
- update/create .env file with your credentials
- to run the project with docker the "POSTGRES_HOST" in the .env should be 'db'
This project uses the Node Version Manager (nvm) to manage the Node.js version. To ensure you're using the correct version of Node.js, follow these steps:
-
Install Node Version Manager (if not already installed) by following the instructions at nvm repository.
-
Once nvm is installed, navigate to the project directory and run the following command to use the recommended Node.js version for this project:
nvm use
This command will automatically select and use the Node.js version specified in the .nvmrc file in the project root.
- Verify that the correct Node.js version is being used:
node -v
Before running the project, configure the necessary environment variables. Create a .env file in the project root and define the following variables:
NODE_ENV=dev
POSTGRES_DB=dbname
POSTGRES_PASSWORD=password
POSTGRES_USER=dbuser
POSTGRES_HOST=dbhost # use 'db' if you are dockerizing the app within the included docker-compose
POSTGRES_PORT=5432
# POSTGRES_HOST='http://yourhost/'
# env variables that docker-compose will use to build the PostgreSQL image
DB_USER=myuser
DB_PASSWORD=password
DB_NAME=dbname
npm install
npm run dev
npm run dockerize
npm run test
For questions or feedback, contact Alexander Herrera at alexander.herrerain@gmail.com.