Skip to content

UNIZAR-30226-2023-01/chess-backend

Repository files navigation

chess-backend Production CI

Beta node npm

TypeScript Express.js MongoDB Mocha

Folder structure

  • 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.

Naming convention

  • ALL_CAPS for constants (e.g: GAME_OVER_TTL)
  • camelCase for variable names and object properties
  • PascalCase for type names and classes (e.g: ChessTimer)
  • kebab-case for module names (e.g: restore-queue)
  • kebab-case with namespaces sintax for Redis string keys (e.g: token-blacklist:user)

Getting Started

Run for a development environment

npm run dev

Run for a production environment

Command Line

Note this version requires to have ports 4000 and 4001 open on the router. This version does not support HTTPS

npm run tsc
npm run start

Docker

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

Docker Compose (preferred)

Note This version includes nginx redirection so the ports that need to be open in the router are 443 and 8443. 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

Learn More

To learn more about Express.js, take a look at the following resources:

You can check out the Expressjs GitHub repository

About

Backend del proyecto 'Chess' desarrollado en proyecto software

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •