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.
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 installNote
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.
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.
Not done yet, feel free to make a PR π
Not done yet, feel free to make a PR π
The easiest way to install PostgreSQL is to use Homebrew with:
brew install postgresql@13
brew services start postgresql@13 # start postgresql serviceAfter 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.
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:seedThe 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:prodBoth 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
./coveragefolder.
This project uses ESLint and Prettier to lint the code. You can run the linter with the following command:
pnpm run lintSwagger 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.