This is a RESTful API that uses:
- Node.js
- Typescript.js
- Express.js
- SQLite3
- Prisma
- express-validator
- mocha & chai & supertest
- Dependency Injection
npm i
npx run start
Default port: 7000 (.env file)
npm test
The REST API is described below. Only "Create user" and "Login" services are public. For the rest you must add an Authorization header "Bearer token" in order to call them. You can also import the Postman project "postman_soccermanager.json" from the root folder to test the API. Fields with a (*) are required.
POST /user
{
* email: "[email protected]",
firstName= "first name",
lastName= "last name",
countryCode= "US",
* password="password1"
}
HTTP/1.1 200 OK
{
id:1,
email: "[email protected]",
firstName= "first name",
lastName= "last name",
countryCode= "US",
password="password1",
team= {...}
}
POST /session
{
* email: "[email protected]",
* password="password1"
}
HTTP/1.1 200 OK
{
token:"tokendata...",
user: userData
}
DELETE /session
Authorization: Bearer token....
HTTP/1.1 200 OK
GET /player/:id
Authorization: Bearer token....
Returns player
HTTP/1.1 200 OK
{
"id": 54,
"name": "Juan",
"age": 35
...
..
}
PUT /player/:id
Authorization: Bearer token....
{
name= "Test player name",
countryCode= "US",
}
Returns team HTTP/1.1 200 OK
GET /team/:id
Authorization: Bearer token....
Returns team HTTP/1.1 200 OK { "id": 2, "name": "Team 1", "countryCode": "US" ... .. }
PUT /team/:id
Authorization: Bearer token....
{
name= "Test team name",
countryCode= "US",
}
Returns team HTTP/1.1 200 OK
GET /transfer
Authorization: Bearer token....
Returns team HTTP/1.1 200 OK { [ { "id":1, "player1", "price": 5000000, ... }, { "id":2, "player2", "price": 3000000, ... } ] }
POST /transfer/:id
Authorization: Bearer token....
{
* "playerId":2,
* "price":1567000
}
Returns team HTTP/1.1 200 OK { "id": 2, "playerId": 2, "price":1567000, "publishedOn": ... ... .. }
put /transfer/:id
Authorization: Bearer token....
{
}
Returns team HTTP/1.1 200 OK { "id": 2, "playerId": 2, "price":1567000, "active": false "publishedOn": ... ... .. }