8000 GitHub - abd1rahmane/goat-it-api: 🐐 Goat It API is a fast and efficient API built with NestJS and Fastify, designed to provide seamless backend services for Goat It applications. · GitHub
[go: up one dir, main page]

Skip to content

About

🐐 Goat It API is a fast and efficient API built with NestJS and Fastify, designed to provide seamless backend services for Goat It applications.

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Β 
Β 

Latest commit

Β 

History

1,402 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Goat It API

Goat It API Logo


TypeScript Nest Mongoose

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

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

Tests count Mutation testing badge Scenarios

Technical Debt Duplicated Lines (%) Code Smells

πŸ“– Table of Contents

Goat It API is the headless backend that stores and serves the quiz content β€” questions and question themes β€” for the Goat It game.

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

Node PNPM Docker

πŸ‘† Click on the badges above to go to the corresponding website.

  • Node.js β€” the required floor is declared in package.json (engines.node) and the version used by CI and tooling is pinned in configs/node/.node-version.
  • pnpm β€” the exact version is declared in package.json (packageManager).
  • MongoDB β€” a reachable instance; a local server on port 27017 is enough, and the optional Docker command below starts one.
  • Docker β€” optional for development (the MongoDB command below) and required for the acceptance-test MongoDB and the Docker image builds.

Then, install the dependencies and Husky hooks :

# Install dependencies and Husky hooks
pnpm install

βš™οΈ Environment

# Create your local environment file
cp env/.env.example env/.env

env/.env is git-ignored and is loaded when NODE_ENV is unset. Replace the three authentication placeholders with your own values:

  • API_KEY_HMAC_SECRET β€” at least 32 characters
  • ADMIN_API_KEY and GAME_API_KEY β€” at least 24 characters each

Start a MongoDB instance and keep MONGODB_HOST/MONGODB_PORT pointed at it. For example:

# Start a local MongoDB for development (port 27017)
docker run -d --name goat-it-mongodb -p 27017:27017 mongo:9

The example file uses MONGODB_HOST=0.0.0.0, a bind-style address; if your MongoDB only listens on loopback, set MONGODB_HOST=127.0.0.1. Do not point the dev server at the disposable acceptance-test container.

▢️ Run

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

The API listens on http://localhost:3000 (SERVER_PORT) and serves the Swagger UI at http://localhost:3000/docs.

The dev server compiles with SWC and executes the output through the tsx/esm loader, so the path aliases and extensionless imports resolve on Node ESM.

SWC

The API is built using SWC to provide faster and more reliable builds, and runs as native ESM ("type": "module"). The build also runs tsc-alias to resolve the path aliases and append the .js extensions ESM requires.

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

Production mode reads the process environment only: env/.env is not loaded (ignoreEnvFile), so export the required variables before pnpm run start:prod.

Docker

This app is Docker ready!

The Dockerfile is available at the root of the project. It uses a multi-stage build to optimize the image size and performance.

# Build the app using Docker on linux/arm64
pnpm run docker:build:linux/arm64

# Build the app using Docker on linux/amd64
pnpm run docker:build:linux/amd64

βœ… Quality gates

Run these five commands in this order before opening a PR. CI runs the same gates, with lint in check mode and the CI mutation profile.

pnpm run lint:fix
pnpm run typecheck
pnpm run test:unit:cov
pnpm run test:mutation
pnpm run test:acceptance

The acceptance gate needs the disposable MongoDB: run pnpm run docker:acceptance-tests:start before the sequence (see Acceptance tests below).

πŸ§ͺ Unit tests

Vitest

Tests count

Covered Statements Covered Branches

Covered Functions Covered Lines

This project uses Vitest for unit tests and is covered by 100% of its code.

All related test files are located in the src/ directory, alongside the code they test, suffixing the file name with .spec.ts.

# Run unit tests
pnpm run test:unit

# Run unit tests in watch mode
pnpm run test:unit:watch

