Take the Accounting app from prev lesson and use PostgreSQL as a storage
Implement a REST API server using Node.js that manages Users and Expenses.
- Create a user
- Body:
{ name } - Returns:
201with created user - Returns
400ifnameis missing
- Returns all users (
200)
- Returns a user (
200) - Returns
404if not found
- Update user name
- Returns updated user (
200) - Returns
404if not found
- Deletes user
- Returns
204 - Returns
404if not found
- Create an expense
- Required:
spentAt,title,amount,userId - Optional:
category,note - Returns:
201with created expense - Returns
400if required fields are missing or user not found
- Returns all expenses (
200) - Supports filters:
userIdfrom/to(date range)categories(comma-separated)
- Returns expense (
200) - Returns
404if not found
- Update expense fields
- Returns updated expense (
200) - Returns
404if not found
- Deletes expense
- Returns
204 - Returns
404if not found
- Use JSON for all requests/responses
- Set header:
Content-Type: application/json; charset=utf-8 - Use proper HTTP status codes (
200,201,204,400,404) - Persist data using a database (e.g. Sequelize)
- You can sync models by running
npm run test - in local env, tests interect with your local database, so rows can be changed or removed
Read the guideline before start