A TODO GraphQL API boilerplate
- TODOS: CRUD around TODOS
- ORM: TypeORM on PostgreSQL
- Graphql: TypeGraphQL
- Cache System: type-cacheable
- Logging: NestJS default logger
- Sanitizer: class-sanitizer
- E2E tests: SuperTest
- Unit tests: Jest
- Commit semantic: commitlint + husky
- Code format and lint: eslint + prettier
- Documentation: Compodoc
- Linux or macOS
- Node v12 LTS
- Globally
yarn
&nest
commands - Docker
Install yarn packages before continue
yarn
- This is will make a new PostgreSQL running in the standard port
5432
- Please shutdown any previous conflicting PostgreSQL instances before starting this
docker-compose up -d
Check the database is up
docker logs -f todo_pg
Check that you can log into a database with psql
docker exec -it todo_pg psql -U todo_pg_user todo_pg_db
View tables
\dt
Run initial migrations to set up initial database tables
yarn typeorm migration:run
# development
yarn start
# watch mode
yarn start:dev
# production mode
yarn start:prod
After the application starts, go to http://localhost:$PORT/health
to check
health indicators statuses or http://localhost:$PORT/graphql
to access graphql
playground
Observartion: You must change $PORT
for the port to be used in your
environment
Creating tests database Only integration tests are supported. Backend is spun up on a special database
Tests use their own database. To create it:
docker exec -it todo_pg psql -U todo_pg_user -c "create database todo_pg_db_test" todo_pg_db
Note that in backend/config/typeorm.config.ts the todo_db_test database is configured to synchronize TypeORM migrations automatically, unlike the development database.
# unit tests
yarn test
# e2e tests
yarn test:e2e
# test coverage
yarn test:cov
After executing yarn test:cov
, the coverage
folder will be generated with
coverage details
Linting codebase
# issues are automatically fixed
yarn lint
Run typeorm
CLI
You can generate migration files
- Update entity source code
- You have an up-to-date local development database
# creates a file under src/migrations/
yarn typeorm migration:generate -n MigrationName
yarn typeorm migration:run
Check the result of migrations using psql
command-line tool
docker exec -it todo_pg psql -U todo_pg_user todo_pg_db
\d 'todo'
Generating codebase documentation(served at http://127.0.0.1:8080
)
yarn doc
Before building application to production, make sure environment variables are applied correctly
Building for production
yarn build
Running on production
yarn start:prod
[ ] Add code of conduct file
[ ] Add docker section to make project working through docker
[ ] Add project files structure
[ ] Add issue template file
[ ] Add typeorm-seeding within seeds
[ ] Check if env variables are loading correctly using
schema-validation
[ ] Track errors in production. Use sentry.io or similar
Observation: Some TODOS are spread across the code and need to be fixed ASAP
The current code style is following clean code
, some design patterns
and
SOLID
principles
- compodoc - The missing documentation tool for your Angular application
- jest - Jest is a delightful JavaScript Testing Framework with a focus on simplicity
- nestjs - A progressive Node.js framework for building efficient, reliable and scalable server-side applications
- supertest - Small progressive client-side HTTP request library, and Node.js module with the same API
- typegraphql - Modern framework for GraphQL API in Node.js
- typeorm - Amazing ORM for TypeScript and JavaScript (ES7, ES6, ES5)
- Lucas Silva joao.galiano.silva@gmail.com - Developer
- Thiago Butignon thiago@betaquark.com - Reviewer
See also the list of contributors who participated in this project
Copyright © 2020 Lucas Silva
This project is MIT licensed