Here’s an updated README
reflecting the migration information:
# Datalouna Test Task
This project demonstrates a web server built with TypeScript, PostgreSQL, Redis, and Docker for handling user authentication, item retrieval, and purchases.
## Features
- User authentication (JWT)
- Password change
- Item retrieval with price caching (via Redis)
- Purchases with balance checks
## Prerequisites
- Docker
- Docker Compose
## Running the Project
1. Clone the repository:
```bash
git clone https://github.com/yourusername/datalouna-test-task.git
-
Run the application using Docker Compose, which will build the necessary containers and apply database migrations:
npm install docker-compose up --build
Note: Migrations are handled automatically by the
migrate
container, which will runknex migrate:latest
to apply the latest database schema changes to PostgreSQL. This includes creating theusers
,items
, andpurchases
tables if they do not already exist. -
The server will be running at
http://localhost:3000
.
If you need to re-run migrations manually, use the following command:
docker-compose run migrate npx knex migrate:latest
This will apply the latest migrations to ensure the database schema is up to date.
To run the unit test:
docker-compose exec app npm run test:unit
To run the e2e test:
docker-compose exec app npm run test:e2e
POST /auth/login
- Authenticate a userPUT /user/password
- Change the user passwordGET /items
- Retrieve item prices (with Redis caching)POST /purchase
- Purchase an item (balance check)
- PostgreSQL and Redis are fully contained in Docker containers, requiring no external setup.
- Ensure migrations are applied as described above to avoid database-related errors during testing or runtime.
This update clarifies migration handling and manual steps for applying migrations, providing additional guidance on database setup within Docker.