Skip to content

Commit 2631956

Browse files
author
monica.lopez-gris
committed
add sample
1 parent fc722db commit 2631956

24 files changed

Lines changed: 9772 additions & 0 deletions

samples/graphql/.eslintrc.js

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

samples/graphql/.gitignore

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
2+
# Created by https://www.toptal.com/developers/gitignore/api/node,angular,visualstudiocode
3+
# Edit at https://www.toptal.com/developers/gitignore?templates=node,angular,visualstudiocode
4+
5+
### Angular ###
6+
## Angular ##
7+
# compiled output
8+
dist/
9+
tmp/
10+
app/**/*.js
11+
app/**/*.js.map
12+
13+
# dependencies
14+
node_modules/
15+
bower_components/
16+
17+
# IDEs and editors
18+
.idea/
19+
20+
# misc
21+
.sass-cache/
22+
connect.lock/
23+
coverage/
24+
libpeerconnection.log/
25+
npm-debug.log
26+
testem.log
27+
typings/
28+
29+
# e2e
30+
e2e/*.js
31+
e2e/*.map
32+
33+
# System Files
34+
.DS_Store/
35+
36+
### Node ###
37+
# Logs
38+
logs
39+
*.log
40+
npm-debug.log*
41+
yarn-debug.log*
42+
yarn-error.log*
43+
lerna-debug.log*
44+
45+
# Diagnostic reports (https://nodejs.org/api/report.html)
46+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
47+
48+
# Runtime data
49+
pids
50+
*.pid
51+
*.seed
52+
*.pid.lock
53+
54+
# Directory for instrumented libs generated by jscoverage/JSCover
55+
lib-cov
56+
57+
# Coverage directory used by tools like istanbul
58+
coverage
59+
*.lcov
60+
61+
# nyc test coverage
62+
.nyc_output
63+
64+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
65+
.grunt
66+
67+
# Bower dependency directory (https://bower.io/)
68+
bower_components
69+
70+
# node-waf configuration
71+
.lock-wscript
72+
73+
# Compiled binary addons (https://nodejs.org/api/addons.html)
74+
build/Release
75+
76+
# Dependency directories
77+
jspm_packages/
78+
79+
# TypeScript v1 declaration files
80+
81+
# TypeScript cache
82+
*.tsbuildinfo
83+
84+
# Optional npm cache directory
85+
.npm
86+
87+
# Optional eslint cache
88+
.eslintcache
89+
90+
# Microbundle cache
91+
.rpt2_cache/
92+
.rts2_cache_cjs/
93+
.rts2_cache_es/
94+
.rts2_cache_umd/
95+
96+
# Optional REPL history
97+
.node_repl_history
98+
99+
# Output of 'npm pack'
100+
*.tgz
101+
102+
# Yarn Integrity file
103+
.yarn-integrity
104+
105+
# dotenv environment variables file
106+
.env
107+
.env.test
108+
.env*.local
109+
110+
# parcel-bundler cache (https://parceljs.org/)
111+
.cache
112+
.parcel-cache
113+
114+
# Next.js build output
115+
.next
116+
117+
# Nuxt.js build / generate output
118+
.nuxt
119+
dist
120+
121+
# Gatsby files
122+
.cache/
123+
# Comment in the public line in if your project uses Gatsby and not Next.js
124+
# https://nextjs.org/blog/next-9-1#public-directory-support
125+
# public
126+
127+
# vuepress build output
128+
.vuepress/dist
129+
130+
# Serverless directories
131+
.serverless/
132+
133+
# FuseBox cache
134+
.fusebox/
135+
136+
# DynamoDB Local files
137+
.dynamodb/
138+
139+
# TernJS port file
140+
.tern-port
141+
142+
# Stores VSCode versions used for testing VSCode extensions
143+
.vscode-test
144+
145+
### VisualStudioCode ###
146+
.vscode/*
147+
!.vscode/tasks.json
148+
!.vscode/launch.json
149+
*.code-workspace
150+
151+
### VisualStudioCode Patch ###
152+
# Ignore all local history of files
153+
.history
154+
.ionide
155+
156+
# End of https://www.toptal.com/developers/gitignore/api/node,angular,visualstudiocode

samples/graphql/.prettierrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all",
4+
"semi": true,
5+
"printWidth": 120,
6+
"tabWidth": 2,
7+
"bracketSpacing": true,
8+
"arrowParens": "avoid",
9+
"endOfLine": "auto",
10+
"quoteProps": "consistent",
11+
"useTabs": false
12+
}

samples/graphql/README.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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>
4+
5+
[travis-image]: https://api.travis-ci.org/nestjs/nest.svg?branch=master
6+
[travis-url]: https://travis-ci.org/nestjs/nest
7+
[linux-image]: https://img.shields.io/travis/nestjs/nest/master.svg?label=linux
8+
[linux-url]: https://travis-ci.org/nestjs/nest
9+
10+
<p align="center">A progressive <a href="http://nodejs.org" target="blank">Node.js</a> framework for building efficient and scalable server-side applications, heavily inspired by <a href="https://angular.io" target="blank">Angular</a>.</p>
11+
<p align="center">
12+
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
13+
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
14+
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/dm/@nestjs/core.svg" alt="NPM Downloads" /></a>
15+
<a href="https://travis-ci.org/nestjs/nest"><img src="https://api.travis-ci.org/nestjs/nest.svg?branch=master" alt="Travis" /></a>
16+
<a href="https://travis-ci.org/nestjs/nest"><img src="https://img.shields.io/travis/nestjs/nest/master.svg?label=linux" alt="Linux" /></a>
17+
<a href="https://coveralls.io/github/nestjs/nest?branch=master"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#5" alt="Coverage" /></a>
18+
<a href="https://gitter.im/nestjs/nestjs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=body_badge"><img src="https://badges.gitter.im/nestjs/nestjs.svg" alt="Gitter" /></a>
19+
<a href="https://opencollective.com/nest#backer"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
20+
<a href="https://opencollective.com/nest#sponsor"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
21+
<a href="https://paypal.me/kamilmysliwiec"><img src="https://img.shields.io/badge/Donate-PayPal-dc3d53.svg"/></a>
22+
<a href="https://twitter.com/nestframework"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
23+
</p>
24+
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
25+
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->
26+
27+
## Description
28+
29+
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
30+
31+
## Installation
32+
33+
```bash
34+
$ npm install
35+
```
36+
37+
## Running the app
38+
39+
```bash
40+
# development
41+
$ npm run start
42+
43+
# watch mode
44+
$ npm run start:dev
45+
46+
# production mode
47+
$ npm run start:prod
48+
```
49+
50+
## Test
51+
52+
```bash
53+
# unit tests
54+
$ npm run test
55+
56+
# e2e tests
57+
$ npm run test:e2e
58+
59+
# test coverage
60+
$ npm run test:cov
61+
```
62+
63+
## Support
64+
65+
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).
66+
67+
## Stay in touch
68+
69+
- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
70+
- Website - [https://nestjs.com](https://nestjs.com/)
71+
- Twitter - [@nestframework](https://twitter.com/nestframework)
72+
73+
## License
74+
75+
Nest is [MIT licensed](LICENSE).

samples/graphql/nest-cli.json

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

samples/graphql/package.json

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{
2+
"name": "graphql",
3+
"version": "0.0.1",
4+
"description": "",
5+
"author": "",
6+
"private": true,
7+
"license": "UNLICENSED",
8+
"scripts": {
9+
"prebuild": "rimraf dist",
10+
"build": "nest build",
11+
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
12+
"start": "nest start",
13+
"start:dev": "nest start --watch",
14+
"start:debug": "nest start --debug --watch",
15+
"start:prod": "node dist/main",
16+
"lint": "eslint {src,apps,libs,test}/**/*.ts --fix",
17+
"test": "jest",
18+
"test:watch": "jest --watch",
19+
"test:cov": "jest --coverage",
20+
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
21+
"test:e2e": "jest --config ./test/jest-e2e.json"
22+
},
23+
"dependencies": {
24+
"@devon4node/common": "^2.0.0",
25+
"@nestjs/common": "^7.0.0",
26+
"@nestjs/core": "^7.0.0",
27+
"@nestjs/graphql": "^7.8.2",
28+
"@nestjs/mongoose": "^7.1.0",
29+
"@nestjs/platform-express": "^7.0.0",
30+
"apollo-server-express": "^2.19.0",
31+
"class-transformer": "^0.2.3",
32+
"class-validator": "^0.11.1",
33+
"graphql": "^15.4.0",
34+
"graphql-tools": "^7.0.1",
35+
"mongoose": "^5.10.15",
36+
"reflect-metadata": "^0.1.13",
37+
"rimraf": "^3.0.2",
38+
"rxjs": "^6.5.4",
39+
"winston": "^3.2.1"
40+
},
41+
"devDependencies": {
42+
"@nestjs/cli": "^7.0.0",
43+
"@nestjs/schematics": "^7.0.0",
44+
"@nestjs/testing": "^7.0.0",
45+
"@types/express": "^4.17.3",
46+
"@types/jest": "26.0.10",
47+
"@types/mongoose": "^5.10.0",
48+
"@types/node": "^13.9.1",
49+
"@types/supertest": "^2.0.8",
50+
"@typescript-eslint/eslint-plugin": "3.9.1",
51+
"@typescript-eslint/parser": "3.9.1",
52+
"eslint": "7.7.0",
53+
"eslint-config-prettier": "^6.10.0",
54+
"eslint-plugin-import": "^2.20.1",
55+
"eslint-plugin-prettier": "^3.1.2",
56+
"husky": "^4.2.3",
57+
"jest": "26.4.2",
58+
"prettier": "^1.19.1",
59+
"pretty-quick": "^2.0.1",
60+
"supertest": "^4.0.2",
61+
"ts-jest": "26.2.0",
62+
"ts-loader": "^6.2.1",
63+
"ts-node": "9.0.0",
64+
"tsconfig-paths": "^3.9.0",
65+
"typescript": "^3.7.4"
66+
},
67+
"jest": {
68+
"moduleFileExtensions": [
69+
"js",
70+
"json",
71+
"ts"
72+
],
73+
"rootDir": "src",
74+
"testRegex": ".spec.ts$",
75+
"transform": {
76+
"^.+\\.(t|j)s$": "ts-jest"
77+
},
78+
"coverageDirectory": "../coverage",
79+
"testEnvironment": "node"
80+
},
81+
"husky": {
82+
"hooks": {
83+
"pre-commit": "pretty-quick --staged && eslint --cache --fix"
84+
}
85+
}
86+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { Module } from '@nestjs/common';
2+
import { MongooseModule } from '@nestjs/mongoose';
3+
import { GraphQLModule } from '@nestjs/graphql';
4+
import { join } from 'path';
5+
import { TodoModule } from './todo/todo.module';
6+
7+
@Module({
8+
imports: [
9+
TodoModule,
10+
MongooseModule.forRoot('mongodb://localhost:27017'),
11+
GraphQLModule.forRoot({
12+
typePaths: ['./**/*.graphql'],
13+
definitions: {
14+
path: join(process.cwd(), 'src/app/graphql.ts'),
15+
outputAs: 'class',
16+
},
17+
}),
18+
],
19+
})
20+
export class AppModule {}

0 commit comments

Comments
 (0)