A Proper API #24

Open
opened 2024-08-30 21:10:42 +00:00 by TheClashFruit · 0 comments

So a proper api is needed since the current few routes are a mess, not to mention the db.

When NOT to design apis and databases:

  1. At 1 in the morning.

A few to-dos to do before the api:

  • Database Design
  • Types

API Design

The current proposed design.

Routes

Current User (only Self)

  • GET /user/@me - Get User Data
  • PATCH /user/@me - Update User Data
  • DELETE /user/@me - Delete All User Data
  • POST /user/@me/avatar - Change Avatar
  • POST /user/@me/banner - Change Banner
  • GET /user/@me/sessions - Get All Sessions
  • DELETE /user/@me/session/[id] - Log A Session Out

Other User

  • GET /user/[username|id] - Get User Data (Anyone /Without Email Included/) (Self, Super Admin /With Email Included/)
  • PATCH /user/[username|id] - Update User Data (Self, Admin)
  • DELETE /user/[username|id] - Delete All User Data (Self, Super Admin)
  • POST /user/[username|id]/avatar - Change Avatar (Self, Admin)
  • POST /user/[username|id]/banner - Change Banner (Self, Admin)
  • PATCH /user/[username|id]/permissions - Change Banner (Super Admin)

Nations

  • GET /nations - Get All Nations
  • GET /nation/[code|id] - Get A Nation
  • PATCH /nation/[code|id] - Update A Nation (Highest in Government, Admin)
  • DELETE /nation/[code|id] - Delete A Nation (Highest in Government, Super Admin)
  • POST /nation/[code|id]/flag - Update Flag (Government, Admin)
  • POST /nation - Establish A Nation (Anyone)

Companies

  • GET /nation/[code|id]/companies - Get A Nation's Companies
  • GET /nation/[code|id]/company/[id] - Get A Company
  • PATCH /nation/[code|id]/company/[id] - Update A Company (Owner, Government, Admin)
  • DELETE /nation/[code|id]/company/[id] - Delete A Company (Owner, Government, Super Admin)
  • POST /nation/[code|id]/company - Start A Company (Citizen, Admin)

Government

  • GET /nation/[code|id]/government - Get A Government
  • PATCH /nation/[code|id]/government - Edit A Government (Government, Admin)
  • POST /nation/[code|id]/government/user - Add A User
  • PATCH /nation/[code|id]/government/user - Edit A User
  • DELETE /nation/[code|id]/government/user - Remove A User

Gallery

  • GET /gallery - Get Gallery Images
  • GET /gallery/[id] - Get A Specific Image
  • POST /gallery - Upload An Image (Server Player, Admin)

Minecraft

  • GET /server/status - Server Status
  • GET /server/players - Online Players
  • POST /server/link - Link A Minecraft Account to a User

Admin (min. Admin)

  • GET /admin/users - Get All Users
  • POST /admin/team - Add Team Member
  • POST /admin/supertoken - Generate A "Super Super Admin" Token (Super Admin)
  • DELETE /admin/sessions - Log Everyone Out (Super Super Admin) (⚠ Token manually entered to make the request. Not recommended to call unless there were changes to the session system.)

Meta

  • GET /meta - Basic Info Of The Deployment
  • GET /meta/team - Get All Team Members

Other

  • GET /auth - Discord Auth Handler
  • POST /contact - Contact Form

Permissions

  • Super Super Admin Special Single Use Token
  • Super Admin 1 << 0
  • Admin 1 << 1
  • Server Player 1 << 2
