- Typescript
- Node.js
- ExpressJS
- Testing
- Jest
- Supertest
- Database
- MySQL
- Authentication
- JWT
- Register using the /users/signup route.
- Grab the token and use it as the Authorization header to sign in.
- Sign in and uses /assets/ routes to add, delete, update or read assets. Note: Sign in tokens expire after 1 hour.
-
POST /users/signup
- Sign up a new user- Request body:
{ "email": "[email protected]", "password": "password" }
- Response:
200 OK
{ "message": "New user added" }
- Errors:
400 Bad Request
- If request body is invalid or missing fields500 Internal Server Error
- If server encounters an error while signing up user
-
POST /users/signin
- Sign in a user- Request body:
{ "email": "[email protected]", "password": "password" }
- Response:
200 OK
{ "result": { "id": 1, "email": "[email protected]", "password": "$2b$10$w6jKTY6CQYceZiURRZQXYeI0NlLjxdCT1z4Tkq3BqPkkB0.lYFnhS" }, "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"
-
GET /assets/
- Retrieve all assets- Auth: Required
- Response:
200 OK
[ { "category": "property", "amount": 50000 }, { "category": "stocks", "amount": 20000 }, ... ]
- Errors:
401 Unauthorized
- If user is not authenticated500 Internal Server Error
- If server encounters an error while retrieving assets
-
POST /assets/add
- Add a new asset- Auth: Required
- Request body:
{ "category": "savings", "amount": 10000 }
- Response:
202 Accepted
{ "message": "Asset added" }
- Errors:
401 Unauthorized
- If user is not authenticated400 Bad Request
- If request body is invalid or missing fields500 Internal Server Error
- If server encounters an error while adding asset
-
PUT /assets/update
- Update an asset- Auth: Required
- Request parameters:
category
: The category of the asset to be updatedamount
: The new amount for the asset
- Request body:
{ "category": "savings", "amount": 10000 }
- Response:
202 Accepted
{ "message": "Asset updated: {category}" }
- Errors:
401 Unauthorized
- If user is not authenticated400 Bad Request
- If query parameters are invalid or missing500 Internal Server Error
- If server encounters an error while updating asset
-
DELETE /assets?category={category}
- Delete an asset- Auth: Required
- Request query parameters:
category
: The category of the asset to be deleted
- Response:
202 Accepted
{ "message": "Asset deleted: {category}" }
- Errors:
401 Unauthorized
- If user is not authenticated400 Bad Request
- If query parameters are invalid or missing500 Internal Server Error
- If server encounters an error while deleting asset