{"id":19714622,"url":"https://github.com/phatnguyenuit/itask-server","last_synced_at":"2026-05-04T00:34:11.931Z","repository":{"id":45276918,"uuid":"431188225","full_name":"phatnguyenuit/itask-server","owner":"phatnguyenuit","description":"iTask GraphQL server","archived":false,"fork":false,"pushed_at":"2021-12-27T13:45:29.000Z","size":355,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-10T14:59:06.349Z","etag":null,"topics":["apollo-graphql","docker","graphql","jest","mswjs","typescript"],"latest_commit_sha":null,"homepage":"https://itask-api.herokuapp.com/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phatnguyenuit.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-11-23T17:11:54.000Z","updated_at":"2022-11-05T16:04:18.000Z","dependencies_parsed_at":"2022-09-22T18:50:33.692Z","dependency_job_id":null,"html_url":"https://github.com/phatnguyenuit/itask-server","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phatnguyenuit%2Fitask-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phatnguyenuit%2Fitask-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phatnguyenuit%2Fitask-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phatnguyenuit%2Fitask-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phatnguyenuit","download_url":"https://codeload.github.com/phatnguyenuit/itask-server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241035791,"owners_count":19898082,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apollo-graphql","docker","graphql","jest","mswjs","typescript"],"created_at":"2024-11-11T22:34:26.519Z","updated_at":"2026-05-04T00:34:11.895Z","avatar_url":"https://github.com/phatnguyenuit.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# iTask GraphQL Server\n\n![CI/CD](https://github.com/phatnguyenuit/itask-server/workflows/CI/badge.svg)\n[![codecov](https://codecov.io/gh/phatnguyenuit/itask-server/branch/master/graph/badge.svg?token=0JzRGxgu6c)](https://codecov.io/gh/phatnguyenuit/itask-server)\n![License](https://img.shields.io/github/license/phatnguyenuit/itask-server)\n\niTask GraphQL server\n\n## Table of contents\n- [iTask GraphQL Server](#itask-graphql-server)\n  - [Table of contents](#table-of-contents)\n  - [Features](#features)\n  - [Setup](#setup)\n    - [Prerequisites](#prerequisites)\n    - [Development](#development)\n    - [Production](#production)\n  - [Dockerize](#dockerize)\n    - [1. Development](#1-development)\n    - [2. Production](#2-production)\n  - [Setup GitHub Actions](#setup-github-actions)\n  - [Scripts](#scripts)\n    - [1. Development](#1-development-1)\n    - [2. Build](#2-build)\n    - [3. Generate type validators](#3-generate-type-validators)\n    - [4. Generate GraphQL TypeScript shared types](#4-generate-graphql-typescript-shared-types)\n    - [5. Generate both GraphQL TypeScript shared types and type validators](#5-generate-both-graphql-typescript-shared-types-and-type-validators)\n    - [6. Generate Prisma client](#6-generate-prisma-client)\n    - [7. Migrate Prisma dev environment](#7-migrate-prisma-dev-environment)\n    - [8. Deploy Prisma schema](#8-deploy-prisma-schema)\n    - [8. Git commit with commitizen CLI](#8-git-commit-with-commitizen-cli)\n    - [9. Backup database](#9-backup-database)\n    - [10. Restore database](#10-restore-database)\n    - [11. Restore database automatically on Docker](#11-restore-database-automatically-on-docker)\n    - [12. Unit test](#12-unit-test)\n    - [13. Test coverage](#13-test-coverage)\n  - [References](#references)\n\n## Features\n\n- RESTful API\n- Apollo GraphQL server\n- Full TypeScript codebase\n- Unit test with Jest\n- Dockerize\n- Wait for `PostgreSQL` readiness before starting NodeJS server (on the Docker environment)\n\n## Setup\n\n### Prerequisites\n\n1. Prepare ENV files\n\n    Base on `.env.example` file, define your environment variables\n\n    ```sh\n    cp .env.example .env\n    ```\n\n2. Install `node_modules`\n\n      - Using `npm`:\n        \n      ```sh\n      npm install\n      ```\n\n      - Using `yarn`:\n\n      ```sh\n      yarn\n      ```\n\n### Development\n\n\u003e Start dev server\n\n   - Using `npm`:\n\n     ```sh\n     npm run dev:server\n     ```\n\n   - Using `yarn`:\n\n     ```sh\n     yarn dev:server\n     ```\n\n### Production\n\n1. Build production\n\n   - Using `npm`:\n   \n   ```sh\n   npm run build\n   ```\n\n   - Using `yarn`:\n   \n   ```sh\n   yarn build\n   ```\n2. Start production server using PM2\n\n   - Using `npm`:\n   \n   ```sh\n   npm run start:prod\n   ```\n\n   - Using `yarn`:\n   \n   ```sh\n   yarn start:prod\n   ```\n\n## Dockerize\n\n### 1. Development\n\n- Prepare ENV files\n\n  Base on `.docker.dev.env.example` file, define your environment variables\n\n  ```sh\n  cp .docker.dev.env.example .docker.dev.env\n  ```\n\n- Start docker compose (`docker-compose.yml \u0026 docker-compose.dev.yml`)\n\n  ```\n  ./scripts/dev up -d\n  ```\n\n- Stop docker compose (`docker-compose.yml \u0026 docker-compose.dev.yml`)\n\n  ```\n  ./scripts/dev stop\n  ```\n\n### 2. Production\n\n- Prepare ENV files\n\n  Base on `.docker.prod.env.example` file, define your environment variables\n\n  ```sh\n  cp .docker.prod.env.example .docker.prod.env\n  ```\n\n- Start docker compose (`docker-compose.yml \u0026 docker-compose.prod.yml`)\n\n  ```\n  ./scripts/prod up -d\n  ```\n\n- Stop docker compose (`docker-compose.yml \u0026 docker-compose.prod.yml`)\n\n  ```\n  ./scripts/prod stop\n  ```\n\n\n## Setup GitHub Actions\n\nThere are 2 (two) action workflows:\n\n- `test`\n\n  This will be triggered automatically on every open Pull request to `master` branch\n\n  This workflow runs test coverage script during the invocation\n\n- `ci`\n\n  This will be triggered automatically on every open Pull request to `master` branch\n\n  This workflow runs:\n\n  - Test coverage\n  - Upload test coverage to `Codecov`\n  - Release new version\n\nRequired steps:\n\n- Register your repository with `Codecov` to get `CODECOV_TOKEN`\n- Configure repository secrets with name `CODECOV_TOKEN`\n\n## Scripts\n\n### 1. Development\n\n\u003e Run \u0026 develop\n\n- Using `yarn`:\n\n  ```sh\n  yarn dev:server\n  ```\n\n- Using `npm`:\n\n  ```sh\n  npm run dev:server\n  ```\n\n### 2. Build\n\n\u003e Build production source code\n\n- Using `yarn`:\n\n  ```sh\n  yarn build\n  ```\n\n- Using `npm`:\n\n  ```sh\n  npm run build\n  ```\n### 3. Generate type validators\n\n\u003e Generate TypeScript validator files\n\n- Using `yarn`:\n\n  ```sh\n  yarn codegen:validators\n  ```\n\n- Using `npm`:\n\n  ```sh\n  npm run codegen:validators\n  ```\n\n### 4. Generate GraphQL TypeScript shared types\n\n\u003e Generate TypeScript shared types from GraphQL\n\n- Using `yarn`:\n\n  ```sh\n  yarn codegen:gql\n  ```\n\n- Using `npm`:\n\n  ```sh\n  npm run codegen:gql\n  ```\n\n### 5. Generate both GraphQL TypeScript shared types and type validators\n\n\u003e Combine [command 3](#3-generate-type-validators) and [command 4](#4-generate-graphql-typescript-shared-types)\n\n- Using `yarn`:\n\n  ```sh\n  yarn codegen\n  ```\n\n- Using `npm`:\n\n  ```sh\n  npm run codegen\n  ```\n\n### 6. Generate Prisma client\n\n\u003e Generate Prisma client (`./node_modules/.prisma`)\n\n- Using `yarn`:\n\n  ```sh\n  yarn prisma:generate\n  ```\n\n- Using `npm`:\n\n```sh\nnpm run prisma:generate\n```\n\n### 7. Migrate Prisma dev environment\n\n\u003e Migrate Prisma schema and apply to database\n\n- Using `yarn`:\n\n  ```sh\n  yarn prisma:dev\n  ```\n\n- Using `npm`:\n\n  ```sh\n  npm run prisma:dev\n  ```\n### 8. Deploy Prisma schema\n\n\u003e Apply Prisma schema to production environment\n\n- Using `yarn`:\n\n  ```sh\n  yarn prisma:deploy\n  ```\n\n- Using `npm`:\n\n  ```sh\n  npm run prisma:deploy\n  ```\n### 8. Git commit with commitizen CLI\n\n\u003e Commit CLI command with interactive\n\n- Using `yarn`:\n\n  ```sh\n  yarn commit\n  ```\n\n- Using `npm`:\n\n  ```sh\n  npm run commit\n  ```\n\n### 9. Backup database\n\n  ```sh\n  pg_dump -v -U $POSTGRES_USER -O -d $POSTGRES_ITASK_DB \u003e path/to/sql/file\n  ```\n\n### 10. Restore database\n\n  ```sh\n  psql -v -U $POSTGRES_USER -d $POSTGRES_ITASK_DB \u003c path/to/sql/file\n  ```\n\n### 11. Restore database automatically on Docker\n\n- Prepare a SQL backup file (named `$POSTGRES_ITASK_DB.sql` with `$POSTGRES_ITASK_DB` is your defined environment variable)\n- Place the SQL backup file under `./backup` folder.\n- When docker running up, this backup file will be restored automatically.\n\n### 12. Unit test\n\n- Using `npm`:\n\n  ```sh\n  npm run test\n  ```\n\n- Using `yarn`:\n\n  ```sh\n  yarn test\n  ```\n\n### 13. Test coverage\n\n As configuration from `./jest.config.ts` Jest will fail if there is less than `90%` branch, line, and function coverage, or if there are more than `10` uncovered statements:\n\n- Using `npm`:\n\n  ```sh\n  npm run test -- --coverage\n  ```\n\n- Using `yarn`:\n\n  ```sh\n  yarn test --coverage\n  ```\n\n## References\n\n- [Apollo GraphQL](https://www.apollographql.com/docs/)\n- [Prisma ORM](https://www.prisma.io/docs/getting-started/)\n- [Docker - Control startup and shutdown order in Compose](https://docs.docker.com/compose/startup-order/)\n- [Wait for it](https://github.com/vishnubob/wait-for-it)\n- [Mock Prisma client](https://www.prisma.io/docs/guides/testing/unit-testing#mocking-the-prisma-client)\n- [Apollo GraphQL server testing](https://www.apollographql.com/docs/apollo-server/testing/testing/)\n- [ExpressJS Server testing with `supertest`](https://github.com/visionmedia/supertest)\n- [API Mocking with `mswjs.io`](https://mswjs.io/)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphatnguyenuit%2Fitask-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphatnguyenuit%2Fitask-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphatnguyenuit%2Fitask-server/lists"}