So a proper api is needed since the current few routes are a mess, not to mention the db. When NOT to design apis and databases: 1. At 1 in the morning. A few to-dos to do before the api: * [X] ~~Database Design~~ * [X] ~~Types~~ ## API Design The current proposed design. ### Routes Current User (only Self) * [X] ~~`GET /user/@me` - Get User Data~~ * [ ] `PATCH /user/@me` - Update User Data * [ ] `DELETE /user/@me` - Delete All User Data * [ ] `POST /user/@me/avatar` - Change Avatar * [ ] `POST /user/@me/banner` - Change Banner * [X] ~~`GET /user/@me/sessions` - Get All Sessions~~ * [X] ~~`DELETE /user/@me/session/[id]` - Log A Session Out~~ Other User * [X] ~~`GET /user/[username|id]` - Get User Data (Anyone /Without Email Included/) (Self, Super Admin /With Email Included/)~~ * [ ] `PATCH /user/[username|id]` - Update User Data (Self, Admin) * [ ] `DELETE /user/[username|id]` - Delete All User Data (Self, Super Admin) * [ ] `POST /user/[username|id]/avatar` - Change Avatar (Self, Admin) * [ ] `POST /user/[username|id]/banner` - Change Banner (Self, Admin) * [ ] `PATCH /user/[username|id]/permissions` - Change Banner (Super Admin) Nations * [ ] `GET /nations` - Get All Nations * [ ] `GET /nation/[code|id]` - Get A Nation * [ ] `PATCH /nation/[code|id]` - Update A Nation (Highest in Government, Admin) * [ ] `DELETE /nation/[code|id]` - Delete A Nation (Highest in Government, Super Admin) * [ ] `POST /nation/[code|id]/flag` - Update Flag (Government, Admin) * [ ] `POST /nation` - Establish A Nation (Anyone) Companies * [ ] `GET /nation/[code|id]/companies` - Get A Nation's Companies * [ ] `GET /nation/[code|id]/company/[id]` - Get A Company * [ ] `PATCH /nation/[code|id]/company/[id]` - Update A Company (Owner, Government, Admin) * [ ] `DELETE /nation/[code|id]/company/[id]` - Delete A Company (Owner, Government, Super Admin) * [ ] `POST /nation/[code|id]/company` - Start A Company (Citizen, Admin) Government * [ ] `GET /nation/[code|id]/government` - Get A Government * [ ] `PATCH /nation/[code|id]/government` - Edit A Government (Government, Admin) * [ ] `POST /nation/[code|id]/government/user` - Add A User * [ ] `PATCH /nation/[code|id]/government/user` - Edit A User * [ ] `DELETE /nation/[code|id]/government/user` - Remove A User Gallery * [ ] `GET /gallery` - Get Gallery Images * [ ] `GET /gallery/[id]` - Get A Specific Image * [ ] `POST /gallery` - Upload An Image (Server Player, Admin) Minecraft * [ ] `GET /server/status` - Server Status * [ ] `GET /server/players` - Online Players * [ ] `POST /server/link` - Link A Minecraft Account to a User Admin (min. Admin) * [ ] `GET /admin/users` - Get All Users * [ ] `POST /admin/team` - Add Team Member * [ ] `POST /admin/supertoken` - Generate A "Super Super Admin" Token (Super Admin) * [ ] `DELETE /admin/sessions` - Log Everyone Out (Super Super Admin) (⚠ Token manually entered to make the request. Not recommended to call unless there were changes to the session system.) Meta * [X] ~~`GET /meta` - Basic Info Of The Deployment~~ * [X] ~~`GET /meta/team` - Get All Team Members~~ Other * [ ] `GET /auth` - Discord Auth Handler * [ ] `POST /contact` - Contact Form ### Permissions * Super Super Admin `Special Single Use Token` * Super Admin `1 << 0` * Admin `1 << 1` * Server Player `1 << 2`
TheClashFruit added this to the Website v2 milestone 2024-08-30 21:10:42 +00:00
TheClashFruit added the
Kind/Feature
Kind/Security
Kind/Breaking
Priority
Critical
labels 2024-08-30 21:10:42 +00:00
TheClashFruit self-assigned this 2024-08-30 21:10:42 +00:00
TheClashFruit added this to the Website v2 project 2024-09-01 12:47:45 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: CRSS/Website#24
No description provided.