# Run unit tests in coverage mode – used in CI pipelines
pnpm run test:unit:cov

πŸ₯’ Acceptance tests

Cucumber

Scenarios

This project uses Cucumber for acceptance tests.

All related files scenarios and features are located in the tests/acceptance directory.

The suite needs the disposable MongoDB container:

# Start the acceptance-test MongoDB
pnpm run docker:acceptance-tests:start

# Run acceptance tests
pnpm run test:acceptance

pnpm run docker:acceptance-tests:stop stops the container and keeps its volume; pnpm run docker:acceptance-tests:reset discards the volume and starts a fresh MongoDB.

πŸ‘½ Mutant testing

Stryker

Mutation testing badge

This project uses Stryker for mutation testing with 100% coverage (mutation score).

# Run mutation tests
pnpm run test:mutation

# Run mutation tests without incremental file (can be longer)
pnpm run test:mutation:force

πŸ” Code linting & formatting

Oxlint ESLint

This project uses Oxlint and ESLint for code linting and formatting with over 500 rules activated.

# Run code linting with both Oxlint and ESLint
pnpm run lint

# Run code linting with Oxlint only
pnpm run lint:oxlint

# Run code linting with ESLint only
pnpm run lint:eslint

# Run code linting with Oxlint and ESLint and fix issues
pnpm run lint:fix

# Inspect ESLint configuration
pnpm run lint:eslint: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 detailed metrics.

Coverage Duplicated Lines (%) Quality Gate Status

Technical Debt Vulnerabilities Code Smells

Reliability Rating Security Rating Bugs

Releases on the 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.

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

πŸ”€ Create a 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

🧹 Clean PR description from numbered diffhunk links

pnpm run script:clean-pr-description <pr-number>

This script removes numbered diffhunk links (e.g., [[1]](diffhunk://...)) from a PR description. These links are automatically generated by GitHub Copilot but can clutter the summary. A GitHub Actions workflow automatically runs this script when PRs targeting develop are opened or edited.

  • Architecture and file-placement conventions β€” where every file belongs, how it is named and what may depend on it.
  • JSDoc guide β€” JSDoc scope, concise-TSDoc style, examples and enforcement.
  • API contract β€” HTTP surface, DTO and error conventions, Swagger and the published schemas package.
  • Data model β€” MongoDB collections, fields, indexes, references and migration posture.
  • Domain logic β€” question and question-theme domain rules, invariants and error contracts.
  • Performance β€” indexing, query patterns, pagination and payload bounds.
  • Internationalization β€” Accept-Language pipeline, locales, fallback and translation completeness.
  • Security β€” authentication, validation, CORS, secrets, disclosure and known limitations.
  • Dependencies β€” scoped overrides, duplicate-major inventory and dependency-audit policy.
  • Privacy β€” data inventory, logging and telemetry PII policy, retention and legal posture.
  • Operations β€” health/readiness contract, container health check, graceful shutdown and post-deploy verification.
  • CI/CD, branching and release workflow β€” branches, commits, hooks, pull requests, CI and deployment.
  • Release procedure β€” step-by-step maintainer checklist for publishing a version.
  • Package scripts β€” every pnpm run script, grouped by purpose, with internal hook/CI-only entries marked.
  • Bruno collection β€” API collection setup and usage.
  • Unit tests β€” Vitest conventions per file type.
  • Acceptance tests β€” Cucumber, fixtures, payloads and steps.
  • Faketories β€” shared test-data factories.
  • Mocks β€” typed unit-test mock factories.

The tests/**/README.md files are short pointers to these guides.

GitHub license

This project is licensed under the MIT License.

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

Don't hesitate to browse the issues and pull requests to see what's coming up next.

If you want to contribute to this project, please read the CONTRIBUTING.md file for guidelines and our Code of Conduct.

About

🐐 Goat It API is a fast and efficient API built with NestJS and Fastify, designed to provide seamless backend services for Goat It applications.

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0