Skip to content

webshining/expressjs-template

Repository files navigation

Express JS Template

Technologies used:

  • Express JS
  • TypeORM
  • ESBuild
  • PostgreSQL
  • SQLite
  • Docker and docker compose

Navigate

Getting started

Init project

$ git clone https://github.com/webshining/expressjs.template project_name
$ cd project_name
$ cp .env.ren .env
$ npm install
$ npm run start:dev

Build app

$ npm run build

Run builded app

$ npm run start

Docker

In the initial configuration, docker runs the dev version of the project, to run the prod version, replace CMD ["npm", "run start:dev"] with CMD ["npm", "run start:prod"]

Сontainer lifting

$ docker-compose up -d

Logs

$ docker-compose logs -f app
$ docker-compose logs -f db

Manage database container

You can change default database(default - postgres), username(default - postgres) and password(default - postgres) in docker-compose.yml

$ docker-compose exec db bash
# in container
$ psql -U postgres

Custom network name

Сreate a network (network_name: changeable(your custom network name))

$ docker network create network_name

Paste at the end of the docker-compose.yml file

networks:
    default:
        name: network_name
        external: true

Environment variables config

PORT - The port on which the server will run

DB_NAME - Database name(default: database)

DB_USER - Database username(required for PostgreSQL)

DB_PASS - Database password(required for PostgreSQL)

DB_HOST - Database host(required for PostgreSQL)

DB_PORT - Database port(required for PostgreSQL)

LOGGING - Enable/Disable database logging