app.ts
: This is the main file of your project, it could be the entry point of your application and where you will set up your server.config
: This directory contains any configuration files, such as database connection settings, that the application needs to run.test
: This folder contains tests to check the correct operation of the application.lib
: This folder contains modules with very specific functionality or collections of functions used repeatedly by controllers.api_server/controllers
: This directory contains the application's controllers, which are responsible for handling user input and updating the model and view accordingly.api_server/middleware
: This folder stores intermediate functionalities that act as middelwares for filtering certain requests.api_server/models
: This directory contains the application's data models, which are responsible for handling data and business logic.api_server/routes
: This directory contains the application's routing files, which map URLs to specific controllers and actions.
ALL_CAPS
for constants (e.g:GAME_OVER_TTL
)camelCase
for variable names and object propertiesPascalCase
for type names and classes (e.g:ChessTimer
)kebab-case
for module names (e.g:restore-queue
)kebab-case
withnamespaces
sintax for Redis string keys (e.g:token-blacklist:user
)
npm run dev
Note this version requires to have ports
4000
and4001
open on the router. This version does not support HTTPS
npm run tsc
npm run start
Build Docker image:
docker build -t chess-backend-express:latest .
Run the container:
docker run -p 4000:4000 -p 4001:4001 --env-file .env chess-backend-express:latest
Another option is to run the compiled and tested image and run the container with it as follows:
docker run -p 4000:4000 -p 4001:4001 --env-file .env ghcr.io/unizar-30226-2023-01/chess-backend:latest
Note This version includes
nginx
redirection so the ports that need to be open in the router are443
and8443
. This version supports HTTPS.
Follow the instructions on the following page to get a certificate.
mkdir -p nginx/certs
sudo cp /etc/letsencrypt/live/api.gracehopper.xyz/* nginx/certs
docker-compose up -d
To learn more about Express.js, take a look at the following resources:
- Express.js Documentation - learn about Express.js features
You can check out the Expressjs GitHub repository