Skip to content
This repository was archived by the owner on Jun 24, 2021. It is now read-only.

Commit f8fd498

Browse files
committed
Init project
1 parent 3bcb3ab commit f8fd498

19 files changed

+9179
-15
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root=true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true

.eslintrc.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser',
3+
parserOptions: {
4+
project: 'tsconfig.json',
5+
tsconfigRootDir: __dirname,
6+
sourceType: 'module',
7+
},
8+
plugins: ['@typescript-eslint/eslint-plugin'],
9+
extends: [
10+
'plugin:@typescript-eslint/recommended',
11+
'prettier/@typescript-eslint',
12+
'plugin:prettier/recommended',
13+
],
14+
root: true,
15+
env: {
16+
node: true,
17+
jest: true,
18+
},
19+
ignorePatterns: ['.eslintrc.js', 'node_modules'],
20+
rules: {
21+
'@typescript-eslint/interface-name-prefix': 'off',
22+
'@typescript-eslint/explicit-function-return-type': 'off',
23+
'@typescript-eslint/explicit-module-boundary-types': 'off',
24+
'@typescript-eslint/no-explicit-any': 'off',
25+
},
26+
};

.gitignore

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# compiled output
2+
/dist
3+
/node_modules
4+
5+
# Logs
6+
logs
7+
*.log
8+
npm-debug.log*
9+
yarn-debug.log*
10+
yarn-error.log*
11+
lerna-debug.log*
12+
13+
# OS
14+
.DS_Store
15+
16+
# Tests
17+
/coverage
18+
/.nyc_output
19+
20+
# IDEs and editors
21+
/.idea
22+
.project
23+
.classpath
24+
.c9/
25+
*.launch
26+
.settings/
27+
*.sublime-workspace
28+
29+
# IDE - VSCode
30+
.vscode/*
31+
!.vscode/settings.json
32+
!.vscode/tasks.json
33+
!.vscode/launch.json
34+
!.vscode/extensions.json
35+
36+
# Variables enviroment
37+
.env
38+
.env.local
39+
.env.development
40+
.env.production
41+
.docker.env
42+
prisma.env

.prettierrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all"
4+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Tien Duy
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 64 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,73 @@
1-
# NestJS - GraphQL - Prisma 2
1+
<p align="center">
2+
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo_text.svg" width="320" alt="Nest Logo" /></a>
3+
</p>
24

3-
Example backend [NestJS](https://nestjs.com/) - [Graphql](https://graphql.org/) project using [Prisma 2](https://www.prisma.io/) & [PostgreSQL](https://www.postgresql.org/)
5+
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
6+
[circleci-url]: https://circleci.com/gh/nestjs/nest
47

5-
---
8+
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
9+
<p align="center">
10+
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
11+
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
12+
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
13+
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
14+
<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
15+
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
16+
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
17+
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
18+
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>
19+
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
20+
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
21+
</p>
22+
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
23+
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->
624

7-
## Features
25+
## Description
826

9-
Project inspired from [Nestjs-prisma-starter](https://github.com/fivethree-team/nestjs-prisma-starter) of [fivethree-team](https://github.com/fivethree-team)
27+
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
1028

11-
I create this repo to practice Graphql and to show how to make a clean architecture for a project Graphql with NestJS
29+
## Installation
1230

13-
Features of project:
14-
- GraphQL with [apollo-server-express](https://github.com/apollographql/apollo-server), solution [code first](https://docs.nestjs.com/graphql/quick-start#code-first) and using [GraphQL play ground](https://github.com/graphql/graphql-playground)
15-
- Using [PostgreQL](https://github.com/brianc/node-postgres) for database and [Prisma 2](https://github.com/prisma/prisma) as Object Relation Mapping (ORM)
16-
- [NestJS Authentication](https://docs.nestjs.com/security/authentication) with [Passport](https://github.com/jaredhanson/passport), [JWT](http://www.passportjs.org/packages/passport-jwt/) and [Bcrypt](https://github.com/kelektiv/node.bcrypt.js/)
17-
- Docker solution for PostgreSQL, PGAdmin, Prisma
18-
- Next generation Typescript
31+
```bash
32+
$ npm install
33+
```
1934

20-
## Getting started
35+
## Running the app
2136

22-
**Working in progress**
37+
```bash
38+
# development
39+
$ npm run start
2340

24-
---
41+
# watch mode
42+
$ npm run start:dev
43+
44+
# production mode
45+
$ npm run start:prod
46+
```
47+
48+
## Test
49+
50+
```bash
51+
# unit tests
52+
$ npm run test
53+
54+
# e2e tests
55+
$ npm run test:e2e
56+
57+
# test coverage
58+
$ npm run test:cov
59+
```
60+
61+
## Support
62+
63+
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
64+
65+
## Stay in touch
66+
67+
- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
68+
- Website - [https://nestjs.com](https://nestjs.com/)
69+
- Twitter - [@nestframework](https://twitter.com/nestframework)
70+
71+
## License
72+
73+
Nest is [MIT licensed](LICENSE).

jest.config.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
moduleFileExtensions: ['js', 'json', 'ts'],
4+
rootDir: 'src',
5+
testRegex: '.*\\.spec\\.ts$',
6+
transform: {
7+
'^.+\\.(t|j)s$': 'ts-jest',
8+
},
9+
collectCoverageFrom: ['**/*.(t|j)s'],
10+
coverageDirectory: '../coverage',
11+
testEnvironment: 'node',
12+
moduleDirectories: ['node_modules', 'src'],
13+
moduleNameMapper: {
14+
'@common/(.*)': '<rootDir>/common/$1',
15+
'@modules/(.*)': '<rootDir>/modules/$1',
16+
'@app/(.*)': '<rootDir>/app/$1',
17+
},
18+
clearMocks: true,
19+
};

