Giter Club home page Giter Club logo

todo-graphql-nestjs's Introduction

📝 Description

A TODO GraphQL API boilerplate

🎉 Features

  • 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

🧰 Installation

Prerequisites

  • Linux or macOS
  • Node v12 LTS
  • Globally yarn & nest commands
  • Docker

Install yarn packages before continue

yarn

Setting up PostgreSQL database

  • 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

Creating the initial database

Run initial migrations to set up initial database tables

yarn typeorm migration:run

⌨ Development

⚙ Running the app

# development
yarn start

# watch mode
yarn start:dev

# production mode
yarn start:prod

🎮 Playground & 🩺 Health check

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

🧪 Running tests

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

📏 Lint

Linting codebase

# issues are automatically fixed
yarn lint

🧳 Migrations

Run typeorm CLI

Automatically generating migrations

You can generate migration files

  1. Update entity source code
  2. You have an up-to-date local development database
# creates a file under src/migrations/
yarn typeorm migration:generate -n MigrationName

Apply migrations against the local database

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'

📖 Documentation

Generating codebase documentation(served at http://127.0.0.1:8080)

yarn doc

📦 Building

Before building application to production, make sure environment variables are applied correctly

Building for production

yarn build

Running on production

yarn start:prod

✅ TODO

[ ] 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

💻 Code style

The current code style is following clean code, some design patterns and SOLID principles

🛠 Built with

  • 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)

👷 Authors

See also the list of contributors who participated in this project

📝 License

Copyright © 2020 Lucas Silva
This project is MIT licensed

todo-graphql-nestjs's People

Contributors

lucasmonstrox avatar thiagobutignon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

odilonlimaneto

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.