This project demonstrates a REST API implementation for managing items, written in TypeScript. It includes endpoints for CRUD operations and other functionalities for evaluating candidates during interviews.
- CRUD operations for items
- RESTful API design
 
- Get list items with pagination
- Input validation ex. class-validator
- Modular and scalable project structure
- Search and filter items (name, price range)
- Sorting items
- Cache result of each request for 60 seconds
http://localhost:3000
- POST /items
- Request Body:
[ { "name": "string", "price": number "amount": number } ]
- Response:
[ { "id": "string", "name": "string", "price": number, "amount": number } ]
- GET /items
- Response:
[ { "id": "string", "name": "string", "price": number, "amount": number } ]
- GET /items/:id
- Response:
{ "id": "string", "name": "string", "price": number, "amount": number }
- PUT /items/:id
- Request Body:
{ "name": "string", "price": number, "amount": number }
- Response:
{ "id": "string", "name": "string", "price": number, "amount": number }
- DELETE /items/:id
- Response:
{ "message": "Item deleted successfully" }
swe-interview/
├── data/                # Directory for mount to docker
├── migrations/          # Database migration file
├── seeds/               # Seed file
├── src/
│   ├── index.ts         # Entry point
│   ├── knexfile.ts      # Knex configuration
├── .eslintrc.json       # ESLint configuration
├── .prettierrc          # Prettier configuration
├── package.json         # Dependencies and scripts
├── tsconfig.json        # TypeScript configuration
├── jest.config.js       # Jest configuration
├── docker-compose.yaml  # Docker for PostgreSQL
└── README.md            # Instructions for candidates
Ensure you have the following installed:
- 
Clone the repository: git clone https://github.com/your-repo/swe-interview.git cd swe-interview
- 
Install dependencies: yarn install # or npm install
- 
Run PostgreSQL Local: docker-compose up -d 
- 
Run database migration: yarn run migrate 
- 
Run seed data: yarn run seed 
- 
Run the project: yarn dev # or npm run dev
- 
Access the API at http://localhost:3000.