This repository contains boilerplate code to cook your own backend app with NodeJS, TypeScript, Postgres SQL and Docker.
You need to have Docker installed.
Then use Docker Compose to run the server.
docker compose upThis will run the server on the configured port and enable auto-restart on code changes π!
If you want to run the server without Docker, you need to have NodeJS and NPM installed.
Add all environment variables into a .env file. See the existing template file.
Have the database running: You can do this via docker compose:
docker compose up -d postgres-databaseThen install all dependencies and run the server:
npm install
npm run devBuild the docker image with name node-boilerplate and tag latest:
docker build . -t node-server:latestRun a Docker container with the previous built image and expose port 3000:
docker run -d -p 3000:3000 node-server:latestTo enable linting, you need to have NodeJS and NPM installed. Then install all dependencies and use the lint script as follows:
npm install
npm run lintCreate a file .env and put all env vars there. (Copy the .env.template file).
Inside the docker-compose.yml you can specify those env vars too.
Add a new NodeJS configuration and target the src/index.ts file.
Add all environment variables from the .env file to the configuration.
If a permission error for the build folder inside the docker container occurs, try to remove the image and container fully and build again.