From 50fe9131442009acbbb5aa31adc5c3a93957eaed Mon Sep 17 00:00:00 2001 From: Ayush Mukherjee Date: Tue, 1 Nov 2022 15:16:26 +0530 Subject: [PATCH] add api docs --- API.md | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 API.md diff --git a/API.md b/API.md new file mode 100644 index 0000000..78cb3ea --- /dev/null +++ b/API.md @@ -0,0 +1,86 @@ +# Mx Leaderboard API Docs + +## /user + +src/user/user.controller + +### GET /user + +Returns a list of all users as User[] + +## /auth + +src/auth/auth.controller + +### POST /register + +@Request +```json +{ + "name": "user's name", + "email": "email@user.com", + "password": "user's password" +} +``` + +@Response +HTTP 201 Created OR HTTP 400 Bad Request + +### POST /login + +@Request +```json +{ + "email": "email@user.com", + "password": "user's password" +} +``` + +@Response +```json +{ + "access_token": "" +} +``` + +## /rank + +src/rank/rank.controller + +NOTE: @Authenticated: set authentication header with the jwt token. + +### GET / + +@Response +Returns the rank leaderboard as Rank[] + +### GET /:userId +@Authenticated + +@Response +Returns the user's current score as Rank + +### GET /:userId/all +@Authenticated + +@Response +Returns the user's rank history as Rank[] + +### POST /add20 +@Authenticated + +@Response +Returns new Rank with updated score +20 + + +### POST /add60 +@Authenticated + +@Response +Returns new Rank with updated score +60 + +### POST /add100 +@Authenticated + +@Response +Returns new Rank with updated score +100