Let's say there is a tournament for a game. Teams participate in the tournament.
Players can join teams.
There are managers who run games and look after players and teams.
Managers approve or reject players' requests and have some functionality to manage teams and players.
There are also administrators who approve managers' requests and also have some functionality to manage users.
-
User account functionality: 1.1 Registering the user account;
1.2 Logging in the user account;
1.3 Logging out of the user account;
1.4 User password recovery(enter email to reset password);
1.5 Changing the user password;
1.7 Displaying the user information;
1.6 Changing the user information. -
Admin functionality: 2.1 Show list of admins/managers/players;
2.2 Show one admin/manager/player by ID;
2.3 Ban manager/player by ID;
2.4 Unban manager/player by ID;
2.5 Show list of requests managers/players;
2.6 Show one request by ID manager/player;
2.7 Answer to manager's/player's request;
2.8 Show list of teams;
2.9 Show team information by ID;
2.10 Delete manager/player from team. -
Manager functionality: 3.1 Show list of admins/managers/players;
3.2 Show one admin/manager/player by ID;
3.3 Show list of requests players;
3.4 Show one request by player's ID;
3.5 Create own new request;
3.6 Cancel own request by ID;
3.7 Show list of own requests;
3.8 Show own request by ID;
3.9 Answer to player's request;
3.10 Show list of teams;
3.11 Show team information by ID;
3.12 Delete player from team. -
Player functionality: 4.1 Show list of admins/managers/players;
4.2 Show one admin/manager/player by ID;
4.3 Create own new request;
4.4 Cancel own request by ID;
4.5 Show list of own requests;
4.6 Show own request by ID;
4.7 Show list of teams;
4.8 Show team information by ID.
Server: JavaScript, Typescript, Node.js(v16.16.0), Express.js(v4.17.2), PostgreSQL, Sequelize(v6.21.3), sequelize-typescript
Test: Postman, Jest(v28.1.2)
- Clone the repo:
git clone https://github.com/DarkL0rdd/node-database-game
- Go to the project directory:
cd node-database-game
- Install NPM packages:
npm install
-
Create .env file (see .env.example or Environment Variables).
-
Start the server:
npm run dev
To run this project, you will need to add the following environment variables to your .env file:
SERVER_PORT=
SERVER_PORT_DB=
DB_DIALECT=
DB_USER=
DB_NAME=
DB_PASS=
DB_HOST=
ACCESS_SECRET_KEY=
REFRESH_SECRET_KEY=
- Import the file
node-game.postman_collection.json
in Postman. - Change the port and localhost to yours.
Some functionality can be applied to more than one role(admin/manager/player).
For example: an administrator/manager/player can view a list of teams. The administrator/manager can remove a player from the team. Etc.
POST /user/register
Parameter | Type | Description |
---|---|---|
first_name |
string |
Required. User's first name. |
second_name |
string |
Required. User's second name. |
email |
string |
Required. User's email. |
password |
string |
Required. User's password. |
POST /user/login
Parameter | Type | Description |
---|---|---|
email |
string |
Required. User's email. |
password |
string |
Required. User's password. |
POST /user/logout
Parameter | Type | Description |
---|
POST /user/forgot-password
Parameter | Type | Description |
---|---|---|
email |
string |
Required. User's email. |
POST /user/reset-password
Parameter | Type | Description |
---|---|---|
password |
string |
Required. User's password. |
GET /user/profile
GET /user/profile/change-info
Parameter | Type | Description |
---|---|---|
first_name |
string |
Required. User's first name. |
second_name |
string |
Required. User's second name. |
email |
string |
Required. User's email. |
password |
string |
Required. User's password. |
GET /user/list-users?role=
Parameter | Type | Description |
---|---|---|
role |
string |
Required. Role type. |
GET /user/list-users/:id
Parameter | Type | Description |
---|---|---|
id |
string |
Required. ID of the desired user. |
POST /user/list-users/:id/ban
Parameter | Type | Description |
---|---|---|
id |
string |
Required. ID of the desired user. |
POST /user/list-users/:id/unban
Parameter | Type | Description |
---|---|---|
id |
string |
Required. ID of the desired user. |
GET /request/list-requests
GET /request/list-requests/:id
POST /request/list-requests/answer-request/:id
Parameter | Type | Description |
---|---|---|
id |
string |
Required. ID of the desired request(!). |
answer |
string |
GET /teams/list-teams
GET /teams/list-teams/:id
Parameter | Type | Description |
---|---|---|
id |
string |
Required. ID of the desired team. |
POST /teams/list-teams/delete-from-team/:id
Parameter | Type | Description |
---|---|---|
id |
string |
Required. ID of the desired team. |
player_id |
string |
Required. ID of the desired player. |
GET /user/list-users?role=
Parameter | Type | Description |
---|---|---|
role |
string |
Required. Role type. |
GET /user/list-users/:id
Parameter | Type | Description |
---|---|---|
id |
string |
Required. ID of the desired user. |
POST /request/my-list-requests/new-request
Parameter | Type | Description |
---|---|---|
request_type |
string |
Required. Type of request. |
description |
string |
Optional. Description of request. |
team_name |
string |
Optional. ID of the desired user. |
POST /request/my-list-requests/cancel-request/:id
GET /request/my-list-requests
GET /request/my-list-requests/:id
Parameter | Type | Description |
---|---|---|
id |
string |
Required. ID of the desired user. |
GET /teams/list-teams
GET /teams/list-teams/:id
Parameter | Type | Description |
---|---|---|
id |
string |
Required. ID of the desired team. |
- Create a table of reasons for blocking users.
- Change/update routes to work correctly in Postman.
- Change/update db migrations
- Update "API Reference" in README.
In the future, README file will be supplemented or rewritten as additional changes appear.