https://github.com/puku0x/nestjs-todo-api
REST and GraphQL sample using NestJS + TypeORM + MySQL on Docker
https://github.com/puku0x/nestjs-todo-api
docker graphql mysql nestjs rest-api typeorm typescript
Last synced: 6 months ago
JSON representation
REST and GraphQL sample using NestJS + TypeORM + MySQL on Docker
- Host: GitHub
- URL: https://github.com/puku0x/nestjs-todo-api
- Owner: puku0x
- License: mit
- Created: 2019-08-17T02:52:19.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-23T23:55:52.000Z (over 3 years ago)
- Last Synced: 2025-02-01T22:15:12.016Z (over 1 year ago)
- Topics: docker, graphql, mysql, nestjs, rest-api, typeorm, typescript
- Language: TypeScript
- Homepage: http://localhost:3000/api/v1/todos
- Size: 1.7 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Description
A sample repository of [Nest](https://github.com/nestjs/nest) + [TypeORM](https://github.com/typeorm/typeorm) on Docker.
## Prerequirements
- [Docker](https://www.docker.com/)
## Installation
```bash
# install dependencies
$ docker-compose run app npm ci
```
## Running the app
```bash
# development
$ docker-compose up
# shutting down containers
$ docker-compose down
```
## Sample requests
```bash
$ curl -X POST http://localhost:3000/api/v1/todos \
-H "Content-Type: application/json" \
-d '{"text":"todo"}'
$ curl -X GET http://localhost:3000/api/v1/todos
$ curl -X GET http://localhost:3000/api/v1/todos/1
$ curl -X PUT http://localhost:3000/api/v1/todos/1 \
-H "Content-Type: application/json" \
-d '{"text":"done", "checked":true}'
$ curl -X DELETE http://localhost:3000/api/v1/todos/1
```
```
query {
todo(id: 1) {
id
text
checked
createdAt
updatedAt
}
}
query {
todos {
id
text
checked
createdAt
updatedAt
}
}
mutation {
createTodo(text: "todo") {
id
text
checked
createdAt
updatedAt
}
}
mutation {
updateTodo(id: 1, text: "done", checked: false) {
id
text
checked
createdAt
updatedAt
}
}
mutation {
removeTodo(id: 1)
}
```
## Test
```bash
# unit tests
$ docker-compose run app npm test
```
## Build
```bash
# unit tests
$ docker-compose run app npm run build
```
## License
This sample is [MIT licensed](LICENSE).