Skip to content

antoinezanardi/werewolves-assistant-api-next

Repository files navigation

logo


TypeScript Nest Mongoose

βš™οΈ Build Workflow πŸš€ Deploy To Production Workflow

GitHub release semantic-release: conventional commits GitHub license DependenciesKnown Vulnerabilities

Tests count Scenarios Mutation testing badge

Technical Debt Duplicated Lines (%) Code Smells

πŸ“‹ Table of Contents

  1. 🐺 What is this API ?
  2. πŸƒ Available roles
  3. πŸ”¨ Installation
  4. πŸš€ Build
  5. 🐳 Docker
  6. πŸ’― Tests
  7. 🌿 Env variables
  8. β˜‘οΈ Code analysis and consistency
  9. πŸ“ˆ Releases & Changelog
  10. πŸ™ GitHub Actions
  11. ✨ Misc commands
  12. ©️ License
  13. ❀️ Contributors

Werewolves Assistant API provides over HTTP requests a way of manage Werewolves games to help the game master.

This is the next version of the current Werewolves Assistant API. It is still under development.

πŸ€” Want to know more about this awesome project ? Check out the dedicated about page.

30 different official roles are available to play :


Werewolf

Big Bad Wolf

Accursed Wolf-Father

White Werewolf

Villager

Villager-Villager

Seer

Cupid

Witch

Hunter

Little Girl

Defender

Elder

Scapegoat

Idiot

Two Sisters

Three Brothers

Fox

Bear Tamer

Stuttering Judge

Rusty Sword Knight

Wild Child

Wolf-Hound

Thief

Angel

Pied Piper

Scandalmonger

Prejudiced Manipulator

Actor

Devoted Servant

To install this project, you will need to have on your machine :

Node PNPM Docker

We recommend to use the node version specified in the .nvmrc file.

If you don't have pnpm installed, you can still use npm for all commands below, but we recommend to use pnpm for faster and more reliable installs.

Then, run the following commands :

# Install dependencies and Husky hooks
pnpm install

# Run the app in dev mode
pnpm run start:dev

The above command will start the app in development mode and watch for changes on local.

You can also run the app in development mode with Docker, more information in the Docker section.

In order to build the app for production, run the following command :

# Build the app
pnpm run build

# Run the app in production mode
pnpm run start:prod

You can also run the app in production mode with Docker, more information in the Docker section.

This app is Docker ready !

The Dockerfile is available at the root of the project.

πŸ”¨ Development mode

To run the app in development mode with Docker, multiple commands are available :

# Run the app in development mode with Docker
pnpm run docker:dev:start

# Stop the app in development mode with Docker
pnpm run docker:dev:stop

# Reset the app in development mode with Docker (stop, remove image, containers and volumes, then start)
pnpm run docker:dev:reset

When starting the app in development mode with Docker, a container for the API and a container for the MongoDB database are created.

Docker compose will use the development step of the Dockerfile to build the image.

For more information, please check the docker-compose.yml file.

πŸš€ Production mode

To run the app in production mode with Docker, multiple commands are available :

# Run the app in production mode with Docker
pnpm run docker:production:start

# Stop the app in production mode with Docker
pnpm run docker:production:stop

# Reset the app in production mode with Docker (stop, remove image, containers and volumes, then start)
pnpm run docker:production:reset

When starting the app in production mode with Docker, a container for the API and a container for the MongoDB database are created.

Docker compose will use the production step of the Dockerfile to build the image.

For more information, please check the docker-compose.yml file.

πŸ§ͺ Test mode

To run the tests available in this project thanks to Docker, multiple commands are available :

# Deploy test containers (4 databases are created to parallelize tests)
pnpm run docker:test:start

# Stop test containers
pnpm run docker:test:stop

# Reset test containers (stop, remove image, containers and volumes, then start)
pnpm run docker:test:reset

For more information, please check the docker-compose.yml file.

πŸ§ͺ Unit and E2E tests

Jest

Tests count

Covered Statements

Covered Branches

Covered Functions

Covered Lines

πŸ₯’ Acceptance tests

Cucumber

Scenarios

Click on the badge below πŸ‘‡ to see the reports.

ScenariosReports

πŸ‘½ Mutant testing

Stryker

Mutation testing badge

You can also check the mutation testing report.

▢️ Commands

Before testing, you must follow the installation steps.

Then, run one of the following commands :

# Assure you started test Docker containers (4 databases are created to parallelize tests)
pnpm run docker:test:start

# Run unit tests with coverage
pnpm run test:unit:cov