nest-cli.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"collection": "@nestjs/schematics",
3+
"sourceRoot": "src"
4+
}

package.json

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
{
2+
"name": "graphql-simple-boilerplate",
3+
"version": "0.0.1",
4+
"description": "Example starter project with NestJS - GraphQL - Prisma",
5+
"author": "Tien Duy",
6+
"private": false,
7+
"license": "MIT",
8+
"keywords": [
9+
"NestJS", "GraphQL", "Prisma", "Boilerplate", "Starter", "Postgres", "TypeScript"
10+
],
11+
"scripts": {
12+
"prebuild": "rimraf dist",
13+
"build": "nest build",
14+
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
15+
"start": "nest start",
16+
"start:dev": "nest start --watch",
17+
"start:debug": "nest start --debug --watch",
18+
"start:prod": "node dist/main",
19+
"migrate:dev": "prisma migrate dev --preview-feature",
20+
"migrate:dev:create": "prisma migrate dev --create-only --preview-feature",
21+
"migrate:reset": "prisma migrate reset --preview-feature",
22+
"migrate:deploy": "npx prisma migrate deploy --preview-feature",
23+
"migrate:status": "npx prisma migrate status --preview-feature",
24+
"migrate:resolve": "npx prisma migrate resolve --preview-feature",
25+
"prisma:studio": "npx prisma studio",
26+
"prisma:generate": "npx prisma generate",
27+
"prisma:generate:watch": "npx prisma generate --watch",
28+
"start:db": "npm run migrate:up && npm run prisma:generate && npm run seed",
29+
"seed": "ts-node prisma/seed.ts",
30+
"postinstall": "npm run prisma:generate",
31+
"docker:migrate": "docker-compose -f docker-compose.migrate.yml up -d",
32+
"docker:seed": "docker exec -it nest-api npm run seed",
33+
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
34+
"test": "jest",
35+
"test:watch": "jest --watch",
36+
"test:cov": "jest --coverage",
37+
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
38+
"test:e2e": "jest --config ./test/jest-e2e.json"
39+
40+
},
41+
"dependencies": {
42+
"@nestjs/common": "^7.5.1",
43+
"@nestjs/config": "^0.6.2",
44+
"@nestjs/core": "^7.5.1",
45+
"@nestjs/graphql": "^7.9.8",
46+
"@nestjs/platform-express": "^7.5.1",
47+
"@nestjs/swagger": "^4.7.12",
48+
"@prisma/client": "^2.15.0",
49+
"apollo-server-express": "^2.19.2",
50+
"class-transformer": "^0.3.2",
51+
"class-validator": "^0.13.1",
52+
"graphql": "^15.5.0",
53+
"graphql-tools": "^7.0.2",
54+
"pg": "^8.5.1",
55+
"reflect-metadata": "^0.1.13",
56+
"rimraf": "^3.0.2",
57+
"rxjs": "^6.6.3",
58+
"swagger-ui-express": "^4.1.6"
59+
},
60+
"devDependencies": {
61+
"@nestjs/cli": "^7.5.1",
62+
"@nestjs/schematics": "^7.1.3",
63+
"@nestjs/testing": "^7.5.1",
64+
"@prisma/cli": "2.15.0",
65+
"@types/express": "^4.17.8",
66+
"@types/jest": "^26.0.15",
67+
"@types/node": "^14.14.6",
68+
"@types/supertest": "^2.0.10",
69+
"@typescript-eslint/eslint-plugin": "^4.6.1",
70+
"@typescript-eslint/parser": "^4.6.1",
71+
"dotenv": "^8.2.0",
72+
"eslint": "^7.12.1",
73+
"eslint-config-prettier": "7.1.0",
74+
"eslint-plugin-prettier": "^3.1.4",
75+
"jest": "^26.6.3",
76+
"prettier": "^2.1.2",
77+
"prisma-dbml-generator": "^0.4.0",
78+
"supertest": "^6.0.0",
79+
"ts-jest": "^26.4.3",
80+
"ts-loader": "^8.0.8",
81+
"ts-node": "^9.0.0",
82+
"tsconfig-paths": "^3.9.0",
83+
"typescript": "^4.0.5"
84+
}
85+
}

src/app/app.controller.spec.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Test, TestingModule } from '@nestjs/testing';
2+
import { AppController } from './app.controller';
3+
import { AppService } from './app.service';
4+
5+
describe('AppController', () => {
6+
let appController: AppController;
7+
8+
beforeEach(async () => {
9+
const app: TestingModule = await Test.createTestingModule({
10+
controllers: [AppController],
11+
providers: [AppService],
12+
}).compile();
13+
14+
appController = app.get<AppController>(AppController);
15+
});
16+
17+
describe('root', () => {
18+
it('should return "Hello World!"', () => {
19+
expect(appController.getHello()).toBe('Hello World!');
20+
});
21+
});
22+
});

0 commit comments

Comments
 (0)