Skip to content
/ app-template Public template

Simple & flexible template for your API

Notifications You must be signed in to change notification settings

Winter4/app-template

Repository files navigation

App Template

Basic web-app template. By default it's assumed, that it would be a web-app with at least HTTP API. if other service is needed (sockets, for example), the conceived way is to add source/service.ts and source/service/; then, add the corresponding npm script to package.json and there you go

Local dev deploy

Pre-requisites

Deploy

  1. Rename the folder (otherwise, docker-compose network name would be confusing)
  2. Update Node.js version
    • put the required node version into .nvmrc file
    • nvm use
  3. Update packages versions
    • npm run update-packages
    • npm install

      If something goes wrong, read the log & manually rollback the package(s) version. Sometimes it happens for reasons beyond me (npm-check-updates package just updates the package.json)

  4. Update Docker-images versions & names
    • docker-compose.dev.yml:
      • services/service-name: image, container_name, volumes
      • volumes/volume-name: name
      • services/postgres/environment: POSTGRES_DB
  5. Run docker-compose
    • npm run compose:up

      :down for removing containers with their volumes; :stop & :start for pausing & starting the containers, respectively

  6. Update config values
    • config/default.ts
  7. Run the API in dev-mode
    • npm run api:dev

Optional

  • npx husky init, if you want to use git-hooks. Links: Git Hooks, Husky

Database

  • npm run migrate:new for creating new migration-file

  • npm run migrate for migrating existing files

  • npm run psql for direct aceess (update package.json script first: template-postgres is your container_name, and template is your POSTGRES_DB)