# Run e2e tests with coverage
pnpm run test:e2e:cov

# Run both unit and e2e tests with coverage
pnpm run test:cov

# Run both unit and e2e tests only on staged files (run on pre-commit)
pnpm run test:staged

# Run acceptance tests
pnpm run test:cucumber

# Run acceptance tests and publish the report
pnpm run test:cucumber:publish

# Run mutant tests with coverage
pnpm run test:stryker

# Run mutant tests with coverage from scratch (without using the incremental file)
pnpm run test:stryker:force

Environnement files are available in the env directory.

You can create a .env file in this directory to override the default values when starting the API locally with pnpm run start command.

Environment variables are :

Name Description Required Default value Limitations
HOST Host on which the API will be available ❌ 127.0.0.1 If set, can't be empty string
PORT Port on which the API will be available ❌ 8080 If set, must be a number between 0 and 65535
ENVIRONNEMENT Environment in which the API will run βœ… ❌ Must be development, production or test
DATABASE_HOST MongoDB database host URL βœ… ❌ Can't be empty string
DATABASE_PORT MongoDB database port ❌ undefined If set, must be a number between 0 and 65535
DATABASE_NAME MongoDB database name βœ… ❌ Can't be empty string
DATABASE_USERNAME MongoDB database user βœ… ❌ Can't be empty string
DATABASE_PASSWORD MongoDB database password βœ… ❌ Can't be empty string
CORS_ORIGIN CORS allowed origin ❌ * If set, can't be empty string

πŸ” Code linting & formatting

ESLint

In order to keep the code clean, consistent and free of bad TS practices, more than 300 ESLint rules are activated !

Complete list of all enabled rules is available in the .eslintrc.js file.

▢️ Commands

Before linting, you must follow the installation steps.

Then, run one of the following commands :

# Lint 
pnpm run lint

# Lint and fix
pnpm run lint:fix

# Lint and fix only on staged files (runs on pre-commit)
pnpm run lint:staged:fix

# Display all configs and rules used in browser using @eslint/config-inspector
pnpm run lint:inspect-config

πŸ₯‡ Project quality scanner

Multiple tools are set up to maintain the best code quality and to prevent vulnerabilities :

CodeQL

You can check the CodeQL analysis report here.

SonarCloud

SonarCloud summary is available here.

Coverage Duplicated Lines (%) Quality Gate Status

Technical Debt Vulnerabilities Code Smells

Reliability Rating Security Rating Bugs

Releases on main branch are generated and published automatically by :

Semantic Release

It uses the conventional commit strategy.

Each change when a new release comes up is listed in the CHANGELOG.md file.

Also, you can keep up with changes by watching releases via the Watch GitHub button at the top of this page.

This project uses GitHub Actions to automate some boring tasks.

You can find all the workflows in the .github/workflows directory.

🎒 Workflows

Name Description & Status Triggered on
βš™οΈ Build Various checks for app health, code quality and tests coverage

βš™οΈ Build Workflow
push on develop and all pull requests to develop
πŸ”ƒ Lint PR Name Into Develop Workflow Checks if pull request name respects conventionnal-commit rules

πŸ”ƒ Lint PR Name Into Develop Workflow
pull-request created or updated
⛡️ Push On Develop Branch Workflow Uploads app with develop version to Docker Hub

⛡️ Push On Develop Branch Workflow
push on develop
πŸ”ƒοΈ Upsert PR Release Workflow Creates or updates pull request to main depending on commits on develop since last release

πŸ”ƒοΈ Upsert PR Release Workflow
push on develop
🏷️ Release Creation Workflow Creates a new release using semantic-release with tag and updated changelog

🏷️ Release Creation Workflow
push on main
πŸš€ Deploy To Production Workflow Deploys app with last tag version to Docker Hub and GCP

πŸš€ Deploy To Production Workflow
tag-creation

🌳 Animated tree visualisation of the project's evolution with Gource

# Please ensure that `gource` is installed on your system.
pnpm run gource

πŸ”€ Create git branch with a conventional name

pnpm run script:create-branch

‴️ Create pull request against the develop branch from current branch

pnpm run script:create-pull-request

πŸ“£ To all IntelliJ IDEs users (IntelliJ, Webstorm, PHPStorm, etc.)

All the above commands are available in the .run directory at the root of the project.

You can add them as run configurations in your IDE.

This project is licensed under the MIT License.

There is no contributor yet. Want to be the first ?

If you want to contribute to this project, please read the contribution guide.

About

🐺 Werewolves Assistant API provides over HTTP requests a way of manage Werewolves games to help the game master.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •