Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/temirlan-zh/test-task-user-api
Implementation of a test task for a job application.
https://github.com/temirlan-zh/test-task-user-api
e2e-tests jest mongodb mongoose nestjs rabbitmq rest-api typescript unit-testing
Last synced: 13 days ago
JSON representation
Implementation of a test task for a job application.
- Host: GitHub
- URL: https://github.com/temirlan-zh/test-task-user-api
- Owner: temirlan-zh
- Created: 2024-08-27T15:13:19.000Z (2 months ago)
- Default Branch: master
- Last Pushed: 2024-08-27T15:24:30.000Z (2 months ago)
- Last Synced: 2024-10-04T21:37:41.541Z (about 1 month ago)
- Topics: e2e-tests, jest, mongodb, mongoose, nestjs, rabbitmq, rest-api, typescript, unit-testing
- Language: TypeScript
- Homepage:
- Size: 164 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Description
Implementation of a test task for a job application.### Test task:
Should use:
- NestJS Framework
- MongoDB
- RabbitMQREST app should consist of:
- **POST /api/users**
Stores the user entry in db. After the creation, send an email and RabbitMQ event. Email can be dummy sending (no consumer needed).
- **GET /api/user/{userId}**
Returns a user in JSON representation.
- **GET /api/user/{userId}/avatar**
Retrieves image by 'avatar' field. Returns its base64-encoded representation.
On the first request it should save the image as a plain file, create a MongoDB entry with userId and hash.
On following requests should return the previously saved file.
- **DELETE /api/user/{userId}/avatar**
Removes the file from the file system and the stored entry from db.
Should cover code with unit and e2e tests.
## Installation
```bash
$ npm install
```## Running the app
```bash
$ npm run start
```
You should configure URIs for MongoDB and RabbitMQ in `.env` file.## Test
```bash
# unit tests$ npm run test
# e2e tests
$ npm run test:e2e
```
For e2e tests, you need to have running instances of MongoDB and RabbitMQ, and you need to configure the URIs in `.env.test` file.There is also a _Postman_ collection to help with manual testing.