Skip to content

piotrkabacinski/node-starter

Repository files navigation

Hello, Node.js!

Dockerized Node.js project starter using following stack:

Setup

# Clone repo:
git clone [email protected]:piotrkabacinski/node-starter.git --depth 1

# Create .env file based on template file:
cp .env.template .env

nvm use

npm i

docker-compose build

# Run migrations:
docker-compose run --rm app npm run migration:deploy

# Run server:
docker-compose up

When installing new dependencies locally do it within container as well:

docker-compose run --rm app npm i

Prisma ORM

Docs

If using VS Code try prisma extension for better DX.

When changing prisma's schema (src/db/schema.prisma) run migration command:

# Create and run migration:
npm run migration <migration name>

# Apply migrations on production server after deploy:
npm run migration:deploy

Tests

docker-compose run --rm app npm t

Postgres

docker exec -it <container name prefix>_db_1 psql -U postgres

\l # List all data bases
\c <db name> # Connect to DB
\dt # Show data base tables

Redis

docker exec -it <container name prefix>_redis_1 redis-cli

Insomnia

For manual tests of Todo API example you can import Insomnia workspace from insomnia.json.

Deployment

App is configured for Heroku environment. See Heroku.md file for deployment details.