This application implements the server part of the local hosting management manager. The client part of the application is located in the repository chat3-manager-frontend.
The application is built on the basis of a starter TypeScript Express Starter.
Docker is a platform for developers and sysadmins to build, run, and share applications with containers.
Docker Install.
docker-compose up -d
docker-compose down
Modify docker-compose.yml
and Dockerfile
file to your source code.
NGINX is a web server that can also be used as a reverse proxy, load balancer, mail proxy and HTTP cache.
Proxying is typically used to distribute the load among several servers, seamlessly show content from different websites, or pass requests for processing to application servers over protocols other than HTTP.
When NGINX proxies a request, it sends the request to a specified proxied server, fetches the response, and sends it back to the client.
Modify nginx.conf
file to your source code.
Prettier is an opinionated code formatter.
ESLint, Find and fix problems in your JavaScript code
It enforces a consistent style by parsing your code and re-printing it with its own rules that take the maximum line length into account, wrapping code when necessary.
CMD
+ Shift
+ P
(Mac Os) or Ctrl
+ Shift
+ P
(Windows)
Format Selection With
Configure Default Formatter...
Prettier - Code formatter
Palantir, the backers behind TSLint announced in 2019 that they would be deprecating TSLint in favor of supporting typescript-eslint in order to benefit the community. So, migration from TSLint to ESLint.
REST Client allows you to send HTTP request and view the response in Visual Studio Code directly.
VSCode Extension REST Client Install.
Modify *.http
file in src/http folder to your source code.
PM2 is a daemon process manager that will help you manage and keep your application online 24/7.
npm run deploy:prod
or pm2 start ecosystem.config.js --only prod
npm run deploy:dev
or pm2 start ecosystem.config.js --only dev
Modify ecosystem.config.js
file to your source code.
SWC is an extensible Rust-based platform for the next generation of fast developer tools.
SWC is 20x faster than Babel on a single thread and 70x faster on four cores.
npm run build
npm run build:swc
Modify .swcrc
file to your source code.
Makefiles are used to help decide which parts of a large program need to be recompiled.
make help
Modify Makefile
file to your source code.
โ
โโโ๐ .vscode
โ โโโ launch.json
โ โโโ settings.json
โ
โโโ๐ src
โ โโโ๐ config
โ โ โโโ index.ts
โ โ
โ โโโ๐ controllers
โ โ โโโ auth.controller.ts
โ โ โโโ users.controller.ts
โ โ
โ โโโ๐ dtos
โ โ โโโ users.dto.ts
โ โ
โ โโโ๐ exceptions
โ โ โโโ httpException.ts
โ โ
โ โโโ๐ http
โ โ โโโ auth.http
โ โ โโโ users.http
โ โ
โ โโโ๐ interfaces
โ โ โโโ auth.interface.ts
โ โ โโโ routes.interface.ts
โ โ โโโ users.interface.ts
โ โ
โ โโโ๐ middlewares
โ โ โโโ auth.middleware.ts
โ โ โโโ error.middleware.ts
โ โ โโโ validation.middleware.ts
โ โ
โ โโโ๐ models
โ โ โโโ users.model.ts
โ โ
โ โโโ๐ routes
โ โ โโโ auth.route.ts
โ โ โโโ users.route.ts
โ โ
โ โโโ๐ services
โ โ โโโ auth.service.ts
โ โ โโโ users.service.ts
โ โ
โ โโโ๐ test
โ โ โโโ auth.test.ts
โ โ โโโ users.test.ts
โ โ
โ โโโ๐ utils
โ โ โโโ logger.ts
โ โ โโโ vaildateEnv.ts
โ โโโ๐ static
โ โ โโโ index.html
โ โ
โ โโโ app.ts
โ โโโ server.ts
โ
โโโ .dockerignore
โโโ .editorconfig
โโโ .env.development.local
โโโ .env.production.local
โโโ .env.test.local
โโโ .eslintignore
โโโ .eslintrc
โโโ .gitignore
โโโ .huskyrc
โโโ .lintstagedrc.json
โโโ .prettierrc
โโโ .swcrc
โโโ docker-compose.yml
โโโ Dockerfile.dev
โโโ Dockerfile.prod
โโโ ecosystem.config.js
โโโ jest.config.js
โโโ Makefile
โโโ nginx.conf
โโโ nodemon.json
โโโ package-lock.json
โโโ package.json
โโโ tsconfig.json
This application interacts with the Postgresql database, the HestiaCP API CLI and API Aplication Creator ( application for deploying a template application in a domain) which are deployed in the same environment.
Through the Hestia API, we will administer local hosting. Create new sites, configure the environment, dns zone, etc. Through the API Aplication creator, we will deploy the application itself on a new domain domain.
Let's prepare the development environment:
# if docker was not installed
# for archlinux
$ sudo pacman -S docker docker-compose
$ sudo usermod -aG docker ${USER}
# logout from user and go in
# get code
$ git clone git@github.com:vzx7/chat3-manager-backend.git
$ cd chat3-manager-backend
$ npm i
To build the application, you need to add two files to the root dir .env for docker-compose, and .env.development.local for the application itself. They should contain the following variables:
# PORT
PORT = 3000
# TOKENS
TOKEN_SECRET_KEY = your_key
REFRESH_TOKEN_SECRET_KEY = your_key
TOKEN_TIME = 15m
REFRESH_TOKEN_TIME = 15d
REFRESH_TOKEN_COOKIES_EXPIRES = 14 # days
# LOG
LOG_FORMAT = dev
LOG_DIR = ../logs
# CORS
ORIGIN = your_host
CREDENTIALS = true
# DATABASE
POSTGRES_USER = root
POSTGRES_PASSWORD = your_password
POSTGRES_HOST = localhost
POSTGRES_PORT = 5432
POSTGRES_DB = dev
# EXTERNAL API
EXTERNAL_API_URL = api_host
EXTERNAL_API_PORT = 4567
EXTERNAL_API_KEY = api_key
Let's build and launch
$ ./src/scripts/dockerStart.sh
Stop app:
$ ./src/scripts/dockerStop.sh