Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jonathangaldino/private-pension-api
Private pension API - built with #nestjs and #prisma
https://github.com/jonathangaldino/private-pension-api
nestjs prisma
Last synced: 2 months ago
JSON representation
Private pension API - built with #nestjs and #prisma
- Host: GitHub
- URL: https://github.com/jonathangaldino/private-pension-api
- Owner: jonathangaldino
- Created: 2023-09-17T01:02:30.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-20T02:01:38.000Z (over 1 year ago)
- Last Synced: 2023-09-29T05:20:30.178Z (over 1 year ago)
- Topics: nestjs, prisma
- Language: TypeScript
- Homepage:
- Size: 225 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Description
This is a tech test, part of an interview process at a company I cannot disclosure.
To understand the requirements of the tech, go to INSTRUCTIONS.md.>
## Installation
### Requirements
- Postgres database (use docker for it)
- Clone the `.env.example` file and rename it to `.env`.[![Run in Insomnia}](https://insomnia.rest/images/run.svg)](https://insomnia.rest/run/?label=Private%20Pension%20API&uri=https%3A%2F%2Fgist.github.com%2Fjonathangaldino%2F3804f1a0117f693961b6b771b60c90d6)
### Dependencies
```bash
$ pnpm install
```## Running the app
```bash
# copy env variables
# make sure to modify the postgres connection to the right one
$ cp .env.example .env# development
$ pnpm run start# watch mode
$ pnpm run start:dev# production mode
$ pnpm run start:prod
```## Test
# copy env variables
# make sure to modify the postgres connection to the right one
$ cp .env.example .env.testing```bash
# unit tests
$ pnpm run test# test coverage
$ pnpm run test:cov
```Controller tests were made using Supertest, so the request is 'actually' made.
That's why we don't have any e2e tests, but we have integration ones.## Swagger documentation
Go to `http://localhost:3000/api`
## Running this API on a container
### Dockerfile
- Exposes the default port: 3000
- Is running the builded files (.js files - the ones that NestJS builds)### Docker Compose
Useful for local playground of the api. It will spawn:
- the api service
- a postgres databaseWhen you're running the compose for the first time, the api will crash because the database and migrations are not created yet.
For it to work:
On your .env file, you should have `DATABASE_URL` with the following value (example): `DATABASE_URL="postgres://postgres:postgres@postgres:5432/privatepension?schema=public&sslmode=prefer"`.
Run `$ docker compose up` and then, change the `HOST` from the `DATABASE_URL` to `localhost`. E.g: `DATABASE_URL="postgres://postgres:postgres@localhost:5432/privatepension?schema=public&sslmode=prefer"`
Now, you can create the database and then run the migrations:
`$ pnpm prisma migrate dev`. Later, restart the api service and you should be good to go.[Documentation](https://notiz.dev/blog/dockerizing-nestjs-with-prisma-and-postgresql)