Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/matii96/movies-svc
Netguru recruitment task
https://github.com/matii96/movies-svc
Last synced: 14 days ago
JSON representation
Netguru recruitment task
- Host: GitHub
- URL: https://github.com/matii96/movies-svc
- Owner: Matii96
- Created: 2021-05-31T19:05:31.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-06-04T13:44:35.000Z (over 3 years ago)
- Last Synced: 2024-11-07T07:51:09.428Z (2 months ago)
- Language: TypeScript
- Size: 255 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Description
Microservice for processing movies using [OMDb](https://www.omdbapi.com). Netguru recruitment [task](https://github.com/netguru/nodejs-recruitment-task).
## Installation
```bash
$ npm install
```## Environmental variables
```bash
$ APP_PORT=3100 # published port of movies microservice
$ PG_DATA=~/pgstore # host storage for postgresql
```All variables used by the service with their defaults are in .env configuration file.
## Running the app
```bash
# development
$ npm run start# watch mode
$ npm run start:dev# production mode
$ npm run start:prod # requires docker-compose
```Production mode uses PostgreSQL as database. Therefore requires to map its data store.
## Test
```bash
# unit tests
$ npm run test# e2e tests
$ npm run test:e2e # requires docker-compose# test coverage
$ npm run test:cov
```## Api documentation
`POST /movies`
- **Header**
`{ Authorization: "Bearer " }`
- **Body**
`{ title: "Star wars" }`
- **Success Response:**
- **Code:** 201
**Content:** `{"id":"d160fee1-3255-413c-b4de-acd3892c5533","title":"Star Wars: Episode IV - A New Hope","released":"1977-05-24T22:00:00.000Z","genre":"Action, Adventure, Fantasy, Sci-Fi","director":"George Lucas","createdAt":"2000-06-09T22:00:00.000Z"}`- **Error Response:**
- **Code:** 401 UNAUTHORIZED
OR
- **Code:** 403 FORBIDDEN
**Content:** `{ error : "movies-count-per-month-exceeded" }`OR
- **Code:** 400 BAD REQUEST
**Content:** `{ error : "OMDb api error / not found" }``GET /movies`
- **Header**
`{ Authorization: "Bearer " }`
- **Success Response:**
- **Code:** 200
**Content:** `[{"id":"d160fee1-3255-413c-b4de-acd3892c5533","title":"Star Wars: Episode IV - A New Hope","released":"1977-05-24T22:00:00.000Z","genre":"Action, Adventure, Fantasy, Sci-Fi","director":"George Lucas","createdAt":"2000-06-09T22:00:00.000Z"}]`OR
- **Code:** 401 UNAUTHORIZED
Interactive docs available at http://localhost:3100/docs in development and test modes.
## Continuous integration
GitHub Actions with automated tests.
## Technological stack
- [NestJS](https://nestjs.com)
- [Sequelize](https://sequelize.org) - postgres, sqlite in dev mode
- [Swagger UI](https://swagger.io/tools/swagger-ui/)## Final notes
Other solutions could have been used like CQRS, Event Sourcing and DDD but this API is far too simple for any more complex solutions at this moment.
When user is removed from auth-svc then his remaining movies here will lead to data inconsistency. The solution for that would be e.g. global event bus and subscribing to user removal event.