Skip to content
This repository was archived by the owner on Sep 18, 2024. It is now read-only.

ae-utbm/api

Β 
Β 

Repository files navigation

AE UTBM - API

Discord GitHub issues GitHub pull requests


This repository contains the source code of the API used by the Sith 4 to manage its members, events, etc. Feel free to contribute to this project by opening a pull request or an issue.

  • This project is under the GNU GPLv3 license.
  • You can find the contributing guidelines here.

Table of contents

Installation

Project

To run this project, you will need to install NodeJS and pnpm.

# install pnpm globally (npm comes with nodeJS)
npm install -g pnpm
# clone the repository
# note: we use --recurse-submodules to clone the types repository as well
git clone --recurse-submodules 'https://github.com/ae-utbm/api.git'

# install the dependencies
pnpm install

Note
This project use the typings repository as a git submodule to manage output types for all endpoints, this submodule is also present in the Sith 4 and allows to share the types between the two projects.

Environment variables

The API can be configured trough a lot of environment variables, you can find them in the .env.example file. You will need to create a .env file and fill it with the values you want to use before running the API.

Database

PostgreSQL Installation

Linux

Not done yet, feel free to make a PR πŸŽ‰

Windows

Not done yet, feel free to make a PR πŸŽ‰

MacOS

The easiest way to install PostgreSQL is to use Homebrew with:

brew install postgresql@13
brew services start postgresql@13 # start postgresql service

Configuration

After the installation, you can use pgAdmin to create a server with the following parameters:

.env pgAdmin 4 value
DB_HOST Host 127.0.0.1
DB_PORT Port 5432
DB_USERNAME Username Should be the username you used to install postgresql or any user you have created for it
DB_PASSWORD Password leave it empty, unless you have set a password for your postgresql user
DB_DATABASE Maintenance database postgres

Note
You can also use TablePlus to manage your databases as a lightweight (but more limited, in the free edition) alternative to pgAdmin.

Note
You have to create a server before creating a database, as the database will be created in the server you have selected.

First time setup

As the database has never been used, you will need to create it and run the seeders to populate it with some base data. You can do so with the following commands:

# create the database (will drop if already exists and create it again)
pnpm run db:create

# run the seeders (to populate the database with some base data)
pnpm run db:seed

Launch

The API is built with NestJS and uses TypeScript. You can run it with the following commands:

# debug mode
pnpm run start:debug

# watch mode
pnpm run start:dev

# production mode
pnpm run start:prod

Tests

Both unit and e2e tests are available and run with Jest. You can run them with the following command:

# all tests
pnpm test

# unique test file
pnpm test -- "auth.e2e-spec.ts"

After running the tests, a coverage report is generated in the ./coverage folder.

Linting

This project uses ESLint and Prettier to lint the code. You can run the linter with the following command:

pnpm run lint

Documentation

Swagger is used to generate the documentation of the API, you can access it at the /docs endpoint when the app is launched.

For the more in depth documentation on how to develop on this project, you can check the wiki.

About

API used for the version 4 of our website

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages