Code Challenge
Task:
Create a simple RESTful API using Node.js and Express that allows users to manage a list of tasks. Each task should have the following properties:
- id (number): Unique identifier for the task
- title (string): Title of the task
- completed (boolean): Indicates whether the task is completed
The API should support the following endpoints:
GET /tasks - Retrieve all tasks
POST /tasks - Create a new task
PUT /tasks/:id - Update an existing task by ID
DELETE /tasks/:id - Delete a task by ID
Requirements:
- Use Node.js and Express for the backend.
- Use in-memory storage (an array) for tasks (no database required).
- Validate incoming data for the POST and PUT requests.
- Ensure that the API follows RESTful conventions.
Constraints:
- The challenge should be solvable in less than 30 minutes.
- Ensure code quality and use ES6+ features.
External Resources
Node.js
Express.js
Postman for testing the API (optional)The API is deployed on fly.io and available at taller-challenge.fly.dev.
Collection for Postman available here.
[!NOTE] Install dependencies Prefer
pnpmto install the dependencies. but any other package manager is ok
pnpm install[!TIP] Create and seed the database with the following command before running the project:
pnpm run db push[!TIP] Run the project with the
devscript:
pnpm run devThe tests are written with Vitest and the database is mocked via Drizzle with and in memory database.
[!TIP] Run the tests with the
testscript:
pnpm run test