Skip to content
/ UA-api Public

API web à destination des services de l'UTT Arena

License

Notifications You must be signed in to change notification settings

ungdev/UA-api

Repository files navigation

UA-api

Build Status codecov Read the Docs

API web à destination des services de l'UTT Arena

Avant toute chose, prenez connaissance de la documentation.

Requirements

Installation

git clone [email protected]:ungdev/UA-api.git
# or
git clone https://github.com/ungdev/UA-api.git

cd UA-api

# Install all the dependencies
pnpm install

# Copy the file .env.example to .env

cp .env.example .env

# Then, edit the variable DATABASE_URL in the file .env

Then, connect to your database (MySQL/MariaDB) and enter

CREATE DATABASE arena CHARACTER SET utf8;

Create the tables

pnpm prisma db push

Populate the tables

mysql -u DATABASE_USER -p arena --protocol tcp < seed.sql

Generate the prisma client (redo this command when you update schema.prisma)

pnpm prisma generate

Configuration

Edit the file .env with your values

Commands

pnpm dev              # start development server
pnpm build            # builds the typescript to javascript
pnpm start            # start production server
pnpm lint             # checks if the code is correct
pnpm lint-fix         # try to fix lint errors and warnings
pnpm fake             # populate the database with fake data
pnpm schema:push      # push the schema.prisma to the database
pnpm test:schema:push # push the schema.prisma to the test database (done automatically in tests)

Prisma config

Use npx prisma generate to generate your prisma client

How to test

The tests must be able to run without any environment variables except the database

Change the database for tests

Create a new .env.test file that will override values from .env :

cp .env.test.example .env.test

Change the database name to arena_test. Change the credentials too, like in the .env file.

Open MySQL/MariaDB, and run the following command to create the database :

CREATE DATABASE arena_test CHARACTER SET utf8;

What follows is mostly there for information purposes. It is done automatically during the tests. From what we know, there is no reason to use these commands. Come back to your terminal :

# Push the schema to the database :
pnpm test:schema:push

# Seed the database :
mysql -u DATABASE_USER -p arena_test --protocol tcp < seed.sql

Run the tests

pnpm test

Documentation

We build the documentation with Sphinx based on markdown. If you want to compile the documentation on your local PC, you will need to have Python 3 and then type the following commands:

cd docs
pip3 install -r requirements.txt
make html

It will create a build folder where the doc is located