-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: update kerna workspaces and finish graphql services by count…
…ries
- Loading branch information
Showing
47 changed files
with
9,306 additions
and
199 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
node_modules/ | ||
node_modules/ | ||
yarn-error.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
{ | ||
"version": "1.0.0", | ||
"packages": [ | ||
"libs/*", | ||
"microservices/**" | ||
], | ||
"npmClient": "yarn" | ||
"npmClient": "yarn", | ||
"useWorkspaces": true | ||
} |
2 changes: 1 addition & 1 deletion
2
microservices/countries/core/src/infraestructure/database/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
microservices/countries/interfaces/console/src/commands/create/create.command.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
microservices/countries/interfaces/console/src/commands/create/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
microservices/countries/interfaces/console/src/commands/delete/delete.command.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
microservices/countries/interfaces/console/src/commands/delete/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
microservices/countries/interfaces/console/src/commands/find/find.command.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
microservices/countries/interfaces/console/src/commands/find/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
microservices/countries/interfaces/console/src/commands/list/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
microservices/countries/interfaces/console/src/commands/list/list.command.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
microservices/countries/interfaces/console/src/commands/update/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
microservices/countries/interfaces/console/src/commands/update/update.command.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 2 | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
max_line_length = off | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
node_modules/ | ||
reports/ | ||
lib/ | ||
.env | ||
cert/ | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"endOfLine": "auto", | ||
"semi": true, | ||
"singleQuote": true, | ||
"tabWidth": 2, | ||
"trailingComma": "es5" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 Luis Diego | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"name": "@micro/countries-graphql", | ||
"version": "1.0.0", | ||
"description": "Country GraphQL Interface", | ||
"author": { | ||
"name": "Luis Diego", | ||
"email": "[email protected]", | ||
"url": "http://github.com/ldiego73" | ||
}, | ||
"license": "MIT", | ||
"main": "lib/main.js", | ||
"types": "lib/main.d.ts", | ||
"files": [ | ||
"lib/" | ||
], | ||
"scripts": { | ||
"clean": "rimraf lib", | ||
"develop": "nest start --watch", | ||
"prebuild": "yarn clean", | ||
"build": "nest build" | ||
}, | ||
"dependencies": { | ||
"@micro/countries-config": "^1.0.0", | ||
"@micro/countries-core": "^1.0.0", | ||
"@micro/logger": "^1.0.0", | ||
"@nestjs/cli": "^7.1.5", | ||
"@nestjs/common": "^7.1.0", | ||
"@nestjs/core": "^7.1.0", | ||
"@nestjs/graphql": "^7.3.11", | ||
"@nestjs/platform-fastify": "^7.1.0", | ||
"apollo-server-fastify": "^2.13.1", | ||
"fastify-compress": "^2.0.1", | ||
"fastify-cors": "^3.0.3", | ||
"fastify-rate-limit": "^3.0.1", | ||
"graphql": "^15.0.0", | ||
"graphql-tools": "^6.0.1", | ||
"reflect-metadata": "^0.1.13", | ||
"rxjs": "^6.5.5" | ||
}, | ||
"devDependencies": { | ||
"@nestjs/cli": "^7.1.5", | ||
"@types/node": "^14.0.1", | ||
"fastify-helmet": "^3.0.2", | ||
"rimraf": "^3.0.2", | ||
"ts-loader": "^7.0.4", | ||
"ts-node": "^8.10.1", | ||
"typescript": "^3.8.3", | ||
"webpack": "^4.43.0", | ||
"webpack-cli": "^3.3.11", | ||
"webpack-node-externals": "^1.7.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './options'; |
17 changes: 17 additions & 0 deletions
17
microservices/countries/interfaces/graphql/src/core/options.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import { ServerOptionsAsSecureHttp } from 'fastify'; | ||
|
||
const readCert = (cert: string): Buffer => | ||
fs.readFileSync(path.join(process.cwd(), cert)); | ||
|
||
export const options = ( | ||
key: string, | ||
cert: string | ||
): ServerOptionsAsSecureHttp => ({ | ||
https: { | ||
allowHTTP1: true, | ||
key: readCert(key), | ||
cert: readCert(cert), | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { NestFactory } from '@nestjs/core'; | ||
import { | ||
FastifyAdapter, | ||
NestFastifyApplication, | ||
} from '@nestjs/platform-fastify'; | ||
import helmet from 'fastify-helmet'; | ||
import cors from 'fastify-cors'; | ||
import compression from 'fastify-compress'; | ||
import rateLimit from 'fastify-rate-limit'; | ||
|
||
import { readEnv } from '@micro/countries-config'; | ||
import { Logger } from '@micro/logger'; | ||
|
||
import { options } from './core'; | ||
import { AppModule } from './modules/app.module'; | ||
|
||
const env = readEnv(); | ||
const { key, cert } = env.server.https!; | ||
const log = Logger.create('Server'); | ||
|
||
async function bootstrap() { | ||
const app = await NestFactory.create<NestFastifyApplication>( | ||
AppModule, | ||
new FastifyAdapter(options(key, cert)) | ||
); | ||
|
||
app.register(helmet); | ||
app.register(cors); | ||
app.register(compression, { encodings: ['gzip', 'deflate'] }); | ||
app.register(rateLimit, { max: 100, timeWindow: '1 minute' }); | ||
|
||
await app.listen(3000); | ||
|
||
log.info(`Server listening at ${await app.getUrl()}`); | ||
} | ||
|
||
bootstrap(); |
16 changes: 16 additions & 0 deletions
16
microservices/countries/interfaces/graphql/src/models/country.input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Field, InputType } from '@nestjs/graphql'; | ||
|
||
@InputType() | ||
export class CountryInput { | ||
@Field() | ||
name!: string; | ||
|
||
@Field() | ||
iso!: string; | ||
|
||
@Field() | ||
currency!: string; | ||
|
||
@Field() | ||
status!: boolean; | ||
} |
16 changes: 16 additions & 0 deletions
16
microservices/countries/interfaces/graphql/src/models/country.model.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Field, ObjectType } from '@nestjs/graphql'; | ||
|
||
@ObjectType() | ||
export class Country { | ||
@Field() | ||
name!: string; | ||
|
||
@Field() | ||
iso!: string; | ||
|
||
@Field() | ||
currency!: string; | ||
|
||
@Field() | ||
status!: boolean; | ||
} |
2 changes: 2 additions & 0 deletions
2
microservices/countries/interfaces/graphql/src/models/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './country.input'; | ||
export * from './country.model'; |
27 changes: 27 additions & 0 deletions
27
microservices/countries/interfaces/graphql/src/modules/app.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { GraphQLModule } from '@nestjs/graphql'; | ||
import path from 'path'; | ||
|
||
import { ListModule } from './list/list.module'; | ||
import { FindModule } from './find/find.module'; | ||
import { CreateModule } from './create/create.module'; | ||
import { DeleteModule } from './delete/delete.module'; | ||
import { UpdateModule } from './update/create.module'; | ||
|
||
const modules = [ | ||
ListModule, | ||
FindModule, | ||
CreateModule, | ||
DeleteModule, | ||
UpdateModule, | ||
]; | ||
|
||
@Module({ | ||
imports: [ | ||
...modules, | ||
GraphQLModule.forRoot({ | ||
autoSchemaFile: path.join(process.cwd(), 'src/schema.gql'), | ||
}), | ||
], | ||
}) | ||
export class AppModule {} |
8 changes: 8 additions & 0 deletions
8
microservices/countries/interfaces/graphql/src/modules/create/create.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { CreateResolver } from './create.resolver'; | ||
import { CreateService } from './create.service'; | ||
|
||
@Module({ | ||
providers: [CreateResolver, CreateService], | ||
}) | ||
export class CreateModule {} |
13 changes: 13 additions & 0 deletions
13
microservices/countries/interfaces/graphql/src/modules/create/create.resolver.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Args, Mutation, Resolver } from '@nestjs/graphql'; | ||
import { CreateService } from './create.service'; | ||
import { CountryInput } from '../../models'; | ||
|
||
@Resolver() | ||
export class CreateResolver { | ||
constructor(private readonly service: CreateService) {} | ||
|
||
@Mutation(returns => Boolean) | ||
async create(@Args('input') input: CountryInput) { | ||
return await this.service.execute(input); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
microservices/countries/interfaces/graphql/src/modules/create/create.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { | ||
CreateCountryUseCase, | ||
createCountryUseCase, | ||
} from '@micro/countries-core/lib/application/use-cases'; | ||
import { CountryDto } from '@micro/countries-core/lib/application/dtos'; | ||
import { CountryInput } from '../../models'; | ||
|
||
@Injectable() | ||
export class CreateService { | ||
private readonly useCase: CreateCountryUseCase; | ||
|
||
constructor() { | ||
this.useCase = createCountryUseCase; | ||
} | ||
|
||
async execute(country: CountryInput): Promise<any> {; | ||
const dto = country as CountryDto; | ||
const result = await this.useCase.execute(dto); | ||
|
||
if (result.isFailure()) { | ||
throw result.error.message; | ||
} | ||
|
||
return true; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
microservices/countries/interfaces/graphql/src/modules/delete/delete.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { DeleteResolver } from './delete.resolver'; | ||
import { DeleteService } from './delete.service'; | ||
|
||
@Module({ | ||
providers: [DeleteResolver, DeleteService], | ||
}) | ||
export class DeleteModule {} |
12 changes: 12 additions & 0 deletions
12
microservices/countries/interfaces/graphql/src/modules/delete/delete.resolver.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Args, Mutation, Resolver } from '@nestjs/graphql'; | ||
import { DeleteService } from './delete.service'; | ||
|
||
@Resolver() | ||
export class DeleteResolver { | ||
constructor(private readonly service: DeleteService) {} | ||
|
||
@Mutation(returns => Boolean) | ||
async delete(@Args('iso') iso: string) { | ||
return await this.service.execute(iso); | ||
} | ||
} |
Oops, something went wrong.