Back-end rest API made for student council (BDE in french).
- Secure authentication & administration system with student email
- Handling of challenge creation & accomplishment for integration purpuse
- Online market to buy goodies with fake money earned by doing challenges
This project was bootstrapped with Fastify-CLI.
- node
- docker & docker-compose
npm install
In the project directory, you can run:
To start the app in dev mode.
Open http://localhost:4000/doc to access documentation.
For production mode
To build the ORM types needed in the project
You need to setup few environment variables to setup your project :
- DATABASE_URI : URI to connect to DB, hint postgresql URI are formated like this : "postgresql://[user]:[password]@[host]/[database]"
- JWT_TOKEN : JWT secret key to cipher user id, if none provided the key will be "secrettoken"
- JWT_EXPIRATION : Expiration time for a user session, see JWT doc for formats, if none provided it will be "30d"
- EMAIL_REGEX : Regex that matches your particular student email, for example : "^[\w-.]+@([\w-]+.)*umontpellier.fr$" matches emails with umontpellier.fr domain, if none provided regex will match a classic email
- API-URL : URL used by the swagger to make API calls
Your need to have a postgresql database runing, don't forget to set the DATABASE_URI
A default database is available for dev in the parent project /infra/dev it will start a database accessible from "postgresql://webbde:webbde@localhost:5432/webbde?schema=public" by default, just run :
The database is divided into 4 main tables (+ 2 relational tables)
- User : Made for user storage
- Session: Made to store connection sessions of all users
- Goodies : Made to store all registered goodies in the shop
- Challenge : Made to store all registered challenges
There are 6 routes in this API :
- /user : User related tasks
- /session : Connection session related tasks
- /challenge : Challenge related tasks
- /accomplishment : Related to accomplishment of challenge made by users
- /goodies : Goodies related tasks
- /purchase : Related to purchase of some goodies made by users
To test routes and learn about all methods used by all routes, please visit the swagger documentation on route /doc
To learn Fastify, check out the Fastify documentation.