diff --git a/.prettierrc b/.prettierrc index b911b6a9474..cabb5383336 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,4 +1,6 @@ { "printWidth": 140, - "bracketSpacing": false + "bracketSpacing": false, + "trailingComma": "none", + "arrowParens": "always" } diff --git a/packages/ajv/src/pipes/AjvErrorFormatterPipe.ts b/packages/ajv/src/pipes/AjvErrorFormatterPipe.ts index a298153cb3a..35df00fc538 100644 --- a/packages/ajv/src/pipes/AjvErrorFormatterPipe.ts +++ b/packages/ajv/src/pipes/AjvErrorFormatterPipe.ts @@ -17,7 +17,7 @@ function defaultFormatter(error: AjvErrorObject, index: string | number) { index !== undefined && error.modelName && isNaN(+index) && ".", `${error.modelName || ""}`, error.dataPath, - ` ${error.message}. Given value: ${value}`, + ` ${error.message}. Given value: ${value}` ] // @ts-ignore .filter(Boolean) diff --git a/packages/ajv/src/pipes/AjvValidationPipe.spec.ts b/packages/ajv/src/pipes/AjvValidationPipe.spec.ts index 297487ad2dd..da565b0db0a 100644 --- a/packages/ajv/src/pipes/AjvValidationPipe.spec.ts +++ b/packages/ajv/src/pipes/AjvValidationPipe.spec.ts @@ -9,7 +9,7 @@ import { QueryParams, Required, UseParam, - ValidationError, + ValidationError } from "@tsed/common"; import {expect} from "chai"; import {AjvValidationPipe} from "./AjvValidationPipe"; @@ -32,8 +32,8 @@ describe("AjvValidationPipe", () => { beforeEach(() => PlatformTest.create({ ajv: { - verbose: true, - }, + verbose: true + } }) ); afterEach(() => PlatformTest.reset()); @@ -66,14 +66,14 @@ describe("AjvValidationPipe", () => { keyword: "type", message: "should be object", params: { - type: "object", + type: "object" }, parentSchema: { - type: "object", + type: "object" }, schema: "object", - schemaPath: "#/type", - }, + schemaPath: "#/type" + } ]); }); }); @@ -121,7 +121,7 @@ describe("AjvValidationPipe", () => { } const value = { - id: "hello", + id: "hello" }; const result = await validate(value, ParamMetadata.get(Ctrl, "get", 0)); @@ -153,25 +153,25 @@ describe("AjvValidationPipe", () => { message: "should have required property 'id'", modelName: "Model", params: { - missingProperty: "id", + missingProperty: "id" }, parentSchema: { definitions: {}, properties: { id: { - type: "string", - }, + type: "string" + } }, required: ["id"], - type: "object", + type: "object" }, schema: { id: { - type: "string", - }, + type: "string" + } }, - schemaPath: "#/required", - }, + schemaPath: "#/required" + } ]); }); it("should throw an error (deep property)", async () => { @@ -194,7 +194,7 @@ describe("AjvValidationPipe", () => { const value: any = { id: "id", - user: {}, + user: {} }; const error = await validate(value, ParamMetadata.get(Ctrl, "get", 0)); @@ -218,8 +218,8 @@ describe("AjvValidationPipe", () => { const value = [ { - id: "hello", - }, + id: "hello" + } ]; const result = await validate(value, ParamMetadata.get(Ctrl, "get", 0)); @@ -265,8 +265,8 @@ describe("AjvValidationPipe", () => { const value: any = [ { id: "id", - user: {}, - }, + user: {} + } ]; const error = await validate(value, ParamMetadata.get(Ctrl, "get", 0)); @@ -290,8 +290,8 @@ describe("AjvValidationPipe", () => { const value = { key1: { - id: "hello", - }, + id: "hello" + } }; const result = await validate(value, ParamMetadata.get(Ctrl, "get", 0)); @@ -337,8 +337,8 @@ describe("AjvValidationPipe", () => { const value: any = { key1: { id: "id", - user: {}, - }, + user: {} + } }; const error = await validate(value, ParamMetadata.get(Ctrl, "get", 0)); diff --git a/packages/ajv/src/pipes/AjvValidationPipe.ts b/packages/ajv/src/pipes/AjvValidationPipe.ts index 549615b6870..14a254ef332 100644 --- a/packages/ajv/src/pipes/AjvValidationPipe.ts +++ b/packages/ajv/src/pipes/AjvValidationPipe.ts @@ -66,7 +66,7 @@ export class AjvValidationPipe extends ValidationPipe implements IPipe { const options = { ignoreCallback: (obj: any, type: any) => type === Date, checkRequiredValue: false, - additionalProperties: metadata.paramType === ParamTypes.QUERY ? "ignore" : undefined, + additionalProperties: metadata.paramType === ParamTypes.QUERY ? "ignore" : undefined }; if (metadata.isCollection) { diff --git a/packages/ajv/src/services/Ajv.spec.ts b/packages/ajv/src/services/Ajv.spec.ts index c4f0a52bdfe..11202faea78 100644 --- a/packages/ajv/src/services/Ajv.spec.ts +++ b/packages/ajv/src/services/Ajv.spec.ts @@ -13,7 +13,7 @@ describe("Ajv", () => { expect( ajv.validate( { - type: "object", + type: "object" }, {} ) @@ -21,7 +21,7 @@ describe("Ajv", () => { ajv.validate( { - type: "object", + type: "object" }, [] ); @@ -32,10 +32,10 @@ describe("Ajv", () => { keyword: "type", message: "should be object", params: { - type: "object", + type: "object" }, - schemaPath: "#/type", - }, + schemaPath: "#/type" + } ]); }); }); diff --git a/packages/ajv/src/services/Ajv.ts b/packages/ajv/src/services/Ajv.ts index 5150639e5a1..f2706c863c4 100644 --- a/packages/ajv/src/services/Ajv.ts +++ b/packages/ajv/src/services/Ajv.ts @@ -16,7 +16,7 @@ registerProvider({ return new Ajv({ verbose: false, ...props, - ...options, + ...options }); - }, + } }); diff --git a/packages/common/src/config/services/ServerSettingsService.spec.ts b/packages/common/src/config/services/ServerSettingsService.spec.ts index 6f0cb909490..bebb0e340ad 100644 --- a/packages/common/src/config/services/ServerSettingsService.spec.ts +++ b/packages/common/src/config/services/ServerSettingsService.spec.ts @@ -21,23 +21,23 @@ describe("ServerSettingsService", () => { version: "1.0.0", uploadDir: "${rootDir}/uploads", scopes: { - [ProviderType.CONTROLLER]: ProviderScope.SINGLETON, + [ProviderType.CONTROLLER]: ProviderScope.SINGLETON }, logger: { debug: false, level: "info", logRequest: true, - jsonIndentation: process.env.NODE_ENV === Env.PROD ? 0 : 2, + jsonIndentation: process.env.NODE_ENV === Env.PROD ? 0 : 2 }, errors: { - headerName: "errors", + headerName: "errors" }, mount: { - "/rest": "${rootDir}/controllers/**/*.ts", + "/rest": "${rootDir}/controllers/**/*.ts" }, exclude: ["**/*.spec.ts", "**/*.spec.js"], componentsScan: ["${rootDir}/controllers/**/*.ts", "${rootDir}/services/**/*.ts", "${rootDir}/converters/**/*.ts"], - controllerScope: ProviderScope.SINGLETON, + controllerScope: ProviderScope.SINGLETON }).forEach(([key, value]) => { settings[key] = value; }); @@ -89,14 +89,14 @@ describe("ServerSettingsService", () => { it("should return httpsPort", () => { expect(settings.getHttpsPort()).to.deep.equal({ address: "address", - port: 8080, + port: 8080 }); }); it("should return httpPort", () => { expect(settings.getHttpPort()).to.deep.equal({ address: "address", - port: 8081, + port: 8081 }); }); @@ -180,14 +180,14 @@ describe("ServerSettingsService", () => { it("should return address and port from a concatened address and port", () => { expect((ServerSettingsService as any).buildAddressAndPort("0.0.0.0:9000")).to.deep.eq({ address: "0.0.0.0", - port: 9000, + port: 9000 }); }); it("should return address and port from a port number", () => { expect((ServerSettingsService as any).buildAddressAndPort(9000)).to.deep.eq({ address: "0.0.0.0", - port: 9000, + port: 9000 }); }); }); @@ -216,26 +216,26 @@ describe("ServerSettingsService", () => { const store = new Storage(); const result = settings.resolve({ path: "${rootDir}", - storage: store, + storage: store }); expect(result).to.deep.eq({ path: process.cwd(), - storage: new Storage(), + storage: new Storage() }); }); it("should replace rootDir", () => { expect(settings.resolve({other: null, resolve: "${rootDir}"})).to.deep.eq({ other: null, - resolve: process.cwd(), + resolve: process.cwd() }); }); it("should replace rootDir", () => { expect(settings.resolve({other: 808, resolve: "${rootDir}"})).to.deep.eq({ other: 808, - resolve: process.cwd(), + resolve: process.cwd() }); }); }); @@ -262,7 +262,7 @@ describe("ServerSettingsService", () => { Sinon.stub($log.appenders, "set"); settings.logger = { - format: "format", + format: "format" }; }); @@ -277,8 +277,8 @@ describe("ServerSettingsService", () => { levels: ["info", "debug"], layout: { type: "pattern", - pattern: "format", - }, + pattern: "format" + } }); expect($log.appenders.set).to.have.been.calledWithExactly("stderr", { @@ -286,8 +286,8 @@ describe("ServerSettingsService", () => { type: "stderr", layout: { type: "pattern", - pattern: "format", - }, + pattern: "format" + } }); }); }); diff --git a/packages/common/src/config/services/ServerSettingsService.ts b/packages/common/src/config/services/ServerSettingsService.ts index 0780c4d8ed5..7fb61875978 100644 --- a/packages/common/src/config/services/ServerSettingsService.ts +++ b/packages/common/src/config/services/ServerSettingsService.ts @@ -12,7 +12,7 @@ const rootDir = process.cwd(); */ @Injectable({ scope: ProviderScope.SINGLETON, - global: true, + global: true }) export class ServerSettingsService extends DIConfiguration { constructor() { @@ -24,27 +24,27 @@ export class ServerSettingsService extends DIConfiguration { version: "1.0.0", uploadDir: "${rootDir}/uploads", scopes: { - [ProviderType.CONTROLLER]: ProviderScope.SINGLETON, + [ProviderType.CONTROLLER]: ProviderScope.SINGLETON }, logger: { debug: false, level: "info", logRequest: true, - jsonIndentation: process.env.NODE_ENV === Env.PROD ? 0 : 2, + jsonIndentation: process.env.NODE_ENV === Env.PROD ? 0 : 2 }, errors: { - headerName: "errors", + headerName: "errors" }, mount: { - "/rest": "${rootDir}/controllers/**/*.ts", + "/rest": "${rootDir}/controllers/**/*.ts" }, exclude: ["**/*.spec.ts", "**/*.spec.js"], componentsScan: [ "${rootDir}/mvc/**/*.ts", "${rootDir}/services/**/*.ts", "${rootDir}/middlewares/**/*.ts", - "${rootDir}/converters/**/*.ts", - ], + "${rootDir}/converters/**/*.ts" + ] }); } @@ -209,8 +209,8 @@ export class ServerSettingsService extends DIConfiguration { levels: ["info", "debug"], layout: { type: "pattern", - pattern: logger.format, - }, + pattern: logger.format + } }); $log.appenders.set("stderr", { @@ -218,8 +218,8 @@ export class ServerSettingsService extends DIConfiguration { type: "stderr", layout: { type: "pattern", - pattern: logger.format, - }, + pattern: logger.format + } }); } } diff --git a/packages/common/src/converters/ConverterModule.ts b/packages/common/src/converters/ConverterModule.ts index 68ca403e58a..32d37874c64 100644 --- a/packages/common/src/converters/ConverterModule.ts +++ b/packages/common/src/converters/ConverterModule.ts @@ -2,6 +2,6 @@ import {Module} from "@tsed/di"; import {ConverterService} from "./services/ConverterService"; @Module({ - imports: [ConverterService], + imports: [ConverterService] }) export class ConverterModule {} diff --git a/packages/common/src/converters/decorators/converter.ts b/packages/common/src/converters/decorators/converter.ts index 775d606e4ba..21c82865d24 100644 --- a/packages/common/src/converters/decorators/converter.ts +++ b/packages/common/src/converters/decorators/converter.ts @@ -19,7 +19,7 @@ export function Converter(...classes: any[]): Function { registerConverter({ provide: target, - type: "converter", + type: "converter" }); classes.forEach((clazz) => Metadata.set(CONVERTER, target, clazz)); diff --git a/packages/common/src/converters/errors/RequiredPropertyError.ts b/packages/common/src/converters/errors/RequiredPropertyError.ts index cac2ff27a82..07589f8e86e 100644 --- a/packages/common/src/converters/errors/RequiredPropertyError.ts +++ b/packages/common/src/converters/errors/RequiredPropertyError.ts @@ -15,10 +15,10 @@ export class RequiredPropertyError extends ValidationError { message: `should have required property '${String(propertyName)}'`, modelName: nameOf(target), params: { - missingProperty: propertyName, + missingProperty: propertyName }, - schemaPath: "#/required", - }, + schemaPath: "#/required" + } ]); } } diff --git a/packages/common/src/converters/errors/UnknownPropertyError.ts b/packages/common/src/converters/errors/UnknownPropertyError.ts index 57ad2905ad7..63abdfe5df4 100644 --- a/packages/common/src/converters/errors/UnknownPropertyError.ts +++ b/packages/common/src/converters/errors/UnknownPropertyError.ts @@ -15,10 +15,10 @@ export class UnknownPropertyError extends ValidationError { message: `should not have property '${String(propertyName)}'`, modelName: nameOf(target), params: { - missingProperty: propertyName, + missingProperty: propertyName }, - schemaPath: "#/unknown", - }, + schemaPath: "#/unknown" + } ]); } } diff --git a/packages/common/src/converters/registries/ConverterRegistries.ts b/packages/common/src/converters/registries/ConverterRegistries.ts index 676aff0f754..d23f77fce5e 100644 --- a/packages/common/src/converters/registries/ConverterRegistries.ts +++ b/packages/common/src/converters/registries/ConverterRegistries.ts @@ -6,7 +6,7 @@ import {Provider, ProviderType, TypedProvidersRegistry, GlobalProviders} from "@ */ // tslint:disable-next-line: variable-name export const ConverterRegistry: TypedProvidersRegistry = GlobalProviders.createRegistry(ProviderType.CONVERTER, Provider, { - injectable: true, + injectable: true }); /** * Add a new converter in the `ProviderRegistry`. This converter will be built when `InjectorService` will be loaded. diff --git a/packages/common/src/converters/services/ConverterService.spec.ts b/packages/common/src/converters/services/ConverterService.spec.ts index 7bca0761134..dfbc44392d0 100644 --- a/packages/common/src/converters/services/ConverterService.spec.ts +++ b/packages/common/src/converters/services/ConverterService.spec.ts @@ -98,7 +98,7 @@ describe("ConverterService", () => { const foo = converterService.deserialize( { test: 1, - foo: "test", + foo: "test" }, JsonFoo as any ); @@ -121,23 +121,23 @@ describe("ConverterService", () => { dateStart: new Date().toISOString(), object: {test: "2ez"}, foo: { - test: "2", + test: "2" }, foos: [ { - test: "1", + test: "1" }, { - test: "2", - }, + test: "2" + } ], foos2: { - test: "15", + test: "15" }, theMap: { - f1: {test: "1"}, + f1: {test: "1"} }, - theSet: [{test: "13"}, {test: "1re"}], + theSet: [{test: "13"}, {test: "1re"}] }, JsonFoo2 ); @@ -198,7 +198,7 @@ describe("ConverterService", () => { // GIVEN const converterService = await invokeConverterService({ validationModelStrict: true, - configuration, + configuration }); // WHEN @@ -208,7 +208,7 @@ describe("ConverterService", () => { { test: 1, foo: "test", - notPropertyAllowed: "tst", + notPropertyAllowed: "tst" }, JsonFoo4 as any ); @@ -225,7 +225,7 @@ describe("ConverterService", () => { // GIVEN const converterService = await invokeConverterService({ validationModelStrict: false, - configuration, + configuration }); // WHEN @@ -233,7 +233,7 @@ describe("ConverterService", () => { { test: 1, foo: "test", - notPropertyAllowed: "tst", + notPropertyAllowed: "tst" }, JsonFoo5 as any ); @@ -242,7 +242,7 @@ describe("ConverterService", () => { expect(result).to.deep.equal({ foo: "test", notPropertyAllowed: "tst", - test: 1, + test: 1 }); }) ); @@ -255,7 +255,7 @@ describe("ConverterService", () => { // GIVEN const converterService = await invokeConverterService({ additionalProperties: "error", - configuration, + configuration }); // WHEN @@ -265,7 +265,7 @@ describe("ConverterService", () => { { test: 1, foo: "test", - notPropertyAllowed: "tst", + notPropertyAllowed: "tst" }, JsonFoo4 as any ); @@ -282,7 +282,7 @@ describe("ConverterService", () => { // GIVEN const converterService = await invokeConverterService({ additionalProperties: "ignore", - configuration, + configuration }); // WHEN @@ -290,14 +290,14 @@ describe("ConverterService", () => { { test: 1, foo: "test", - notPropertyAllowed: "tst", + notPropertyAllowed: "tst" }, JsonFoo5 as any ); // THEN expect(result).to.be.instanceof(JsonFoo5); expect(result).to.deep.equal({ - test: 1, + test: 1 }); }) ); @@ -307,7 +307,7 @@ describe("ConverterService", () => { // GIVEN const converterService = await invokeConverterService({ additionalProperties: "accept", - configuration, + configuration }); // WHEN @@ -315,7 +315,7 @@ describe("ConverterService", () => { { test: 1, foo: "test", - notPropertyAllowed: "tst", + notPropertyAllowed: "tst" }, JsonFoo5 as any ); @@ -324,7 +324,7 @@ describe("ConverterService", () => { expect(result).to.deep.equal({ foo: "test", notPropertyAllowed: "tst", - test: 1, + test: 1 }); }) ); @@ -340,7 +340,7 @@ describe("ConverterService", () => { try { converterService.deserialize( { - test: undefined, + test: undefined }, JsonFoo2 ); @@ -360,7 +360,7 @@ describe("ConverterService", () => { try { converterService.deserialize( { - test: null, + test: null }, JsonFoo2 ); @@ -380,7 +380,7 @@ describe("ConverterService", () => { try { converterService.deserialize( { - test: "", + test: "" }, JsonFoo2 ); @@ -587,7 +587,7 @@ describe("ConverterService", () => { PlatformTest.inject([Configuration], async (configuration: Configuration) => { const converterService = await invokeConverterService({ validationModelStrict: true, - configuration, + configuration }); // @ts-ignore @@ -600,7 +600,7 @@ describe("ConverterService", () => { PlatformTest.inject([Configuration], async (configuration: Configuration) => { const converterService = await invokeConverterService({ validationModelStrict: true, - configuration, + configuration }); // @ts-ignore @@ -613,7 +613,7 @@ describe("ConverterService", () => { PlatformTest.inject([Configuration], async (configuration: Configuration) => { const converterService = await invokeConverterService({ validationModelStrict: false, - configuration, + configuration }); // @ts-ignore @@ -626,7 +626,7 @@ describe("ConverterService", () => { PlatformTest.inject([Configuration], async (configuration: Configuration) => { const converterService = await invokeConverterService({ additionalProperties: "error", - configuration, + configuration }); // @ts-ignore @@ -639,7 +639,7 @@ describe("ConverterService", () => { PlatformTest.inject([Configuration], async (configuration: Configuration) => { const converterService = await invokeConverterService({ additionalProperties: "accept", - configuration, + configuration }); // @ts-ignore @@ -652,7 +652,7 @@ describe("ConverterService", () => { PlatformTest.inject([Configuration], async (configuration: Configuration) => { const converterService = await invokeConverterService({ additionalProperties: "ignore", - configuration, + configuration }); // @ts-ignore @@ -668,7 +668,7 @@ describe("ConverterService", () => { const converterService = await invokeConverterService({ additionalProperties: "accept", - configuration, + configuration }); // @ts-ignore @@ -684,7 +684,7 @@ describe("ConverterService", () => { const converterService = await invokeConverterService({ additionalProperties: "error", - configuration, + configuration }); // @ts-ignore @@ -707,13 +707,13 @@ async function invokeConverterService({validationModelStrict = true, additionalP if (key === "converter") { return { - additionalProperties, + additionalProperties }; } return configuration.get(key); - }, - }, - }, + } + } + } ]); } diff --git a/packages/common/src/converters/services/ConverterService.ts b/packages/common/src/converters/services/ConverterService.ts index d50caf90638..b8f97ceaab5 100644 --- a/packages/common/src/converters/services/ConverterService.ts +++ b/packages/common/src/converters/services/ConverterService.ts @@ -10,7 +10,7 @@ import {UnknownPropertyError} from "../errors/UnknownPropertyError"; import {IConverter, IConverterOptions, IDeserializer, ISerializer} from "../interfaces/index"; @Injectable({ - imports: [ArrayConverter, DateConverter, MapConverter, PrimitiveConverter, SetConverter, SymbolConverter], + imports: [ArrayConverter, DateConverter, MapConverter, PrimitiveConverter, SetConverter, SymbolConverter] }) export class ConverterService { private converterSettings: IConverterSettings; @@ -112,7 +112,7 @@ export class ConverterService { propertyValue = this.serialize(propertyValue, { checkRequiredValue, withIgnoredProps, - type: propertyMetadata!.type, + type: propertyMetadata!.type }); if (typeof propertyMetadata!.onSerialize === "function") { diff --git a/packages/common/src/jsonschema/class/JsonSchema.spec.ts b/packages/common/src/jsonschema/class/JsonSchema.spec.ts index 1e4837dd068..8f4f2a32e4f 100644 --- a/packages/common/src/jsonschema/class/JsonSchema.spec.ts +++ b/packages/common/src/jsonschema/class/JsonSchema.spec.ts @@ -13,8 +13,8 @@ describe("JsonSchema", () => { expect(schema.toJSON()).to.deep.eq({ type: "array", items: { - type: "string", - }, + type: "string" + } }); }); }); @@ -27,8 +27,8 @@ describe("JsonSchema", () => { expect(schema.toJSON()).to.deep.eq({ type: "array", items: { - type: "object", - }, + type: "object" + } }); }); }); @@ -38,7 +38,7 @@ describe("JsonSchema", () => { const schema = new JsonSchema(); schema.type = ["number", "string"]; expect(schema.toJSON()).to.deep.eq({ - type: ["number", "string"], + type: ["number", "string"] }); }); }); @@ -51,8 +51,8 @@ describe("JsonSchema", () => { expect(schema.toJSON()).to.deep.eq({ type: "array", items: { - type: ["number", "string"], - }, + type: ["number", "string"] + } }); }); }); @@ -66,8 +66,8 @@ describe("JsonSchema", () => { expect(schema.toJSON()).to.deep.eq({ type: "array", items: { - type: ["number", "string"], - }, + type: ["number", "string"] + } }); }); }); @@ -85,8 +85,8 @@ describe("JsonSchema", () => { type: "array", items: { type: ["number", "string"], - enum: ["1", "2"], - }, + enum: ["1", "2"] + } }); }); }); @@ -114,8 +114,8 @@ describe("JsonSchema", () => { type: "array", items: { enum: ["1", "2"], - type: "string", - }, + type: "string" + } }); }); }); @@ -129,8 +129,8 @@ describe("JsonSchema", () => { expect(schema.toJSON()).to.deep.eq({ additionalProperties: { enum: ["1", "2"], - type: "string", - }, + type: "string" + } }); }); }); diff --git a/packages/common/src/jsonschema/class/JsonSchema.ts b/packages/common/src/jsonschema/class/JsonSchema.ts index ddcdb101643..dc7898470f4 100644 --- a/packages/common/src/jsonschema/class/JsonSchema.ts +++ b/packages/common/src/jsonschema/class/JsonSchema.ts @@ -126,7 +126,7 @@ export class JsonSchema implements JSONSchema6 { schema.mapValue(propertyKey, value); return true; - }, + } } as any); } diff --git a/packages/common/src/jsonschema/decorators/additionalProperties.spec.ts b/packages/common/src/jsonschema/decorators/additionalProperties.spec.ts index 838085564a1..be876de1e34 100644 --- a/packages/common/src/jsonschema/decorators/additionalProperties.spec.ts +++ b/packages/common/src/jsonschema/decorators/additionalProperties.spec.ts @@ -13,7 +13,7 @@ describe("@AdditionalProperties", () => { expect(schema).to.deep.equal({ additionalProperties: true, - definitions: {}, + definitions: {} }); }); }); diff --git a/packages/common/src/jsonschema/decorators/any.spec.ts b/packages/common/src/jsonschema/decorators/any.spec.ts index f7efa7c1cf5..474d379d308 100644 --- a/packages/common/src/jsonschema/decorators/any.spec.ts +++ b/packages/common/src/jsonschema/decorators/any.spec.ts @@ -15,10 +15,10 @@ describe("Any", () => { definitions: {}, properties: { prop: { - type: ["integer", "number", "string", "boolean", "array", "object", "null"], - }, + type: ["integer", "number", "string", "boolean", "array", "object", "null"] + } }, - type: "object", + type: "object" }); }); it("should declare any prop (uniq type)", () => { @@ -33,10 +33,10 @@ describe("Any", () => { definitions: {}, properties: { prop: { - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }); }); it("should declare any prop (with list)", () => { @@ -51,10 +51,10 @@ describe("Any", () => { definitions: {}, properties: { num: { - type: ["string", "number", "boolean", "null"], - }, + type: ["string", "number", "boolean", "null"] + } }, - type: "object", + type: "object" }); }); it("should declare any prop (with string, list)", () => { @@ -69,10 +69,10 @@ describe("Any", () => { definitions: {}, properties: { num: { - type: ["string", "null"], - }, + type: ["string", "null"] + } }, - type: "object", + type: "object" }); }); }); diff --git a/packages/common/src/jsonschema/decorators/description.spec.ts b/packages/common/src/jsonschema/decorators/description.spec.ts index 817c0d9e7ed..75a4e2c0541 100644 --- a/packages/common/src/jsonschema/decorators/description.spec.ts +++ b/packages/common/src/jsonschema/decorators/description.spec.ts @@ -15,10 +15,10 @@ describe("Description", () => { properties: { prop: { type: "string", - description: "Description", - }, + description: "Description" + } }, - type: "object", + type: "object" }); }); }); diff --git a/packages/common/src/jsonschema/decorators/enum.spec.ts b/packages/common/src/jsonschema/decorators/enum.spec.ts index d913768c996..33e9b0a903d 100644 --- a/packages/common/src/jsonschema/decorators/enum.spec.ts +++ b/packages/common/src/jsonschema/decorators/enum.spec.ts @@ -18,7 +18,7 @@ describe("Enum", () => { describe("when is a typescript enum (string)", () => { enum SomeEnum { ENUM_1 = "enum1", - ENUM_2 = "enum2", + ENUM_2 = "enum2" } it("should store data", () => { @@ -38,7 +38,7 @@ describe("Enum", () => { describe("when is a typescript enum (index)", () => { enum SomeEnum { ENUM_1, - ENUM_2, + ENUM_2 } it("should store data", () => { @@ -58,7 +58,7 @@ describe("Enum", () => { enum SomeEnum { ENUM_1, ENUM_2 = "test", - ENUM_3 = "test2", + ENUM_3 = "test2" } it("should store data", () => { diff --git a/packages/common/src/jsonschema/decorators/example.spec.ts b/packages/common/src/jsonschema/decorators/example.spec.ts index b55d8ae94c5..c090187b9c6 100644 --- a/packages/common/src/jsonschema/decorators/example.spec.ts +++ b/packages/common/src/jsonschema/decorators/example.spec.ts @@ -17,10 +17,10 @@ describe("@Example", () => { properties: { method: { examples: ["Examples"], - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }); }); it("should declare description on property (with obj)", () => { @@ -38,13 +38,13 @@ describe("@Example", () => { method: { examples: [ { - id: "id", - }, + id: "id" + } ], - type: "object", - }, + type: "object" + } }, - type: "object", + type: "object" }); }); it("should declare description on property (with array)", () => { @@ -63,17 +63,17 @@ describe("@Example", () => { examples: [ [ { - id: "id", - }, - ], + id: "id" + } + ] ], items: { - type: "object", + type: "object" }, - type: "array", - }, + type: "array" + } }, - type: "object", + type: "object" }); }); it("should declare description on property (with two params on class)", () => { @@ -89,14 +89,14 @@ describe("@Example", () => { expect(getJsonSchema(Model)).to.deep.equal({ definitions: {}, example: { - method: "description", + method: "description" }, properties: { method: { - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }); }); }); diff --git a/packages/common/src/jsonschema/decorators/example.ts b/packages/common/src/jsonschema/decorators/example.ts index e45697a78a2..1db64716d9c 100644 --- a/packages/common/src/jsonschema/decorators/example.ts +++ b/packages/common/src/jsonschema/decorators/example.ts @@ -26,7 +26,7 @@ export function Example(...args: any[]): Function { case DecoratorTypes.PROP: case DecoratorTypes.METHOD: return Schema({ - examples: isArray(name) ? [name] : [].concat(name), + examples: isArray(name) ? [name] : [].concat(name) })(...args); } }; diff --git a/packages/common/src/jsonschema/decorators/integer.spec.ts b/packages/common/src/jsonschema/decorators/integer.spec.ts index 38bbfd5782e..e3df8316c4a 100644 --- a/packages/common/src/jsonschema/decorators/integer.spec.ts +++ b/packages/common/src/jsonschema/decorators/integer.spec.ts @@ -13,10 +13,10 @@ describe("Integer", () => { definitions: {}, properties: { prop: { - type: "integer", - }, + type: "integer" + } }, - type: "object", + type: "object" }); }); }); diff --git a/packages/common/src/jsonschema/decorators/property.spec.ts b/packages/common/src/jsonschema/decorators/property.spec.ts index c9a87537aba..4172d33db11 100644 --- a/packages/common/src/jsonschema/decorators/property.spec.ts +++ b/packages/common/src/jsonschema/decorators/property.spec.ts @@ -17,12 +17,12 @@ describe("Property()", () => { properties: { test: { items: { - type: "string", + type: "string" }, - type: "array", - }, + type: "array" + } }, - type: "object", + type: "object" }); }); it("should create schema from Name", () => { @@ -35,10 +35,10 @@ describe("Property()", () => { definitions: {}, properties: { test: { - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }); }); it("should create schema from Class", () => { @@ -52,12 +52,12 @@ describe("Property()", () => { properties: { test: { items: { - type: "string", + type: "string" }, - type: "array", - }, + type: "array" + } }, - type: "object", + type: "object" }); }); it("should create a schema", () => { @@ -66,101 +66,101 @@ describe("Property()", () => { JsonAgeModel: { properties: { age: { - type: "number", + type: "number" }, id: { - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }, JsonFoo1: { properties: { test: { - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }, JsonNameModel: { properties: { name: { - type: "string", + type: "string" }, id: { - type: "string", - }, + type: "string" + } }, - type: "object", - }, + type: "object" + } }, required: ["test", "foo"], properties: { ageModel: { - $ref: "#/definitions/JsonAgeModel", + $ref: "#/definitions/JsonAgeModel" }, arrayOfString: { items: { - type: "string", + type: "string" }, - type: "array", + type: "array" }, dateStart: { - type: "string", + type: "string" }, foo: { - type: "object", + type: "object" }, foos: { items: { - type: "object", + type: "object" }, - type: "array", + type: "array" }, foos2: { items: { - $ref: "#/definitions/JsonFoo1", + $ref: "#/definitions/JsonFoo1" }, - type: "array", + type: "array" }, mapOfString: { additionalProperties: { - type: "string", - }, + type: "string" + } }, name: { minLength: 3, - type: "string", + type: "string" }, object: { - type: "object", + type: "object" }, password: { - type: "string", + type: "string" }, nameModel: { - $ref: "#/definitions/JsonNameModel", + $ref: "#/definitions/JsonNameModel" }, test: { minLength: 3, - type: "string", + type: "string" }, theMap: { additionalProperties: { - $ref: "#/definitions/JsonFoo1", - }, + $ref: "#/definitions/JsonFoo1" + } }, theSet: { additionalProperties: { - $ref: "#/definitions/JsonFoo1", - }, + $ref: "#/definitions/JsonFoo1" + } }, uint: { - type: "number", - }, + type: "number" + } }, - type: "object", + type: "object" }); }); }); diff --git a/packages/common/src/jsonschema/jsonschema.integration.spec.ts b/packages/common/src/jsonschema/jsonschema.integration.spec.ts index e7e6f8221e4..ce537fae0ea 100644 --- a/packages/common/src/jsonschema/jsonschema.integration.spec.ts +++ b/packages/common/src/jsonschema/jsonschema.integration.spec.ts @@ -14,101 +14,101 @@ describe("JsonSchemesService", () => { JsonAgeModel: { properties: { age: { - type: "number", + type: "number" }, id: { - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }, JsonFoo1: { properties: { test: { - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }, JsonNameModel: { properties: { id: { - type: "string", + type: "string" }, name: { - type: "string", - }, + type: "string" + } }, - type: "object", - }, + type: "object" + } }, properties: { ageModel: { - $ref: "#/definitions/JsonAgeModel", + $ref: "#/definitions/JsonAgeModel" }, arrayOfString: { items: { - type: "string", + type: "string" }, - type: "array", + type: "array" }, dateStart: { - type: "string", + type: "string" }, foo: { - type: "object", + type: "object" }, foos: { items: { - type: "object", + type: "object" }, - type: "array", + type: "array" }, foos2: { items: { - $ref: "#/definitions/JsonFoo1", + $ref: "#/definitions/JsonFoo1" }, - type: "array", + type: "array" }, mapOfString: { additionalProperties: { - type: "string", - }, + type: "string" + } }, name: { minLength: 3, - type: "string", + type: "string" }, nameModel: { - $ref: "#/definitions/JsonNameModel", + $ref: "#/definitions/JsonNameModel" }, object: { - type: "object", + type: "object" }, password: { - type: "string", + type: "string" }, test: { minLength: 3, - type: "string", + type: "string" }, theMap: { additionalProperties: { - $ref: "#/definitions/JsonFoo1", - }, + $ref: "#/definitions/JsonFoo1" + } }, theSet: { additionalProperties: { - $ref: "#/definitions/JsonFoo1", - }, + $ref: "#/definitions/JsonFoo1" + } }, uint: { - type: "number", - }, + type: "number" + } }, required: ["test", "foo"], - type: "object", + type: "object" }); }); }); @@ -120,29 +120,29 @@ describe("JsonSchemesService", () => { Stuff: { properties: { name: { - type: "string", + type: "string" }, nested: { - $ref: "#/definitions/Nested", - }, + $ref: "#/definitions/Nested" + } }, - type: "object", + type: "object" }, Nested: { properties: { count: { - type: "number", - }, + type: "number" + } }, - type: "object", - }, + type: "object" + } }, properties: { stuff: { - $ref: "#/definitions/Stuff", - }, + $ref: "#/definitions/Stuff" + } }, - type: "object", + type: "object" }); }); }); @@ -168,34 +168,34 @@ describe("JsonSchemesService", () => { definitions: {}, properties: { age: { - type: "number", + type: "number" }, name: { - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }); expect(getJsonSchema(M3)).to.deep.eq({ definitions: { M2: { properties: { name: { - type: "string", + type: "string" }, age: { - type: "number", - }, + type: "number" + } }, - type: "object", - }, + type: "object" + } }, properties: { nested: { - $ref: "#/definitions/M2", - }, + $ref: "#/definitions/M2" + } }, - type: "object", + type: "object" }); }); }); @@ -207,18 +207,18 @@ describe("JsonSchemesService", () => { Circular: { properties: { parent: { - $ref: "#/definitions/Circular", - }, + $ref: "#/definitions/Circular" + } }, - type: "object", - }, + type: "object" + } }, properties: { parent: { - $ref: "#/definitions/Circular", - }, + $ref: "#/definitions/Circular" + } }, - type: "object", + type: "object" }); }); }); @@ -230,26 +230,26 @@ describe("JsonSchemesService", () => { Dependency: { properties: { dep: { - $ref: "#/definitions/IndirectCircular", - }, + $ref: "#/definitions/IndirectCircular" + } }, - type: "object", + type: "object" }, IndirectCircular: { properties: { parent: { - $ref: "#/definitions/Dependency", - }, + $ref: "#/definitions/Dependency" + } }, - type: "object", - }, + type: "object" + } }, properties: { parent: { - $ref: "#/definitions/Dependency", - }, + $ref: "#/definitions/Dependency" + } }, - type: "object", + type: "object" }); }); }); diff --git a/packages/common/src/jsonschema/registries/JsonSchemesRegistry.spec.ts b/packages/common/src/jsonschema/registries/JsonSchemesRegistry.spec.ts index 731ffd92ccb..4a55a5edbe1 100644 --- a/packages/common/src/jsonschema/registries/JsonSchemesRegistry.spec.ts +++ b/packages/common/src/jsonschema/registries/JsonSchemesRegistry.spec.ts @@ -10,71 +10,71 @@ describe("JsonSchemesRegistry", () => { expect(j(JsonSchemesRegistry.get(JsonFoo2))).to.deep.eq({ properties: { ageModel: { - $ref: "#/definitions/JsonAgeModel", + $ref: "#/definitions/JsonAgeModel" }, arrayOfString: { items: { - type: "string", + type: "string" }, - type: "array", + type: "array" }, dateStart: { - type: "string", + type: "string" }, foo: { - $ref: "#/definitions/JsonFoo", + $ref: "#/definitions/JsonFoo" }, foos: { items: { - $ref: "#/definitions/JsonFoo", + $ref: "#/definitions/JsonFoo" }, - type: "array", + type: "array" }, foos2: { items: { - $ref: "#/definitions/JsonFoo1", + $ref: "#/definitions/JsonFoo1" }, - type: "array", + type: "array" }, mapOfString: { additionalProperties: { - type: "string", - }, + type: "string" + } }, name: { minLength: 3, - type: "string", + type: "string" }, nameModel: { - $ref: "#/definitions/JsonNameModel", + $ref: "#/definitions/JsonNameModel" }, password: { - type: "string", + type: "string" }, object: { - type: "object", + type: "object" }, test: { minLength: 3, - type: "string", + type: "string" }, theMap: { additionalProperties: { - $ref: "#/definitions/JsonFoo1", - }, + $ref: "#/definitions/JsonFoo1" + } }, theSet: { additionalProperties: { - $ref: "#/definitions/JsonFoo1", - }, + $ref: "#/definitions/JsonFoo1" + } }, uint: { - type: "number", - }, + type: "number" + } }, required: ["test", "foo"], - type: "object", + type: "object" }); }); }); diff --git a/packages/common/src/jsonschema/registries/JsonSchemesRegistry.ts b/packages/common/src/jsonschema/registries/JsonSchemesRegistry.ts index 66fa32218a9..f86b588c32f 100644 --- a/packages/common/src/jsonschema/registries/JsonSchemesRegistry.ts +++ b/packages/common/src/jsonschema/registries/JsonSchemesRegistry.ts @@ -58,7 +58,7 @@ export class JsonSchemaRegistry extends Registry> { property(target: Type, propertyKey: string, type: any, collectionType?: any): JsonSchema { if (!this.has(target)) { this.merge(target, { - type: target, + type: target }); Store.from(target).set("schema", this.get(target)); } @@ -102,7 +102,7 @@ export class JsonSchemaRegistry extends Registry> { getSchemaDefinition(target: Type, options: Partial = {}): JSONSchema6 { if (isPrimitiveOrPrimitiveClass(target)) { return { - type: getJsonType(target), + type: getJsonType(target) }; } diff --git a/packages/common/src/jsonschema/services/JsonSchemesService.spec.ts b/packages/common/src/jsonschema/services/JsonSchemesService.spec.ts index 79aa821a038..50beae77120 100644 --- a/packages/common/src/jsonschema/services/JsonSchemesService.spec.ts +++ b/packages/common/src/jsonschema/services/JsonSchemesService.spec.ts @@ -18,101 +18,101 @@ describe("JsonSchemesService", () => { JsonAgeModel: { properties: { age: { - type: "number", + type: "number" }, id: { - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }, JsonFoo1: { properties: { test: { - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }, JsonNameModel: { properties: { name: { - type: "string", + type: "string" }, id: { - type: "string", - }, + type: "string" + } }, - type: "object", - }, + type: "object" + } }, properties: { ageModel: { - $ref: "#/definitions/JsonAgeModel", + $ref: "#/definitions/JsonAgeModel" }, arrayOfString: { items: { - type: "string", + type: "string" }, - type: "array", + type: "array" }, dateStart: { - type: "string", + type: "string" }, foo: { - type: "object", + type: "object" }, foos: { items: { - type: "object", + type: "object" }, - type: "array", + type: "array" }, foos2: { items: { - $ref: "#/definitions/JsonFoo1", + $ref: "#/definitions/JsonFoo1" }, - type: "array", + type: "array" }, mapOfString: { additionalProperties: { - type: "string", - }, + type: "string" + } }, name: { minLength: 3, - type: "string", + type: "string" }, nameModel: { - $ref: "#/definitions/JsonNameModel", + $ref: "#/definitions/JsonNameModel" }, object: { - type: "object", + type: "object" }, password: { - type: "string", + type: "string" }, test: { minLength: 3, - type: "string", + type: "string" }, theMap: { additionalProperties: { - $ref: "#/definitions/JsonFoo1", - }, + $ref: "#/definitions/JsonFoo1" + } }, theSet: { additionalProperties: { - $ref: "#/definitions/JsonFoo1", - }, + $ref: "#/definitions/JsonFoo1" + } }, uint: { - type: "number", - }, + type: "number" + } }, required: ["test", "foo"], - type: "object", + type: "object" }); }) ); diff --git a/packages/common/src/mvc/MvcModule.ts b/packages/common/src/mvc/MvcModule.ts index 430b458b784..4f321998d64 100644 --- a/packages/common/src/mvc/MvcModule.ts +++ b/packages/common/src/mvc/MvcModule.ts @@ -5,6 +5,6 @@ import {ParseService} from "./services/ParseService"; import {ValidationService} from "./services/ValidationService"; @Module({ - imports: [ConverterModule, ParseService, ValidationService, JsonSchemesService], + imports: [ConverterModule, ParseService, ValidationService, JsonSchemesService] }) export class MvcModule {} diff --git a/packages/common/src/mvc/constants/index.ts b/packages/common/src/mvc/constants/index.ts index c594913e758..76d7ec6ac45 100644 --- a/packages/common/src/mvc/constants/index.ts +++ b/packages/common/src/mvc/constants/index.ts @@ -26,5 +26,5 @@ export const HTTP_METHODS = [ "subscribe", "trace", "unlock", - "unsuscribe", + "unsuscribe" ]; diff --git a/packages/common/src/mvc/decorators/allow.spec.ts b/packages/common/src/mvc/decorators/allow.spec.ts index f3d52de095d..1ff05af8d97 100644 --- a/packages/common/src/mvc/decorators/allow.spec.ts +++ b/packages/common/src/mvc/decorators/allow.spec.ts @@ -60,12 +60,12 @@ describe("Allow", () => { expect(metadata.schema.toJSON()).to.deep.eq({ oneOf: [ { - type: "null", + type: "null" }, { - $ref: "#/definitions/Children", - }, - ], + $ref: "#/definitions/Children" + } + ] }); }); }); diff --git a/packages/common/src/mvc/decorators/class/controller.spec.ts b/packages/common/src/mvc/decorators/class/controller.spec.ts index 6867b18c46f..883458155d0 100644 --- a/packages/common/src/mvc/decorators/class/controller.spec.ts +++ b/packages/common/src/mvc/decorators/class/controller.spec.ts @@ -28,7 +28,7 @@ describe("@Controller", () => { Controller({ path: "/test", children: [Dep], - scope: ProviderScope.REQUEST, + scope: ProviderScope.REQUEST })(Test); // THEN diff --git a/packages/common/src/mvc/decorators/class/controller.ts b/packages/common/src/mvc/decorators/class/controller.ts index 5ef2a3b37b0..32b17ac7b25 100644 --- a/packages/common/src/mvc/decorators/class/controller.ts +++ b/packages/common/src/mvc/decorators/class/controller.ts @@ -54,13 +54,13 @@ export function Controller(options: PathParamsType | IControllerOptions, ...chil registerController({ provide: target, path: options, - children, + children }); } else { registerController({ provide: target, children: (options as IControllerOptions).dependencies || (options as IControllerOptions).children, - ...options, + ...options }); } }; diff --git a/packages/common/src/mvc/decorators/method/authOptions.spec.ts b/packages/common/src/mvc/decorators/method/authOptions.spec.ts index d2efaf3b54e..3e9eb4405f0 100644 --- a/packages/common/src/mvc/decorators/method/authOptions.spec.ts +++ b/packages/common/src/mvc/decorators/method/authOptions.spec.ts @@ -19,14 +19,14 @@ describe("AuthOptions()", () => { AuthOptions(Guard, { security: [ { - auth: ["email"], - }, + auth: ["email"] + } ], responses: { "200": { - description: "Success", - }, - }, + description: "Success" + } + } })(...decoratorArgs(prototypeOf(Test), "test")); // THEN @@ -35,14 +35,14 @@ describe("AuthOptions()", () => { expect(store.get("operation")).to.deep.eq({ security: [ { - auth: ["email"], - }, - ], + auth: ["email"] + } + ] }); expect(store.get("responses")).to.deep.eq({ "200": { - description: "Success", - }, + description: "Success" + } }); store.set("operation", {}); store.set("responses", {}); @@ -58,14 +58,14 @@ describe("AuthOptions()", () => { AuthOptions(Guard, { security: [ { - auth: ["email"], - }, + auth: ["email"] + } ], responses: { "200": { - description: "Success", - }, - }, + description: "Success" + } + } })(Test); // THEN @@ -74,14 +74,14 @@ describe("AuthOptions()", () => { expect(store.get("operation")).to.deep.eq({ security: [ { - auth: ["email"], - }, - ], + auth: ["email"] + } + ] }); expect(store.get("responses")).to.deep.eq({ "200": { - description: "Success", - }, + description: "Success" + } }); store.set("operation", {}); diff --git a/packages/common/src/mvc/decorators/method/authenticated.spec.ts b/packages/common/src/mvc/decorators/method/authenticated.spec.ts index c7de023d746..85a5ec9f32d 100644 --- a/packages/common/src/mvc/decorators/method/authenticated.spec.ts +++ b/packages/common/src/mvc/decorators/method/authenticated.spec.ts @@ -8,7 +8,7 @@ const middleware: any = Sinon.stub(); const UseAuth: any = Sinon.stub().returns(middleware); const {Authenticated} = Proxyquire.load("../../../../src/mvc/decorators/method/authenticated", { - "./useAuth": {UseAuth}, + "./useAuth": {UseAuth} }); describe("Authenticated", () => { @@ -27,9 +27,9 @@ describe("Authenticated", () => { options: "options", responses: { "401": { - description: "Unauthorized", - }, - }, + description: "Unauthorized" + } + } }); }); }); diff --git a/packages/common/src/mvc/decorators/method/authenticated.ts b/packages/common/src/mvc/decorators/method/authenticated.ts index b637e11c879..c64016f07be 100644 --- a/packages/common/src/mvc/decorators/method/authenticated.ts +++ b/packages/common/src/mvc/decorators/method/authenticated.ts @@ -29,11 +29,11 @@ export function Authenticated(options: IAuthOptions = {}): Function { options = { responses: { "401": { - description: "Unauthorized", + description: "Unauthorized" }, - ...(options.responses || {}), + ...(options.responses || {}) }, - ...options, + ...options }; return UseAuth(AuthenticatedMiddleware, options); diff --git a/packages/common/src/mvc/decorators/method/header.spec.ts b/packages/common/src/mvc/decorators/method/header.spec.ts index 9c6c5b71d2c..9dbe6083c86 100644 --- a/packages/common/src/mvc/decorators/method/header.spec.ts +++ b/packages/common/src/mvc/decorators/method/header.spec.ts @@ -10,16 +10,16 @@ describe("mapHeaders", () => { header2: "content", header3: { value: "content2", - type: "string", - }, + type: "string" + } } as any) ).to.deep.eq({ header1: {value: 1, type: "number"}, header2: {value: "content", type: "string"}, header3: { value: "content2", - type: "string", - }, + type: "string" + } }); }); }); @@ -40,9 +40,9 @@ describe("Header", () => { headers: { "Content-Type": { type: "string", - value: "application/json", - }, - }, + value: "application/json" + } + } }); }); }); @@ -60,9 +60,9 @@ describe("Header", () => { headers: { "Content-Type": { type: "string", - value: "application/json", - }, - }, + value: "application/json" + } + } }); }); }); @@ -74,8 +74,8 @@ describe("Header", () => { "Content-Length": 123, ETag: { value: "12345", - description: "header description", - }, + description: "header description" + } } as any) test() {} } @@ -87,18 +87,18 @@ describe("Header", () => { headers: { "Content-Length": { type: "number", - value: 123, + value: 123 }, "Content-Type": { type: "string", - value: "text/plain", + value: "text/plain" }, ETag: { description: "header description", type: "string", - value: "12345", - }, - }, + value: "12345" + } + } }); }); }); diff --git a/packages/common/src/mvc/decorators/method/header.ts b/packages/common/src/mvc/decorators/method/header.ts index 0828a6eb372..ccd4b3a8256 100644 --- a/packages/common/src/mvc/decorators/method/header.ts +++ b/packages/common/src/mvc/decorators/method/header.ts @@ -16,7 +16,7 @@ export function mapHeaders(headers: IHeadersOptions): IResponseHeaders { const value: any = headers[key]; let type = typeof value; let options: any = { - value, + value }; if (type === "object") { diff --git a/packages/common/src/mvc/decorators/method/returnType.ts b/packages/common/src/mvc/decorators/method/returnType.ts index 0fc45f18f99..3869359d144 100644 --- a/packages/common/src/mvc/decorators/method/returnType.ts +++ b/packages/common/src/mvc/decorators/method/returnType.ts @@ -24,7 +24,7 @@ function mapStatusResponseOptions(args: any[]): any { ...options, code, type: options.type || options.use, - collectionType: options.collectionType || options.collection, + collectionType: options.collectionType || options.collection }; } @@ -68,7 +68,7 @@ export function ReturnType(response: Partial = {}): Function { response = { description: "", ...deepMerge(endpoint.responses.get(code), cleanObject(response)), - code, + code }; endpoint.responses.set(response.code!, response as IResponseOptions); diff --git a/packages/common/src/mvc/decorators/method/returnTypes.spec.ts b/packages/common/src/mvc/decorators/method/returnTypes.spec.ts index 5fcffedeb1a..b80ccfff600 100644 --- a/packages/common/src/mvc/decorators/method/returnTypes.spec.ts +++ b/packages/common/src/mvc/decorators/method/returnTypes.spec.ts @@ -15,9 +15,9 @@ describe("ReturnType", () => { headers: { // @ts-ignore "x-header": { - value: "test", - }, - }, + value: "test" + } + } }) get() {} } @@ -33,9 +33,9 @@ describe("ReturnType", () => { description: "", headers: { "x-header": { - value: "test", - }, - }, + value: "test" + } + } }); }); it("should store metadata (when code is not given)", () => { @@ -50,9 +50,9 @@ describe("ReturnType", () => { headers: { // @ts-ignore "x-header": { - value: "test", - }, - }, + value: "test" + } + } }) get() {} } @@ -67,9 +67,9 @@ describe("ReturnType", () => { description: "", headers: { "x-header": { - value: "test", - }, - }, + value: "test" + } + } }); }); }); diff --git a/packages/common/src/mvc/decorators/method/route.spec.ts b/packages/common/src/mvc/decorators/method/route.spec.ts index 24d467bf46c..f8b297df71b 100644 --- a/packages/common/src/mvc/decorators/method/route.spec.ts +++ b/packages/common/src/mvc/decorators/method/route.spec.ts @@ -23,8 +23,8 @@ describe("Route decorators", () => { expect(endpoint.pathsMethods).to.deep.eq([ { method: "all", - path: "/", - }, + path: "/" + } ]); expect(endpoint.propertyKey).to.equal("test"); }); @@ -44,8 +44,8 @@ describe("Route decorators", () => { expect(endpoint.pathsMethods).to.deep.eq([ { method: "get", - path: "/", - }, + path: "/" + } ]); expect(endpoint.propertyKey).to.equal("test"); }); @@ -64,8 +64,8 @@ describe("Route decorators", () => { expect(endpoint.pathsMethods).to.deep.eq([ { method: "get", - path: "/", - }, + path: "/" + } ]); expect(endpoint.propertyKey).to.equal("test"); expect(endpoint.middlewares).to.deep.equal([middleware]); @@ -86,8 +86,8 @@ describe("Route decorators", () => { expect(endpoint.pathsMethods).to.deep.eq([ { method: "post", - path: "/", - }, + path: "/" + } ]); expect(endpoint.propertyKey).to.equal("test"); }); @@ -107,8 +107,8 @@ describe("Route decorators", () => { expect(endpoint.pathsMethods).to.deep.eq([ { method: "put", - path: "/", - }, + path: "/" + } ]); expect(endpoint.propertyKey).to.equal("test"); }); @@ -128,8 +128,8 @@ describe("Route decorators", () => { expect(endpoint.pathsMethods).to.deep.eq([ { method: "delete", - path: "/", - }, + path: "/" + } ]); expect(endpoint.propertyKey).to.equal("test"); }); @@ -149,8 +149,8 @@ describe("Route decorators", () => { expect(endpoint.pathsMethods).to.deep.eq([ { method: "head", - path: "/", - }, + path: "/" + } ]); expect(endpoint.propertyKey).to.equal("test"); }); @@ -170,8 +170,8 @@ describe("Route decorators", () => { expect(endpoint.pathsMethods).to.deep.eq([ { method: "patch", - path: "/", - }, + path: "/" + } ]); expect(endpoint.propertyKey).to.equal("test"); }); @@ -191,8 +191,8 @@ describe("Route decorators", () => { expect(endpoint.pathsMethods).to.deep.eq([ { method: "options", - path: "/", - }, + path: "/" + } ]); expect(endpoint.propertyKey).to.equal("test"); }); diff --git a/packages/common/src/mvc/decorators/method/status.spec.ts b/packages/common/src/mvc/decorators/method/status.spec.ts index af9a53a8eb5..91a1edb2af7 100644 --- a/packages/common/src/mvc/decorators/method/status.spec.ts +++ b/packages/common/src/mvc/decorators/method/status.spec.ts @@ -15,9 +15,9 @@ describe("Status", () => { description: "description", headers: { "x-header": { - type: "string", - }, - }, + type: "string" + } + } }) get() {} } @@ -32,9 +32,9 @@ describe("Status", () => { type: TypeC, headers: { "x-header": { - type: "string", - }, - }, + type: "string" + } + } }; expect(endpoint.responses.get(200)).to.deep.eq(response); @@ -52,9 +52,9 @@ describe("Status", () => { description: "description", headers: { "x-header": { - type: "string", - }, - }, + type: "string" + } + } }) get() {} } @@ -69,9 +69,9 @@ describe("Status", () => { type: TypeC, headers: { "x-header": { - type: "string", - }, - }, + type: "string" + } + } }; expect(endpoint.responses.get(204)).to.deep.eq(response); @@ -89,9 +89,9 @@ describe("Status", () => { description: "description", headers: { "x-header": { - type: "string", - }, - }, + type: "string" + } + } }) get() {} } @@ -106,9 +106,9 @@ describe("Status", () => { type: TypeC, headers: { "x-header": { - type: "string", - }, - }, + type: "string" + } + } }; expect(endpoint.responses.get(201)).to.deep.eq(response); @@ -127,9 +127,9 @@ describe("Status", () => { description: "description", headers: { "x-error": { - type: "string", - }, - }, + type: "string" + } + } }) @Status(200, { type: TypeC, @@ -137,9 +137,9 @@ describe("Status", () => { description: "description", headers: { "x-map": { - type: "string", - }, - }, + type: "string" + } + } }) get() {} } @@ -152,9 +152,9 @@ describe("Status", () => { type: CustomError, headers: { "x-error": { - type: "string", - }, - }, + type: "string" + } + } }); expect(endpoint.statusCode).to.eq(200); expect(endpoint.responses.get(200)).to.deep.eq({ @@ -164,9 +164,9 @@ describe("Status", () => { type: TypeC, headers: { "x-map": { - type: "string", - }, - }, + type: "string" + } + } }); }); }); diff --git a/packages/common/src/mvc/decorators/method/status.ts b/packages/common/src/mvc/decorators/method/status.ts index cb76c415670..a5577ab10b3 100644 --- a/packages/common/src/mvc/decorators/method/status.ts +++ b/packages/common/src/mvc/decorators/method/status.ts @@ -51,6 +51,6 @@ export function Status(code: number, options: Partial = {} ...options, code, type: options.type || use, - collectionType: options.collectionType || collection, + collectionType: options.collectionType || collection }); } diff --git a/packages/common/src/mvc/decorators/method/use.ts b/packages/common/src/mvc/decorators/method/use.ts index 8b7bcf32911..0fe0d9e4afc 100644 --- a/packages/common/src/mvc/decorators/method/use.ts +++ b/packages/common/src/mvc/decorators/method/use.ts @@ -25,7 +25,7 @@ function mapOptions(args: any[]) { return { path, method, - middlewares, + middlewares }; } @@ -59,7 +59,7 @@ export function Use(...args: any[]): Function { options.path && endpoint.pathsMethods.push({ method: options.method, - path: options.path!, + path: options.path! }); endpoint.use(args); @@ -68,7 +68,7 @@ export function Use(...args: any[]): Function { } Store.from(target).merge("middlewares", { - use: args, + use: args }); }; } diff --git a/packages/common/src/mvc/decorators/method/useAuth.spec.ts b/packages/common/src/mvc/decorators/method/useAuth.spec.ts index dd9d192107c..0e51f5669ab 100644 --- a/packages/common/src/mvc/decorators/method/useAuth.spec.ts +++ b/packages/common/src/mvc/decorators/method/useAuth.spec.ts @@ -15,14 +15,14 @@ describe("UseAuth()", () => { @UseAuth(Guard, { security: [ { - auth: ["email"], - }, + auth: ["email"] + } ], responses: { "200": { - description: "Success", - }, - }, + description: "Success" + } + } }) class Test { test() {} @@ -38,14 +38,14 @@ describe("UseAuth()", () => { expect(store.get("operation")).to.deep.eq({ security: [ { - auth: ["email"], - }, - ], + auth: ["email"] + } + ] }); expect(store.get("responses")).to.deep.eq({ "200": { - description: "Success", - }, + description: "Success" + } }); store.set("operation", {}); store.set("responses", {}); @@ -57,14 +57,14 @@ describe("UseAuth()", () => { @UseAuth(Guard, { security: [ { - auth: ["email"], - }, + auth: ["email"] + } ], responses: { "200": { - description: "Success", - }, - }, + description: "Success" + } + } }) class Test { test() {} @@ -81,14 +81,14 @@ describe("UseAuth()", () => { expect(store.get("operation")).to.deep.eq({ security: [ { - auth: ["email"], - }, - ], + auth: ["email"] + } + ] }); expect(store.get("responses")).to.deep.eq({ "200": { - description: "Success", - }, + description: "Success" + } }); store.set("operation", {}); diff --git a/packages/common/src/mvc/decorators/method/useAuth.ts b/packages/common/src/mvc/decorators/method/useAuth.ts index 9116099e4d2..63b1a91f915 100644 --- a/packages/common/src/mvc/decorators/method/useAuth.ts +++ b/packages/common/src/mvc/decorators/method/useAuth.ts @@ -6,7 +6,7 @@ import { Store, StoreFn, Type, - UnsupportedDecoratorType, + UnsupportedDecoratorType } from "@tsed/core"; import {AuthOptions, IAuthOptions} from "./authOptions"; import {UseBefore} from "./useBefore"; diff --git a/packages/common/src/mvc/decorators/method/view.spec.ts b/packages/common/src/mvc/decorators/method/view.spec.ts index c28476f5e1f..ba7283caa5c 100644 --- a/packages/common/src/mvc/decorators/method/view.spec.ts +++ b/packages/common/src/mvc/decorators/method/view.spec.ts @@ -12,7 +12,7 @@ describe("ResponseView", () => { const endpoint = EndpointMetadata.get(Test, "test"); expect(endpoint.view).to.deep.eq({ path: "page", - options: {test: "test"}, + options: {test: "test"} }); }); it("should set metadata", () => { @@ -24,7 +24,7 @@ describe("ResponseView", () => { const endpoint = EndpointMetadata.get(Test, "test"); expect(endpoint.view).to.deep.eq({ path: "page", - options: {test: "test"}, + options: {test: "test"} }); }); it("should set metadata", () => { @@ -36,7 +36,7 @@ describe("ResponseView", () => { const endpoint = EndpointMetadata.get(Test, "test"); expect(endpoint.view).to.deep.eq({ path: "page", - options: {test: "test"}, + options: {test: "test"} }); }); }); diff --git a/packages/common/src/mvc/decorators/params/bodyParams.ts b/packages/common/src/mvc/decorators/params/bodyParams.ts index ba3f09ca449..d314bde731d 100644 --- a/packages/common/src/mvc/decorators/params/bodyParams.ts +++ b/packages/common/src/mvc/decorators/params/bodyParams.ts @@ -53,6 +53,6 @@ export function BodyParams(...args: any[]): ParameterDecorator { expression, useType, useConverter, - useValidation, + useValidation }); } diff --git a/packages/common/src/mvc/decorators/params/cookies.ts b/packages/common/src/mvc/decorators/params/cookies.ts index eaa38f0c846..bd3b7ab1443 100644 --- a/packages/common/src/mvc/decorators/params/cookies.ts +++ b/packages/common/src/mvc/decorators/params/cookies.ts @@ -47,7 +47,7 @@ export function CookiesParams(...args: any[]): ParameterDecorator { expression, useType, useConverter, - useValidation, + useValidation }); } diff --git a/packages/common/src/mvc/decorators/params/endpointInfo.ts b/packages/common/src/mvc/decorators/params/endpointInfo.ts index 2b680cd31e8..c993925714a 100644 --- a/packages/common/src/mvc/decorators/params/endpointInfo.ts +++ b/packages/common/src/mvc/decorators/params/endpointInfo.ts @@ -13,6 +13,6 @@ export type EndpointInfo = EndpointMetadata; export function EndpointInfo(): Function { return UseParam(ParamTypes.ENDPOINT_INFO, { useConverter: false, - useValidation: false, + useValidation: false }); } diff --git a/packages/common/src/mvc/decorators/params/error.ts b/packages/common/src/mvc/decorators/params/error.ts index 0971e98db24..c8e4eb7e58f 100644 --- a/packages/common/src/mvc/decorators/params/error.ts +++ b/packages/common/src/mvc/decorators/params/error.ts @@ -11,6 +11,6 @@ import {UseParam} from "./useParam"; export function Err(): Function { return UseParam(ParamTypes.ERR, { useValidation: false, - useConverter: false, + useConverter: false }); } diff --git a/packages/common/src/mvc/decorators/params/headerParams.ts b/packages/common/src/mvc/decorators/params/headerParams.ts index f2721a7d5c2..c6cc92556ea 100644 --- a/packages/common/src/mvc/decorators/params/headerParams.ts +++ b/packages/common/src/mvc/decorators/params/headerParams.ts @@ -43,6 +43,6 @@ export function HeaderParams(...args: any[]): ParameterDecorator { expression, useType, useConverter, - useValidation, + useValidation }); } diff --git a/packages/common/src/mvc/decorators/params/locals.ts b/packages/common/src/mvc/decorators/params/locals.ts index 2a65dae9ec0..172dcf081cc 100644 --- a/packages/common/src/mvc/decorators/params/locals.ts +++ b/packages/common/src/mvc/decorators/params/locals.ts @@ -51,6 +51,6 @@ export function Locals(...args: any[]): ParameterDecorator { expression, useType, useConverter, - useValidation, + useValidation }); } diff --git a/packages/common/src/mvc/decorators/params/next.ts b/packages/common/src/mvc/decorators/params/next.ts index 190442a73c5..e90558ebbfa 100644 --- a/packages/common/src/mvc/decorators/params/next.ts +++ b/packages/common/src/mvc/decorators/params/next.ts @@ -11,7 +11,7 @@ import {UseParam} from "./useParam"; export function Next(): ParameterDecorator { return UseParam(ParamTypes.NEXT_FN, { useConverter: false, - useValidation: false, + useValidation: false }); } diff --git a/packages/common/src/mvc/decorators/params/pathParams.ts b/packages/common/src/mvc/decorators/params/pathParams.ts index 663b359dfb3..0061bd40b72 100644 --- a/packages/common/src/mvc/decorators/params/pathParams.ts +++ b/packages/common/src/mvc/decorators/params/pathParams.ts @@ -48,7 +48,7 @@ export function PathParams(...args: any[]): ParameterDecorator { expression, useType, useConverter, - useValidation, + useValidation }); } diff --git a/packages/common/src/mvc/decorators/params/queryParams.ts b/packages/common/src/mvc/decorators/params/queryParams.ts index acab726d295..1962ca6567e 100644 --- a/packages/common/src/mvc/decorators/params/queryParams.ts +++ b/packages/common/src/mvc/decorators/params/queryParams.ts @@ -53,7 +53,7 @@ export function QueryParams(...args: any[]): ParameterDecorator { expression, useType, useConverter, - useValidation, + useValidation }); } diff --git a/packages/common/src/mvc/decorators/params/request.ts b/packages/common/src/mvc/decorators/params/request.ts index 0176e63a550..1f6bc816f22 100644 --- a/packages/common/src/mvc/decorators/params/request.ts +++ b/packages/common/src/mvc/decorators/params/request.ts @@ -41,7 +41,7 @@ export function Req(...args: any[]): ParameterDecorator { expression, useType, useConverter, - useValidation, + useValidation }); } diff --git a/packages/common/src/mvc/decorators/params/session.ts b/packages/common/src/mvc/decorators/params/session.ts index e4d4e7076f7..12d80442da7 100644 --- a/packages/common/src/mvc/decorators/params/session.ts +++ b/packages/common/src/mvc/decorators/params/session.ts @@ -45,6 +45,6 @@ export function Session(...args: any[]): ParameterDecorator { expression, useType, useConverter, - useValidation, + useValidation }); } diff --git a/packages/common/src/mvc/decorators/params/useParam.spec.ts b/packages/common/src/mvc/decorators/params/useParam.spec.ts index 74af059a51c..94fde3e2829 100644 --- a/packages/common/src/mvc/decorators/params/useParam.spec.ts +++ b/packages/common/src/mvc/decorators/params/useParam.spec.ts @@ -26,7 +26,7 @@ describe("@UseParam", () => { useConverter: true, useValidation: true, paramType: ParamTypes.BODY, - useType: Test, + useType: Test }) body: Test ) {} @@ -47,7 +47,7 @@ describe("@UseParam", () => { useConverter: true, useValidation: true, paramType: ParamTypes.BODY, - useType: Test, + useType: Test }) body: Test ) {} @@ -74,7 +74,7 @@ describe("@UseParam", () => { useConverter: true, useValidation: true, paramType: ParamTypes.BODY, - useType: Test, + useType: Test }) body: Test ) {} diff --git a/packages/common/src/mvc/decorators/params/useParam.ts b/packages/common/src/mvc/decorators/params/useParam.ts index 5c834985e5d..7e54535c7be 100644 --- a/packages/common/src/mvc/decorators/params/useParam.ts +++ b/packages/common/src/mvc/decorators/params/useParam.ts @@ -18,7 +18,7 @@ function mapPipes(options: IParamOptions = {}) { options.useType && UseType(options.useType), options.expression && UseParamExpression(options.expression), options.useValidation && UseValidation(), - options.useConverter && UseDeserialization(), + options.useConverter && UseDeserialization() ]; } diff --git a/packages/common/src/mvc/decorators/required.ts b/packages/common/src/mvc/decorators/required.ts index 910a8c70f8f..3dfbc9c1779 100644 --- a/packages/common/src/mvc/decorators/required.ts +++ b/packages/common/src/mvc/decorators/required.ts @@ -65,8 +65,8 @@ export function Required(...allowedRequiredValues: any[]): any { }, StoreMerge("responses", { "400": { - description: "BadRequest", - }, + description: "BadRequest" + } }) ); } diff --git a/packages/common/src/mvc/errors/RequiredValidationError.spec.ts b/packages/common/src/mvc/errors/RequiredValidationError.spec.ts index 32c6cbf567d..38a05ba74a9 100644 --- a/packages/common/src/mvc/errors/RequiredValidationError.spec.ts +++ b/packages/common/src/mvc/errors/RequiredValidationError.spec.ts @@ -5,7 +5,7 @@ describe("RequiredValidationError", () => { it("should have a message", () => { const error = RequiredValidationError.from({ service: "name", - expression: "expression", + expression: "expression" } as any); expect(error.message).to.equal("It should have required parameter 'expression'"); expect(error.name).to.equal("REQUIRED_VALIDATION_ERROR"); @@ -21,11 +21,11 @@ describe("RequiredValidationError", () => { message: "It should have required parameter 'expression'", modelName: "name", params: { - missingProperty: "expression", + missingProperty: "expression" }, - schemaPath: "#/required", - }, - ], + schemaPath: "#/required" + } + ] }); }); }); diff --git a/packages/common/src/mvc/errors/RequiredValidationError.ts b/packages/common/src/mvc/errors/RequiredValidationError.ts index e7fc17d7e02..f9ca8258c48 100644 --- a/packages/common/src/mvc/errors/RequiredValidationError.ts +++ b/packages/common/src/mvc/errors/RequiredValidationError.ts @@ -19,10 +19,10 @@ export class RequiredValidationError extends ValidationError { message, modelName: type, params: { - missingProperty: expression, + missingProperty: expression }, - schemaPath: "#/required", - }, + schemaPath: "#/required" + } ]; return new RequiredValidationError(message, errors); diff --git a/packages/common/src/mvc/errors/ValidationError.spec.ts b/packages/common/src/mvc/errors/ValidationError.spec.ts index de494a6798b..296667ec10b 100644 --- a/packages/common/src/mvc/errors/ValidationError.spec.ts +++ b/packages/common/src/mvc/errors/ValidationError.spec.ts @@ -5,14 +5,14 @@ describe("ValidationError", () => { it("should return error", () => { const error = new ValidationError("should have required property", [ { - dataPath: "hello", - }, + dataPath: "hello" + } ]); expect(error.errors).to.deep.eq([ { - dataPath: "hello", - }, + dataPath: "hello" + } ]); expect(error.message).to.eq("should have required property"); }); diff --git a/packages/common/src/mvc/interfaces/HandlerType.ts b/packages/common/src/mvc/interfaces/HandlerType.ts index e318fbdd0bd..46e49c95d6c 100644 --- a/packages/common/src/mvc/interfaces/HandlerType.ts +++ b/packages/common/src/mvc/interfaces/HandlerType.ts @@ -1,5 +1,5 @@ export enum HandlerType { FUNCTION = "function", MIDDLEWARE = "middleware", - CONTROLLER = "controller", + CONTROLLER = "controller" } diff --git a/packages/common/src/mvc/middlewares/AcceptMimesMiddleware.spec.ts b/packages/common/src/mvc/middlewares/AcceptMimesMiddleware.spec.ts index 58d447fc07c..69290209af9 100644 --- a/packages/common/src/mvc/middlewares/AcceptMimesMiddleware.spec.ts +++ b/packages/common/src/mvc/middlewares/AcceptMimesMiddleware.spec.ts @@ -20,12 +20,12 @@ describe("AcceptMimesMiddleware", () => { const request: any = new FakeRequest({ sandbox, headers: { - accept: "application/json", - }, + accept: "application/json" + } }); const ctx = PlatformTest.createRequestContext({ request: new PlatformRequest(request), - endpoint, + endpoint }); const middleware = await PlatformTest.invoke(AcceptMimesMiddleware); @@ -44,12 +44,12 @@ describe("AcceptMimesMiddleware", () => { const request: any = new FakeRequest({ sandbox, headers: { - accept: "application/xml", - }, + accept: "application/xml" + } }); const ctx = PlatformTest.createRequestContext({ request: new PlatformRequest(request), - endpoint, + endpoint }); const middleware = await PlatformTest.invoke(AcceptMimesMiddleware); diff --git a/packages/common/src/mvc/models/EndpointMetadata.spec.ts b/packages/common/src/mvc/models/EndpointMetadata.spec.ts index 66204c1e926..0c261e95267 100644 --- a/packages/common/src/mvc/models/EndpointMetadata.spec.ts +++ b/packages/common/src/mvc/models/EndpointMetadata.spec.ts @@ -111,8 +111,8 @@ describe("EndpointMetadata", () => { expect(endpoint.pathsMethods).to.deep.equal([ { method: undefined, - path: "/", - }, + path: "/" + } ]); }); it("should add endpoint with path and method", () => { @@ -132,8 +132,8 @@ describe("EndpointMetadata", () => { expect(endpoint.pathsMethods).to.deep.equal([ { method: "get", - path: "/", - }, + path: "/" + } ]); }); }); @@ -201,7 +201,7 @@ describe("EndpointMetadata", () => { const result = endpointMetadata.statusResponse(200); expect(result).to.deep.eq({ - code: 200, + code: 200 }); expect(endpointMetadata.type).to.eq(undefined); @@ -222,7 +222,7 @@ describe("EndpointMetadata", () => { stub(endpointMetadata.store.get) .withArgs("responses") .returns({ - [200]: {}, + [200]: {} }); // WHEN @@ -230,7 +230,7 @@ describe("EndpointMetadata", () => { // THEN expect(result).to.deep.eq({ - code: 200, + code: 200 }); expect(endpointMetadata.type).to.eq(undefined); @@ -251,9 +251,9 @@ describe("EndpointMetadata", () => { headers: { headerName: { type: "string", - value: "x-content", - }, - }, + value: "x-content" + } + } } as any); // WHEN @@ -264,10 +264,10 @@ describe("EndpointMetadata", () => { headers: { headerName: { type: "string", - value: "x-content", - }, + value: "x-content" + } }, - type: Test, + type: Test }); expect(endpointMetadata.type).to.eq(Test); expect(endpointMetadata.collectionType).to.eq(undefined); diff --git a/packages/common/src/mvc/models/EndpointMetadata.ts b/packages/common/src/mvc/models/EndpointMetadata.ts index f895f5d208a..e7f702633af 100644 --- a/packages/common/src/mvc/models/EndpointMetadata.ts +++ b/packages/common/src/mvc/models/EndpointMetadata.ts @@ -12,7 +12,7 @@ import { prototypeOf, Storable, Store, - Type, + Type } from "@tsed/core"; import {IPathMethod} from "../interfaces/IPathMethod"; import {IResponseOptions} from "../interfaces/IResponseOptions"; @@ -93,7 +93,7 @@ export class EndpointMetadata extends Storable implements EndpointConstructorOpt middlewares = [], afterMiddlewares = [], pathsMethods = [], - type, + type } = options; this.provide = target; @@ -110,7 +110,7 @@ export class EndpointMetadata extends Storable implements EndpointConstructorOpt this.responses = responses; } else { this.responses.set(this.statusCode, { - code: this.statusCode, + code: this.statusCode } as any); } } @@ -158,7 +158,7 @@ export class EndpointMetadata extends Storable implements EndpointConstructorOpt set redirect(options: EndpointRedirectOptions) { this.store.set("redirect", { status: 302, - ...options, + ...options }); } @@ -371,7 +371,7 @@ export class EndpointMetadata extends Storable implements EndpointConstructorOpt pathsMethods: this.pathsMethods, type: this.type, responses: this.responses, - statusCode: this.statusCode, + statusCode: this.statusCode }); } } diff --git a/packages/common/src/mvc/models/HandlerMetadata.spec.ts b/packages/common/src/mvc/models/HandlerMetadata.spec.ts index 19d2a160f63..af12cf75d1d 100644 --- a/packages/common/src/mvc/models/HandlerMetadata.spec.ts +++ b/packages/common/src/mvc/models/HandlerMetadata.spec.ts @@ -19,7 +19,7 @@ describe("HandlerMetadata", () => { it("should create a new handlerMetadata with right metadata", () => { // GIVEN const options = { - target(req: any, res: any, next: any) {}, + target(req: any, res: any, next: any) {} }; // WHEN const handlerMetadata = new HandlerMetadata(options); @@ -37,7 +37,7 @@ describe("HandlerMetadata", () => { it("should create a new handlerMetadata with right metadata", () => { // GIVEN const options = { - target(err: any, req: any, res: any, next: any) {}, + target(err: any, req: any, res: any, next: any) {} }; // WHEN const handlerMetadata = new HandlerMetadata(options); @@ -52,20 +52,20 @@ describe("HandlerMetadata", () => { expect(handlerMetadata.parameters).to.deep.eq([ new ParamMetadata({ index: 0, - paramType: ParamTypes.ERR, + paramType: ParamTypes.ERR }), new ParamMetadata({ index: 1, - paramType: ParamTypes.REQUEST, + paramType: ParamTypes.REQUEST }), new ParamMetadata({ index: 2, - paramType: ParamTypes.RESPONSE, + paramType: ParamTypes.RESPONSE }), new ParamMetadata({ index: 3, - paramType: ParamTypes.NEXT_FN, - }), + paramType: ParamTypes.NEXT_FN + }) ]); }); }); @@ -74,7 +74,7 @@ describe("HandlerMetadata", () => { it("should create a new handlerMetadata with right metadata", () => { // GIVEN const options = { - target(req: any, res: any) {}, + target(req: any, res: any) {} }; // WHEN @@ -95,7 +95,7 @@ describe("HandlerMetadata", () => { const options: IHandlerConstructorOptions = { target: Test, propertyKey: "test", - type: HandlerType.CONTROLLER, + type: HandlerType.CONTROLLER }; // WHEN const handlerMetadata = new HandlerMetadata(options); @@ -117,7 +117,7 @@ describe("HandlerMetadata", () => { const options = { target: Test, propertyKey: "test", - type: HandlerType.CONTROLLER, + type: HandlerType.CONTROLLER }; // WHEN const handlerMetadata = new HandlerMetadata(options); @@ -139,7 +139,7 @@ describe("HandlerMetadata", () => { const options = { target: Test2, propertyKey: "use", - type: HandlerType.MIDDLEWARE, + type: HandlerType.MIDDLEWARE }; // WHEN const handlerMetadata = new HandlerMetadata(options); @@ -160,7 +160,7 @@ describe("HandlerMetadata", () => { const options = { target: Test2, propertyKey: "use", - type: HandlerType.MIDDLEWARE, + type: HandlerType.MIDDLEWARE }; // WHEN const handlerMetadata = new HandlerMetadata(options); diff --git a/packages/common/src/mvc/models/HandlerMetadata.ts b/packages/common/src/mvc/models/HandlerMetadata.ts index 51486a5d255..c98b06ec0f5 100644 --- a/packages/common/src/mvc/models/HandlerMetadata.ts +++ b/packages/common/src/mvc/models/HandlerMetadata.ts @@ -60,7 +60,7 @@ export class HandlerMetadata { parameters.push( new ParamMetadata({ index: 0, - paramType: ParamTypes.ERR, + paramType: ParamTypes.ERR }) ); } @@ -68,13 +68,13 @@ export class HandlerMetadata { parameters.push( new ParamMetadata({ index: parameters.length, - paramType: ParamTypes.REQUEST, + paramType: ParamTypes.REQUEST }) ); parameters.push( new ParamMetadata({ index: parameters.length, - paramType: ParamTypes.RESPONSE, + paramType: ParamTypes.RESPONSE }) ); @@ -82,7 +82,7 @@ export class HandlerMetadata { parameters.push( new ParamMetadata({ index: parameters.length, - paramType: ParamTypes.NEXT_FN, + paramType: ParamTypes.NEXT_FN }) ); } diff --git a/packages/common/src/mvc/models/ParamTypes.ts b/packages/common/src/mvc/models/ParamTypes.ts index ea4463b7595..78cadcd3c3f 100644 --- a/packages/common/src/mvc/models/ParamTypes.ts +++ b/packages/common/src/mvc/models/ParamTypes.ts @@ -13,5 +13,5 @@ export enum ParamTypes { COOKIES = "COOKIES", LOCALS = "LOCALS", SESSION = "SESSION", - FORM_DATA = "FORM_DATA", + FORM_DATA = "FORM_DATA" } diff --git a/packages/common/src/mvc/pipes/DeserializerPipe.spec.ts b/packages/common/src/mvc/pipes/DeserializerPipe.spec.ts index d186840190c..e92efb8d91b 100644 --- a/packages/common/src/mvc/pipes/DeserializerPipe.spec.ts +++ b/packages/common/src/mvc/pipes/DeserializerPipe.spec.ts @@ -22,7 +22,7 @@ describe("DeserializerPipe", () => { index: 0, target: Test, propertyKey: "test", - paramType: ParamTypes.REQUEST, + paramType: ParamTypes.REQUEST }); // @ts-ignore param._type = String; @@ -46,7 +46,7 @@ describe("DeserializerPipe", () => { index: 0, target: Test, propertyKey: "test", - paramType: ParamTypes.QUERY, + paramType: ParamTypes.QUERY }); // @ts-ignore param._type = String; diff --git a/packages/common/src/mvc/pipes/DeserializerPipe.ts b/packages/common/src/mvc/pipes/DeserializerPipe.ts index a86ea6530fd..14316f9ee48 100644 --- a/packages/common/src/mvc/pipes/DeserializerPipe.ts +++ b/packages/common/src/mvc/pipes/DeserializerPipe.ts @@ -9,7 +9,7 @@ export class DeserializerPipe implements IPipe { transform(value: any, param: ParamMetadata) { return this.converterService.deserialize(value, param.collectionType || param.type, param.type, { - additionalProperties: param.paramType === ParamTypes.QUERY ? "ignore" : undefined, + additionalProperties: param.paramType === ParamTypes.QUERY ? "ignore" : undefined }); } } diff --git a/packages/common/src/mvc/pipes/ParseExpressionPipe.spec.ts b/packages/common/src/mvc/pipes/ParseExpressionPipe.spec.ts index 15d316fb0de..d8f67b761ea 100644 --- a/packages/common/src/mvc/pipes/ParseExpressionPipe.spec.ts +++ b/packages/common/src/mvc/pipes/ParseExpressionPipe.spec.ts @@ -21,7 +21,7 @@ describe("ParseExpressionPipe", () => { target: Test, propertyKey: "test", expression: "test", - paramType: ParamTypes.REQUEST, + paramType: ParamTypes.REQUEST }); // @ts-ignore param._type = String; @@ -29,7 +29,7 @@ describe("ParseExpressionPipe", () => { // WHEN const value = pipe.transform( { - test: "value", + test: "value" }, param ); @@ -48,7 +48,7 @@ describe("ParseExpressionPipe", () => { target: Test, propertyKey: "test", expression: "test", - paramType: ParamTypes.REQUEST, + paramType: ParamTypes.REQUEST }); // @ts-ignore param._type = String; @@ -70,7 +70,7 @@ describe("ParseExpressionPipe", () => { target: Test, propertyKey: "test", expression: "Content-Type", - paramType: ParamTypes.HEADER, + paramType: ParamTypes.HEADER }); // @ts-ignore param._type = String; @@ -78,7 +78,7 @@ describe("ParseExpressionPipe", () => { // WHEN const value = pipe.transform( { - "content-type": "application/json", + "content-type": "application/json" }, param ); @@ -97,14 +97,14 @@ describe("ParseExpressionPipe", () => { target: Test, propertyKey: "test", expression: "test", - paramType: ParamTypes.QUERY, + paramType: ParamTypes.QUERY }); // @ts-ignore param._type = Boolean; // WHEN const value = pipe.transform( { - test: "", + test: "" }, param ); @@ -123,14 +123,14 @@ describe("ParseExpressionPipe", () => { target: Test, propertyKey: "test", expression: "test", - paramType: ParamTypes.QUERY, + paramType: ParamTypes.QUERY }); // @ts-ignore param._type = String; // WHEN const value = pipe.transform( { - test: "", + test: "" }, param ); @@ -149,14 +149,14 @@ describe("ParseExpressionPipe", () => { target: Test, propertyKey: "test", expression: "test", - paramType: ParamTypes.PATH, + paramType: ParamTypes.PATH }); // @ts-ignore param._type = Boolean; // WHEN const value = pipe.transform( { - test: "", + test: "" }, param ); @@ -175,14 +175,14 @@ describe("ParseExpressionPipe", () => { target: Test, propertyKey: "test", expression: "test", - paramType: ParamTypes.PATH, + paramType: ParamTypes.PATH }); // @ts-ignore param._type = String; // WHEN const value = pipe.transform( { - test: "", + test: "" }, param ); diff --git a/packages/common/src/mvc/pipes/ParseExpressionPipe.ts b/packages/common/src/mvc/pipes/ParseExpressionPipe.ts index cad66f13eb3..c59eb39fbcd 100644 --- a/packages/common/src/mvc/pipes/ParseExpressionPipe.ts +++ b/packages/common/src/mvc/pipes/ParseExpressionPipe.ts @@ -4,7 +4,7 @@ import {IPipe, ParamMetadata} from "../models/ParamMetadata"; import {ParamTypes} from "../models/ParamTypes"; @Injectable({ - priority: -1, + priority: -1 }) export class ParseExpressionPipe implements IPipe { transform(value: any, param: ParamMetadata) { diff --git a/packages/common/src/mvc/pipes/ValidationPipe.spec.ts b/packages/common/src/mvc/pipes/ValidationPipe.spec.ts index d197af3210d..f82e941b3c5 100644 --- a/packages/common/src/mvc/pipes/ValidationPipe.spec.ts +++ b/packages/common/src/mvc/pipes/ValidationPipe.spec.ts @@ -9,7 +9,7 @@ describe("ValidationPipe", () => { it("should return value", async () => { const validate = Sinon.stub(); const validator = new ValidationPipe({ - validate, + validate }); class Test {} @@ -18,7 +18,7 @@ describe("ValidationPipe", () => { index: 0, target: Test, propertyKey: "test", - paramType: ParamTypes.REQUEST, + paramType: ParamTypes.REQUEST }); // @ts-ignore param._type = String; @@ -35,7 +35,7 @@ describe("ValidationPipe", () => { const validator = new ValidationPipe({ validate() { throw error; - }, + } }); class Test { diff --git a/packages/common/src/mvc/pipes/ValidationPipe.ts b/packages/common/src/mvc/pipes/ValidationPipe.ts index 6ca1c5a1ff5..6f88cce48f4 100644 --- a/packages/common/src/mvc/pipes/ValidationPipe.ts +++ b/packages/common/src/mvc/pipes/ValidationPipe.ts @@ -4,7 +4,7 @@ import {IPipe, ParamMetadata} from "../models/ParamMetadata"; import {ValidationService} from "../services/ValidationService"; @Injectable({ - type: "validator", + type: "validator" }) export class ValidationPipe implements IPipe { constructor(protected validationService: ValidationService) {} diff --git a/packages/common/src/mvc/registries/FilterRegistry.ts b/packages/common/src/mvc/registries/FilterRegistry.ts index 85bd2536d0c..37d72ecfe00 100644 --- a/packages/common/src/mvc/registries/FilterRegistry.ts +++ b/packages/common/src/mvc/registries/FilterRegistry.ts @@ -6,7 +6,7 @@ import {GlobalProviders, Provider, ProviderType, TypedProvidersRegistry} from "@ */ // tslint:disable-next-line: variable-name export const FilterRegistry: TypedProvidersRegistry = GlobalProviders.createRegistry(ProviderType.FILTER, Provider, { - injectable: true, + injectable: true }); /** diff --git a/packages/common/src/mvc/registries/MiddlewareRegistry.ts b/packages/common/src/mvc/registries/MiddlewareRegistry.ts index 4c8bb7d1841..c710a2c053c 100644 --- a/packages/common/src/mvc/registries/MiddlewareRegistry.ts +++ b/packages/common/src/mvc/registries/MiddlewareRegistry.ts @@ -6,7 +6,7 @@ import {GlobalProviders, Provider, ProviderType, TypedProvidersRegistry} from "@ */ // tslint:disable-next-line: variable-name export const MiddlewareRegistry: TypedProvidersRegistry = GlobalProviders.createRegistry(ProviderType.MIDDLEWARE, Provider, { - injectable: true, + injectable: true }); /** * Add a new middleware in the `ProviderRegistry`. This middleware will be built when `InjectorService` will be loaded. diff --git a/packages/common/src/mvc/registries/ParamRegistry.ts b/packages/common/src/mvc/registries/ParamRegistry.ts index 07eb5c75ee0..23344638563 100644 --- a/packages/common/src/mvc/registries/ParamRegistry.ts +++ b/packages/common/src/mvc/registries/ParamRegistry.ts @@ -44,7 +44,7 @@ export class ParamRegistry extends ParamMetadata { param.expression && ParseExpressionPipe, useValidation && (param.type || param.collectionType) && ValidationPipe, useConverter && DeserializerPipe, - ...param.pipes, + ...param.pipes ].filter(Boolean) as Type[]; return param; diff --git a/packages/common/src/mvc/services/ParseService.spec.ts b/packages/common/src/mvc/services/ParseService.spec.ts index 263455ffdf2..81ec0a31715 100644 --- a/packages/common/src/mvc/services/ParseService.spec.ts +++ b/packages/common/src/mvc/services/ParseService.spec.ts @@ -19,7 +19,7 @@ describe("ParseService :", () => { it("should eval expression with a scope and return value", inject([ParseService], (parserService: ParseService) => { expect( parserService.eval(undefined!, { - test: "yes", + test: "yes" }).test ).to.equal("yes"); @@ -29,7 +29,7 @@ describe("ParseService :", () => { it("should eval expression with a scope and return value", inject([ParseService], (parserService: ParseService) => { expect( parserService.eval("test", { - test: "yes", + test: "yes" }) ).to.equal("yes"); })); @@ -37,7 +37,7 @@ describe("ParseService :", () => { it("should eval expression with a scope and return value", inject([ParseService], (parserService: ParseService) => { expect( parserService.eval("test.foo", { - test: "yes", + test: "yes" }) ).to.equal(undefined); })); @@ -45,8 +45,8 @@ describe("ParseService :", () => { it("should eval expression with a scope and return a new object", inject([ParseService], (parserService: ParseService) => { const scope = { test: { - foo: "yes", - }, + foo: "yes" + } }; const value = parserService.eval("test", scope); diff --git a/packages/common/src/mvc/services/ValidationService.spec.ts b/packages/common/src/mvc/services/ValidationService.spec.ts index d2f02d7c28c..215440da5d6 100644 --- a/packages/common/src/mvc/services/ValidationService.spec.ts +++ b/packages/common/src/mvc/services/ValidationService.spec.ts @@ -11,7 +11,7 @@ describe("ValidationService", () => { new ParamMetadata({ target: Test, propertyKey: "method", - index: 0, + index: 0 }) ) ).to.be.true; diff --git a/packages/common/src/mvc/utils/mapParamsOptions.spec.ts b/packages/common/src/mvc/utils/mapParamsOptions.spec.ts index 5a18fb8d739..0197c4d3296 100644 --- a/packages/common/src/mvc/utils/mapParamsOptions.spec.ts +++ b/packages/common/src/mvc/utils/mapParamsOptions.spec.ts @@ -23,7 +23,7 @@ describe("mapParamsOptions", () => { it("should return default params when params have an object", () => { expect(mapParamsOptions([{expression: "expression", useType: Test}])).to.deep.eq({ expression: "expression", - useType: Test, + useType: Test }); }); }); diff --git a/packages/common/src/mvc/utils/mapParamsOptions.ts b/packages/common/src/mvc/utils/mapParamsOptions.ts index 2abab68446f..cb85e3003db 100644 --- a/packages/common/src/mvc/utils/mapParamsOptions.ts +++ b/packages/common/src/mvc/utils/mapParamsOptions.ts @@ -5,13 +5,13 @@ export function mapParamsOptions(args: any[]): IParamOptions { if (args.length === 1) { if (isPrimitive(args[0])) { return { - expression: args[0], + expression: args[0] }; } if (!isObject(args[0])) { return { - useType: args[0], + useType: args[0] }; } @@ -20,6 +20,6 @@ export function mapParamsOptions(args: any[]): IParamOptions { return { expression: args[0], - useType: args[1], + useType: args[1] }; } diff --git a/packages/common/src/mvc/utils/mapReturnedResponse.spec.ts b/packages/common/src/mvc/utils/mapReturnedResponse.spec.ts index ab839b710ba..601e98dc783 100644 --- a/packages/common/src/mvc/utils/mapReturnedResponse.spec.ts +++ b/packages/common/src/mvc/utils/mapReturnedResponse.spec.ts @@ -8,13 +8,13 @@ describe("mapReturnedResponse", () => { description: "description", type: "type", collection: "collection", - headers: "headers", + headers: "headers" }) ).to.deep.eq({ description: "description", type: "type", collectionType: "collection", - headers: "headers", + headers: "headers" }); }); @@ -24,13 +24,13 @@ describe("mapReturnedResponse", () => { description: "description", use: "use", collection: "collection", - headers: "headers", + headers: "headers" }) ).to.deep.eq({ description: "description", type: "use", collectionType: "collection", - headers: "headers", + headers: "headers" }); }); }); diff --git a/packages/common/src/mvc/utils/mapReturnedResponse.ts b/packages/common/src/mvc/utils/mapReturnedResponse.ts index 0d521836008..f835462d72f 100644 --- a/packages/common/src/mvc/utils/mapReturnedResponse.ts +++ b/packages/common/src/mvc/utils/mapReturnedResponse.ts @@ -2,6 +2,6 @@ export function mapReturnedResponse({use, collection, ...options}: any): any { return { ...options, type: options.type || use, - collectionType: options.collectionType || collection, + collectionType: options.collectionType || collection }; } diff --git a/packages/common/src/platform-builder/builder/PlatformBuilder.spec.ts b/packages/common/src/platform-builder/builder/PlatformBuilder.spec.ts index 181739a6e6b..f5f903baa26 100644 --- a/packages/common/src/platform-builder/builder/PlatformBuilder.spec.ts +++ b/packages/common/src/platform-builder/builder/PlatformBuilder.spec.ts @@ -8,7 +8,7 @@ import { BeforeRoutesInit, Controller, InjectorService, - OnReady, + OnReady } from "@tsed/common"; import {Type} from "@tsed/core"; import {Configuration} from "@tsed/di"; @@ -35,11 +35,11 @@ describe("PlatformBuilder", () => { @Configuration({ logger: { - level: "off", + level: "off" }, mount: { - "/rest": [RestCtrl], - }, + "/rest": [RestCtrl] + } }) class ServerModule implements BeforeInit, AfterInit, BeforeRoutesInit, AfterRoutesInit, BeforeListen, AfterListen, OnReady { $onInit(): Promise | void { @@ -99,7 +99,7 @@ describe("PlatformBuilder", () => { // WHEN const server = await PlatformTest.bootstrap(ServerModule, { httpPort: false, - httpsPort: false, + httpsPort: false }); // THEN @@ -132,8 +132,8 @@ describe("PlatformBuilder", () => { expect(server.platform.addRoutes).to.have.been.calledWithExactly([ { route: "/rest", - token: RestCtrl, - }, + token: RestCtrl + } ]); }); }); @@ -154,7 +154,7 @@ describe("PlatformBuilder", () => { join(process.cwd(), "services/**/*.ts"), join(process.cwd(), "middlewares/**/*.ts"), join(process.cwd(), "converters/**/*.ts"), - MyClass, + MyClass ]); }); }); diff --git a/packages/common/src/platform-builder/builder/PlatformBuilder.ts b/packages/common/src/platform-builder/builder/PlatformBuilder.ts index 2c43bfa9820..3f2304477af 100644 --- a/packages/common/src/platform-builder/builder/PlatformBuilder.ts +++ b/packages/common/src/platform-builder/builder/PlatformBuilder.ts @@ -6,7 +6,7 @@ import { LogIncomingRequestMiddleware, Platform, PlatformApplication, - PlatformContextMiddleware, + PlatformContextMiddleware } from "../../platform"; import {GlobalErrorHandlerMiddleware, PlatformExceptionsMiddleware} from "../../platform-exceptions"; import {PlatformLogMiddleware} from "../../platform/middlewares/PlatformLogMiddleware"; @@ -21,7 +21,7 @@ import { listenHttpsServer, loadInjector, printRoutes, - setLoggerLevel, + setLoggerLevel } from "../utils"; /** diff --git a/packages/common/src/platform-builder/utils/createHttpServer.spec.ts b/packages/common/src/platform-builder/utils/createHttpServer.spec.ts index 61e55a26807..33def16b744 100644 --- a/packages/common/src/platform-builder/utils/createHttpServer.spec.ts +++ b/packages/common/src/platform-builder/utils/createHttpServer.spec.ts @@ -21,7 +21,7 @@ describe("createHttpServer", () => { injector.settings = { httpPort: true, getHttpPort: Sinon.stub().returns({address: "address", port: "port"}), - setHttpPort: Sinon.stub(), + setHttpPort: Sinon.stub() }; createHttpServer(injector); @@ -54,7 +54,7 @@ describe("createHttpServer", () => { injector.settings = { httpPort: 0, getHttpPort: Sinon.stub().returns({address: "address", port: 0}), - setHttpPort: Sinon.stub(), + setHttpPort: Sinon.stub() }; createHttpServer(injector); @@ -85,7 +85,7 @@ describe("createHttpServer", () => { injector.logger.stop(); // @ts-ignore injector.settings = { - httpPort: false, + httpPort: false }; createHttpServer(injector); diff --git a/packages/common/src/platform-builder/utils/createHttpServer.ts b/packages/common/src/platform-builder/utils/createHttpServer.ts index 067cbe83c8e..066dfdcc65e 100644 --- a/packages/common/src/platform-builder/utils/createHttpServer.ts +++ b/packages/common/src/platform-builder/utils/createHttpServer.ts @@ -15,7 +15,7 @@ registerProvider({ global: true, useFactory(platformApplication: PlatformApplication) { return Http.createServer(platformApplication.callback()); - }, + } }); export async function listenHttpServer(injector: InjectorService) { diff --git a/packages/common/src/platform-builder/utils/createHttpsServer.spec.ts b/packages/common/src/platform-builder/utils/createHttpsServer.spec.ts index 4319dc59984..10c0a30145c 100644 --- a/packages/common/src/platform-builder/utils/createHttpsServer.spec.ts +++ b/packages/common/src/platform-builder/utils/createHttpsServer.spec.ts @@ -20,7 +20,7 @@ describe("createHttpsServer", () => { injector.settings = { httpsPort: true, getHttpsPort: Sinon.stub().returns({address: "address", port: "port"}), - setHttpsPort: Sinon.stub(), + setHttpsPort: Sinon.stub() }; createHttpsServer(injector); @@ -54,7 +54,7 @@ describe("createHttpsServer", () => { injector.settings = { httpsPort: 0, getHttpsPort: Sinon.stub().returns({address: "address", port: "port"}), - setHttpsPort: Sinon.stub(), + setHttpsPort: Sinon.stub() }; createHttpsServer(injector); @@ -86,7 +86,7 @@ describe("createHttpsServer", () => { injector.logger.stop(); // @ts-ignore injector.settings = { - httpsPort: false, + httpsPort: false }; createHttpsServer(injector); diff --git a/packages/common/src/platform-builder/utils/createHttpsServer.ts b/packages/common/src/platform-builder/utils/createHttpsServer.ts index befe846943a..26a3f567af6 100644 --- a/packages/common/src/platform-builder/utils/createHttpsServer.ts +++ b/packages/common/src/platform-builder/utils/createHttpsServer.ts @@ -17,7 +17,7 @@ registerProvider({ const options = settings.httpsOptions!; return Https.createServer(options, platformApplication.callback()); - }, + } }); export async function listenHttpsServer(injector: InjectorService) { diff --git a/packages/common/src/platform-builder/utils/createInjector.spec.ts b/packages/common/src/platform-builder/utils/createInjector.spec.ts index b548153420c..fc6b32ffd05 100644 --- a/packages/common/src/platform-builder/utils/createInjector.spec.ts +++ b/packages/common/src/platform-builder/utils/createInjector.spec.ts @@ -15,7 +15,7 @@ describe("createInjector", () => { it("should create injector and stop logger in env Test", () => { const settings = { test: "test", - env: Env.TEST, + env: Env.TEST }; const injector = createInjector(settings); @@ -29,7 +29,7 @@ describe("createInjector", () => { it("should create injector", () => { const settings = { test: "test", - env: Env.PROD, + env: Env.PROD }; const injector = createInjector(settings); diff --git a/packages/common/src/platform-builder/utils/getConfiguration.spec.ts b/packages/common/src/platform-builder/utils/getConfiguration.spec.ts index 56087447143..a48e584fee1 100644 --- a/packages/common/src/platform-builder/utils/getConfiguration.spec.ts +++ b/packages/common/src/platform-builder/utils/getConfiguration.spec.ts @@ -7,29 +7,29 @@ describe("getConfiguration", () => { class MyModule {} expect(getConfiguration(MyModule)).to.deep.eq({ - test: "test", + test: "test" }); }); it("should return configuration (2)", () => { @Configuration({ mount: { - "/v1": ["/root1/*.ts"], + "/v1": ["/root1/*.ts"] }, - componentsScan: ["/root1-services/*.ts"], + componentsScan: ["/root1-services/*.ts"] }) class MyModule {} expect( getConfiguration(MyModule, { mount: { - "/v2": ["/root2/*.ts"], + "/v2": ["/root2/*.ts"] }, - componentsScan: ["/root2-services/*.ts"], + componentsScan: ["/root2-services/*.ts"] }) ).to.deep.eq({ componentsScan: ["/root2-services/*.ts"], - mount: ["/root1-services/*.ts", "/root2-services/*.ts"], + mount: ["/root1-services/*.ts", "/root2-services/*.ts"] }); }); }); diff --git a/packages/common/src/platform-builder/utils/getConfiguration.ts b/packages/common/src/platform-builder/utils/getConfiguration.ts index 0b3808a0fec..69d9fa9cc29 100644 --- a/packages/common/src/platform-builder/utils/getConfiguration.ts +++ b/packages/common/src/platform-builder/utils/getConfiguration.ts @@ -5,7 +5,7 @@ export function getConfiguration(module: Type, configuration: any = {}) { const config = { ...store, - ...configuration, + ...configuration }; if (store.mount && configuration.mount) { diff --git a/packages/common/src/platform-builder/utils/importComponents.spec.ts b/packages/common/src/platform-builder/utils/importComponents.spec.ts index 879b958103f..694cf3a2983 100644 --- a/packages/common/src/platform-builder/utils/importComponents.spec.ts +++ b/packages/common/src/platform-builder/utils/importComponents.spec.ts @@ -16,19 +16,19 @@ describe("importComponents", () => { expect(symbols).to.deep.eq([ { route: undefined, - token: Test1, + token: Test1 }, { route: undefined, - token: Test2, - }, + token: Test2 + } ]); }); it("should import symbols with endpoints", async () => { // GIVEN const config = { - "/path/to/endpoint": join(__dirname, "data/*.ts"), + "/path/to/endpoint": join(__dirname, "data/*.ts") }; // WHEN @@ -38,12 +38,12 @@ describe("importComponents", () => { expect(symbols).to.deep.eq([ { route: "/path/to/endpoint", - token: Test1, + token: Test1 }, { route: "/path/to/endpoint", - token: Test2, - }, + token: Test2 + } ]); }); }); diff --git a/packages/common/src/platform-builder/utils/importComponents.ts b/packages/common/src/platform-builder/utils/importComponents.ts index 6287baa2fee..fb569b1ddcf 100644 --- a/packages/common/src/platform-builder/utils/importComponents.ts +++ b/packages/common/src/platform-builder/utils/importComponents.ts @@ -19,7 +19,7 @@ export function mapConfiguration(config: any): {endpoint?: string; values: any[] if (isArray(config)) { return config.map((value: any) => { return { - values: [].concat(value), + values: [].concat(value) }; }); } @@ -27,7 +27,7 @@ export function mapConfiguration(config: any): {endpoint?: string; values: any[] return Object.keys(config).reduce((list: any[], key: string) => { list.push({ endpoint: key, - values: [].concat(config[key]), + values: [].concat(config[key]) }); return list; diff --git a/packages/common/src/platform-builder/utils/importProviders.ts b/packages/common/src/platform-builder/utils/importProviders.ts index 401980537bd..6f169754f3e 100644 --- a/packages/common/src/platform-builder/utils/importProviders.ts +++ b/packages/common/src/platform-builder/utils/importProviders.ts @@ -14,7 +14,7 @@ async function importAll(settings: any): Promise[]> { const results = await Promise.all([ importComponents(settings.imports, settings.exclude), importComponents(settings.mount, settings.exclude), - importComponents(settings.componentsScan, settings.exclude), + importComponents(settings.componentsScan, settings.exclude) ]); const providers: IProvider[] = ([] as any).concat(...results); diff --git a/packages/common/src/platform-builder/utils/printRoutes.ts b/packages/common/src/platform-builder/utils/printRoutes.ts index 6188cdafa70..8b57f62f85d 100644 --- a/packages/common/src/platform-builder/utils/printRoutes.ts +++ b/packages/common/src/platform-builder/utils/printRoutes.ts @@ -8,7 +8,7 @@ export function printRoutes(routes: IRouteDetails[]) { PUT: "blue", DELETE: "red", PATCH: "magenta", - ALL: "cyan", + ALL: "cyan" }; routes = routes.map((route) => { @@ -18,7 +18,7 @@ export function printRoutes(routes: IRouteDetails[]) { length: method.length, toString: () => { return colorize(method, mapColor[method]); - }, + } } as any; return route; @@ -29,8 +29,8 @@ export function printRoutes(routes: IRouteDetails[]) { header: { method: "Method", url: "Endpoint", - name: "Class method", - }, + name: "Class method" + } }); return "\n" + str.trim(); diff --git a/packages/common/src/platform-exceptions/middlewares/GlobalErrorHandlerMiddleware.spec.ts b/packages/common/src/platform-exceptions/middlewares/GlobalErrorHandlerMiddleware.spec.ts index 5fa77505dbe..c54ec4dc643 100644 --- a/packages/common/src/platform-exceptions/middlewares/GlobalErrorHandlerMiddleware.spec.ts +++ b/packages/common/src/platform-exceptions/middlewares/GlobalErrorHandlerMiddleware.spec.ts @@ -41,7 +41,7 @@ describe("GlobalErrorHandlerMiddleware", () => { request.ctx = PlatformTest.createRequestContext({ response: new PlatformResponse(response as any), - request: new PlatformRequest(request as any), + request: new PlatformRequest(request as any) }); // @ts-ignore diff --git a/packages/common/src/platform-exceptions/middlewares/GlobalErrorHandlerMiddleware.ts b/packages/common/src/platform-exceptions/middlewares/GlobalErrorHandlerMiddleware.ts index b454d505e0c..8f25c4938a0 100644 --- a/packages/common/src/platform-exceptions/middlewares/GlobalErrorHandlerMiddleware.ts +++ b/packages/common/src/platform-exceptions/middlewares/GlobalErrorHandlerMiddleware.ts @@ -31,8 +31,8 @@ export class GlobalErrorHandlerMiddleware implements IMiddleware { message: error.message, stack: error.stack, status: error.status, - origin: error.origin, - }, + origin: error.origin + } }); this.setHeaders(response, error, error.origin); @@ -53,8 +53,8 @@ export class GlobalErrorHandlerMiddleware implements IMiddleware { status: 500, message: error.message, stack: error.stack, - origin: error.origin, - }, + origin: error.origin + } }); this.setHeaders(response, error, error.origin); diff --git a/packages/common/src/platform-exceptions/middlewares/PlatformExceptionsMiddleware.spec.ts b/packages/common/src/platform-exceptions/middlewares/PlatformExceptionsMiddleware.spec.ts index f266d137a90..58734567bed 100644 --- a/packages/common/src/platform-exceptions/middlewares/PlatformExceptionsMiddleware.spec.ts +++ b/packages/common/src/platform-exceptions/middlewares/PlatformExceptionsMiddleware.spec.ts @@ -20,7 +20,7 @@ describe("PlatformExceptionsMiddleware", () => { const ctx = PlatformTest.createRequestContext({ response: new PlatformResponse(response as any), - request: new PlatformRequest(request as any), + request: new PlatformRequest(request as any) }); let actualError: any; @@ -45,7 +45,7 @@ describe("PlatformExceptionsMiddleware", () => { const ctx = PlatformTest.createRequestContext({ response: new PlatformResponse(response as any), - request: new PlatformRequest(request as any), + request: new PlatformRequest(request as any) }); // @ts-ignore middleware.use(error, ctx); diff --git a/packages/common/src/platform-express/components/ServerLoader.spec.ts b/packages/common/src/platform-express/components/ServerLoader.spec.ts index dee3b22975d..944c765ac58 100644 --- a/packages/common/src/platform-express/components/ServerLoader.spec.ts +++ b/packages/common/src/platform-express/components/ServerLoader.spec.ts @@ -8,7 +8,7 @@ function createServer() { debug: true, port: 8000, httpsPort: 8080, - imports: [class Test {}], + imports: [class Test {}] }) class TestServer extends ServerLoader { $onInit() {} @@ -165,7 +165,7 @@ describe("ServerLoader", () => { // WHEN const server = await ServerLoader.bootstrap(TestServer, { - ownSettings: "test", + ownSettings: "test" }); server.scan(["/rest"], "/rest"); diff --git a/packages/common/src/platform-express/components/ServerLoader.ts b/packages/common/src/platform-express/components/ServerLoader.ts index 5482c4fec68..616f551cb7e 100644 --- a/packages/common/src/platform-express/components/ServerLoader.ts +++ b/packages/common/src/platform-express/components/ServerLoader.ts @@ -11,7 +11,7 @@ import { HttpsServer, importProviders, PlatformBuilder, - setLoggerLevel, + setLoggerLevel } from "../../platform-builder"; import {GlobalErrorHandlerMiddleware, PlatformExceptionsMiddleware} from "../../platform-exceptions"; import {LogIncomingRequestMiddleware} from "../../platform/middlewares/LogIncomingRequestMiddleware"; diff --git a/packages/common/src/platform-express/services/PlatformExpressRouter.spec.ts b/packages/common/src/platform-express/services/PlatformExpressRouter.spec.ts index 8f2ce234ba1..21790c5bb70 100644 --- a/packages/common/src/platform-express/services/PlatformExpressRouter.spec.ts +++ b/packages/common/src/platform-express/services/PlatformExpressRouter.spec.ts @@ -26,26 +26,26 @@ describe("PlatformExpressRouter", () => { delete: sandbox.stub(), patch: sandbox.stub(), head: sandbox.stub(), - options: sandbox.stub(), + options: sandbox.stub() }; stub(Express.Router).returns(nativeDriver); const platformHandler = { - createHandler: sandbox.stub().callsFake((o) => o), + createHandler: sandbox.stub().callsFake((o) => o) }; const injector = new InjectorService(); injector.addProvider(PlatformHandler, { - useValue: platformHandler, + useValue: platformHandler }); injector.addProvider(PlatformRouter); injector.settings.routers = { - mergeParams: true, + mergeParams: true }; const routerOptions: any = { - test: "options", + test: "options" }; // WHEN diff --git a/packages/common/src/platform-express/services/ServeStaticService.spec.ts b/packages/common/src/platform-express/services/ServeStaticService.spec.ts index 233fb44f359..108ae3a9439 100644 --- a/packages/common/src/platform-express/services/ServeStaticService.spec.ts +++ b/packages/common/src/platform-express/services/ServeStaticService.spec.ts @@ -25,32 +25,32 @@ describe("ServeStaticService", () => { it("should call the express use method", async () => { // GIVEN const request = { - test: "request", + test: "request" }; const response = { - headersSent: false, + headersSent: false }; const nextSpy = sandbox.spy(); const middlewareServeStatic = sandbox.stub(); const platformApp = { - use: sandbox.stub(), + use: sandbox.stub() }; const serverSettingService = { statics: { - "/path": "/views", - }, + "/path": "/views" + } }; const serveStaticService = await PlatformTest.invoke(ServeStaticService, [ { token: PlatformApplication, - use: platformApp, + use: platformApp }, { token: ServerSettingsService, - use: serverSettingService, - }, + use: serverSettingService + } ]); // @ts-ignore @@ -73,32 +73,32 @@ describe("ServeStaticService", () => { it("should call the express use method", async () => { // GIVEN const request = { - test: "request", + test: "request" }; const response = { - headersSent: true, + headersSent: true }; const nextSpy = sandbox.spy(); const middlewareServeStatic = sandbox.stub(); const platformApp = { - use: sandbox.stub(), + use: sandbox.stub() }; const serverSettingService = { statics: { - "/path": "/views", - }, + "/path": "/views" + } }; const serveStaticService = await PlatformTest.invoke(ServeStaticService, [ { token: PlatformApplication, - use: platformApp, + use: platformApp }, { token: ServerSettingsService, - use: serverSettingService, - }, + use: serverSettingService + } ]); // @ts-ignore diff --git a/packages/common/src/platform-express/utils/createExpressApplication.ts b/packages/common/src/platform-express/utils/createExpressApplication.ts index 0680e732334..9dcd821c19d 100644 --- a/packages/common/src/platform-express/utils/createExpressApplication.ts +++ b/packages/common/src/platform-express/utils/createExpressApplication.ts @@ -13,5 +13,5 @@ registerProvider({ global: true, useFactory(platformApplication: PlatformApplication) { return platformApplication.raw; - }, + } }); diff --git a/packages/common/src/platform-test/components/PlatformTest.spec.ts b/packages/common/src/platform-test/components/PlatformTest.spec.ts index 315c4a04746..9535c68d588 100644 --- a/packages/common/src/platform-test/components/PlatformTest.spec.ts +++ b/packages/common/src/platform-test/components/PlatformTest.spec.ts @@ -11,7 +11,7 @@ import { LogIncomingRequestMiddleware, PlatformBuilder, PlatformTest, - RequestContext, + RequestContext } from "@tsed/common"; import {Type} from "@tsed/core"; import {expect} from "chai"; @@ -61,8 +61,8 @@ describe("PlatformTest", () => { beforeEach( PlatformTest.bootstrap(Server, { mount: { - "/rest": [MyController], - }, + "/rest": [MyController] + } }) ); beforeEach(() => { diff --git a/packages/common/src/platform-test/components/PlatformTest.ts b/packages/common/src/platform-test/components/PlatformTest.ts index 07e11a050f0..cefc904bf03 100644 --- a/packages/common/src/platform-test/components/PlatformTest.ts +++ b/packages/common/src/platform-test/components/PlatformTest.ts @@ -64,9 +64,9 @@ export class PlatformTest { if (isInheritedFrom(mod, ServerLoader)) { instance = await ServerLoader.bootstrap(mod, { logger: { - level: "off", + level: "off" }, - ...options, + ...options }); } else { PlatformTest.platformBuilder = options.platform || PlatformTest.platformBuilder; @@ -81,9 +81,9 @@ export class PlatformTest { // @ts-ignore instance = await PlatformBuilder.build(PlatformTest.platformBuilder).bootstrap(mod, { logger: { - level: "off", + level: "off" }, - ...options, + ...options }); } @@ -192,7 +192,7 @@ export class PlatformTest { id: "id", logger: this.injector.logger, url: "/", - ...options, + ...options }); } } diff --git a/packages/common/src/platform/PlatformModule.ts b/packages/common/src/platform/PlatformModule.ts index d35210021a2..cc50a8b8cee 100644 --- a/packages/common/src/platform/PlatformModule.ts +++ b/packages/common/src/platform/PlatformModule.ts @@ -4,7 +4,7 @@ import {Platform} from "./services/Platform"; import {RouteService} from "./services/RouteService"; @Module({ - imports: [InjectorService, MvcModule, Platform, RouteService], + imports: [InjectorService, MvcModule, Platform, RouteService] }) export class PlatformModule { constructor(platform: Platform) { diff --git a/packages/common/src/platform/builder/PlatformControllerBuilder.spec.ts b/packages/common/src/platform/builder/PlatformControllerBuilder.spec.ts index bb2a3e5911a..88004f0b7e3 100644 --- a/packages/common/src/platform/builder/PlatformControllerBuilder.spec.ts +++ b/packages/common/src/platform/builder/PlatformControllerBuilder.spec.ts @@ -21,7 +21,7 @@ function getControllerBuilder({propertyKey = "test", withMiddleware = true}: any get: use, use, post: use, - all: use, + all: use }; // @ts-ignore @@ -30,16 +30,16 @@ function getControllerBuilder({propertyKey = "test", withMiddleware = true}: any const injector = new InjectorService(); injector.addProvider(PlatformRouter, { - useClass: PlatformRouter, + useClass: PlatformRouter }); injector.addProvider(PlatformHandler, { - useClass: PlatformHandler, + useClass: PlatformHandler }); injector.addProvider(PlatformApplication, { - useClass: PlatformApplication, + useClass: PlatformApplication }); injector.addProvider(Platform, { - useClass: Platform, + useClass: Platform }); const provider = new ControllerProvider(TestCtrl); @@ -48,7 +48,7 @@ function getControllerBuilder({propertyKey = "test", withMiddleware = true}: any provider.middlewares = { use: [function controllerUse() {}], useAfter: [function controllerAfter() {}], - useBefore: [function controllerBefore() {}], + useBefore: [function controllerBefore() {}] }; } @@ -87,7 +87,7 @@ describe("ControllerBuilder", () => { endpoint.pathsMethods.push({ path: "/", method: "get", - isFinal: true, + isFinal: true }); // WHEN @@ -119,7 +119,7 @@ describe("ControllerBuilder", () => { const {endpoint, controllerBuilder, provider, router, injector} = getControllerBuilder(); endpoint.pathsMethods.push({ - path: "/", + path: "/" }); // WHEN @@ -173,20 +173,20 @@ describe("ControllerBuilder", () => { // GIVEN const {endpoint, controllerBuilder, router, injector, TestCtrl} = getControllerBuilder({ propertyKey: "getMethod", - withMiddleware: false, + withMiddleware: false }); endpoint.pathsMethods.push({ method: "get", path: "/", - isFinal: true, + isFinal: true }); const endpointAll = new EndpointMetadata({target: TestCtrl, propertyKey: "allMethod"}); endpointAll.pathsMethods.push({ method: "all", path: "/", - isFinal: true, + isFinal: true }); // @ts-ignore diff --git a/packages/common/src/platform/builder/PlatformControllerBuilder.ts b/packages/common/src/platform/builder/PlatformControllerBuilder.ts index a09fa20c2a3..18d6479f4f1 100644 --- a/packages/common/src/platform/builder/PlatformControllerBuilder.ts +++ b/packages/common/src/platform/builder/PlatformControllerBuilder.ts @@ -19,7 +19,7 @@ export class PlatformControllerBuilder { public build(injector: InjectorService): IPlatformDriver { const { routerOptions, - middlewares: {useBefore, useAfter}, + middlewares: {useBefore, useAfter} } = this.provider; this.provider.router = PlatformRouter.create(injector, routerOptions); @@ -72,7 +72,7 @@ export class PlatformControllerBuilder { const {beforeMiddlewares, middlewares: mldwrs, afterMiddlewares, pathsMethods} = endpoint; const { router, - middlewares: {use}, + middlewares: {use} } = this.provider; // Endpoint lifecycle let handlers: any[] = []; diff --git a/packages/common/src/platform/decorators/context.ts b/packages/common/src/platform/decorators/context.ts index 2773b07f9fb..88d3ed7e780 100644 --- a/packages/common/src/platform/decorators/context.ts +++ b/packages/common/src/platform/decorators/context.ts @@ -62,7 +62,7 @@ export function Context(...args: any[]): ParameterDecorator { expression, useType, useConverter, - useValidation, + useValidation }); } diff --git a/packages/common/src/platform/domain/ControllerProvider.spec.ts b/packages/common/src/platform/domain/ControllerProvider.spec.ts index da7bd1c0072..57fdb50f3f2 100644 --- a/packages/common/src/platform/domain/ControllerProvider.spec.ts +++ b/packages/common/src/platform/domain/ControllerProvider.spec.ts @@ -19,7 +19,7 @@ describe("ControllerProvider", () => { controllerProvider.middlewares = { useBefore: [new Function()], use: [new Function()], - useAfter: [new Function()], + useAfter: [new Function()] }; }); @@ -37,7 +37,7 @@ describe("ControllerProvider", () => { "imports", "useFactory", "useAsyncFactory", - "useValue", + "useValue" ]); }); diff --git a/packages/common/src/platform/domain/ControllerProvider.ts b/packages/common/src/platform/domain/ControllerProvider.ts index 79c7511db90..c80fc44ca34 100644 --- a/packages/common/src/platform/domain/ControllerProvider.ts +++ b/packages/common/src/platform/domain/ControllerProvider.ts @@ -88,7 +88,7 @@ export class ControllerProvider extends Provider { { use: [], useAfter: [], - useBefore: [], + useBefore: [] }, this.store.get("middlewares") || {} ); diff --git a/packages/common/src/platform/domain/HandlerContext.spec.ts b/packages/common/src/platform/domain/HandlerContext.spec.ts index 90b0d11ca34..7ce660e95f8 100644 --- a/packages/common/src/platform/domain/HandlerContext.spec.ts +++ b/packages/common/src/platform/domain/HandlerContext.spec.ts @@ -45,10 +45,10 @@ class Test { return { data: "data", headers: { - "Content-Type": "type", + "Content-Type": "type" }, status: 200, - statusText: "OK", + statusText: "OK" }; } @@ -67,7 +67,7 @@ async function getHandlerContext({token, propertyKey, args}: any = {}) { target: token, token, propertyKey, - type: HandlerType.CONTROLLER, + type: HandlerType.CONTROLLER }); const request: any = new FakeRequest(); const response: any = new FakeResponse(); @@ -79,7 +79,7 @@ async function getHandlerContext({token, propertyKey, args}: any = {}) { request, response, args, - next, + next }); return { @@ -94,7 +94,7 @@ async function getHandlerContext({token, propertyKey, args}: any = {}) { } handlerContext.callHandler().catch((err) => handlerContext.next(err)); }); - }, + } }; } @@ -103,7 +103,7 @@ describe("HandlerContext", () => { const {request, run, handlerContext} = await getHandlerContext({ token: Test, propertyKey: "getValue", - args: ["value"], + args: ["value"] }); Sinon.spy(handlerContext, "handle"); @@ -130,7 +130,7 @@ describe("HandlerContext", () => { const {request, run, handlerContext} = await getHandlerContext({ token: Test, propertyKey: "catchError", - args: ["value"], + args: ["value"] }); Sinon.spy(handlerContext, "handle"); @@ -157,7 +157,7 @@ describe("HandlerContext", () => { const {request, run} = await getHandlerContext({ token: Test, propertyKey: "getValueWithPromise", - args: ["value"], + args: ["value"] }); // WHEN @@ -171,7 +171,7 @@ describe("HandlerContext", () => { const {run, request} = await getHandlerContext({ token: Test, propertyKey: "getBuffer", - args: ["value"], + args: ["value"] }); // WHEN @@ -186,7 +186,7 @@ describe("HandlerContext", () => { const {run, request} = await getHandlerContext({ token: Test, propertyKey: "getStream", - args: ["value"], + args: ["value"] }); // WHEN @@ -200,7 +200,7 @@ describe("HandlerContext", () => { const {run, request} = await getHandlerContext({ token: Test, propertyKey: "getResponse", - args: ["value"], + args: ["value"] }); // WHEN @@ -214,7 +214,7 @@ describe("HandlerContext", () => { const {run, request} = await getHandlerContext({ token: Test, propertyKey: "getObservable", - args: ["value"], + args: ["value"] }); // WHEN @@ -228,7 +228,7 @@ describe("HandlerContext", () => { const {run} = await getHandlerContext({ token: Test, propertyKey: "returnMiddleware", - args: ["value"], + args: ["value"] }); // WHEN @@ -241,7 +241,7 @@ describe("HandlerContext", () => { const {run, request} = await getHandlerContext({ token: Test, propertyKey: "empty", - args: ["value"], + args: ["value"] }); // WHEN @@ -255,7 +255,7 @@ describe("HandlerContext", () => { const {run, request, handlerContext, response} = await getHandlerContext({ token: Test, propertyKey: "getValue", - args: [], + args: [] }); handlerContext.args = [response]; @@ -270,7 +270,7 @@ describe("HandlerContext", () => { const {run, request, handlerContext, response} = await getHandlerContext({ token: Test, propertyKey: "responseHeadersSent", - args: [], + args: [] }); handlerContext.args = [response]; @@ -286,7 +286,7 @@ describe("HandlerContext", () => { const {request, handlerContext} = await getHandlerContext({ token: Test, propertyKey: "getValue", - args: [], + args: [] }); request.aborted = true; @@ -302,7 +302,7 @@ describe("HandlerContext", () => { const {handlerContext} = await getHandlerContext({ token: Test, propertyKey: "getValue", - args: [], + args: [] }); // @ts-ignore @@ -319,7 +319,7 @@ describe("HandlerContext", () => { const {handlerContext} = await getHandlerContext({ token: Test, propertyKey: "getValue", - args: [], + args: [] }); // @ts-ignore diff --git a/packages/common/src/platform/domain/HandlerContext.ts b/packages/common/src/platform/domain/HandlerContext.ts index 9b99811598d..c91c41c8fc9 100644 --- a/packages/common/src/platform/domain/HandlerContext.ts +++ b/packages/common/src/platform/domain/HandlerContext.ts @@ -65,7 +65,7 @@ export class HandlerContext { const { metadata: {hasNextFunction}, - request: {ctx}, + request: {ctx} } = this; if (error) { @@ -89,7 +89,7 @@ export class HandlerContext { metadata: {hasNextFunction}, request, response, - next, + next } = this; if (process) { diff --git a/packages/common/src/platform/domain/RequestContext.spec.ts b/packages/common/src/platform/domain/RequestContext.spec.ts index 9ddb6939cb8..2bd0a619a6c 100644 --- a/packages/common/src/platform/domain/RequestContext.spec.ts +++ b/packages/common/src/platform/domain/RequestContext.spec.ts @@ -14,7 +14,7 @@ describe("RequestContext", () => { id: "id", injector: PlatformTest.injector, response: new PlatformResponse(res), - request: new PlatformRequest(req), + request: new PlatformRequest(req) }); expect(context.id).to.eq("id"); diff --git a/packages/common/src/platform/domain/RequestContext.ts b/packages/common/src/platform/domain/RequestContext.ts index 9e7548d8d46..c0593e982c0 100644 --- a/packages/common/src/platform/domain/RequestContext.ts +++ b/packages/common/src/platform/domain/RequestContext.ts @@ -88,7 +88,7 @@ export class RequestContext extends Map { this.logger = new RequestLogger(logger, { id, startDate: this.dateStart, - ...options, + ...options }); } diff --git a/packages/common/src/platform/domain/RequestLogger.spec.ts b/packages/common/src/platform/domain/RequestLogger.spec.ts index 49aaa701ab5..11773a091c7 100644 --- a/packages/common/src/platform/domain/RequestLogger.spec.ts +++ b/packages/common/src/platform/domain/RequestLogger.spec.ts @@ -9,7 +9,7 @@ describe("RequestLogger", () => { debug: Sinon.stub(), warn: Sinon.stub(), error: Sinon.stub(), - trace: Sinon.stub(), + trace: Sinon.stub() }; const requestLogger = new RequestLogger(logger, { @@ -18,7 +18,7 @@ describe("RequestLogger", () => { url: "/url", ignoreUrlPatterns: ["/admin"], minimalRequestPicker: (o: any) => ({...o, minimal: "minimal"}), - completeRequestPicker: (o: any) => ({...o, complete: "complete"}), + completeRequestPicker: (o: any) => ({...o, complete: "complete"}) }); Sinon.stub(requestLogger as any, "getDuration").returns(1); @@ -39,42 +39,42 @@ describe("RequestLogger", () => { duration: 1, reqId: "id", test: "test", - time: Sinon.match.instanceOf(Date), + time: Sinon.match.instanceOf(Date) }); expect(logger.info).to.have.been.calledWithExactly({ minimal: "minimal", duration: 1, reqId: "id", message: "message", - time: Sinon.match.instanceOf(Date), + time: Sinon.match.instanceOf(Date) }); expect(logger.debug).to.have.been.calledWithExactly({ complete: "complete", duration: 1, reqId: "id", test: "test", - time: Sinon.match.instanceOf(Date), + time: Sinon.match.instanceOf(Date) }); expect(logger.warn).to.have.been.calledWithExactly({ complete: "complete", duration: 1, reqId: "id", test: "test", - time: Sinon.match.instanceOf(Date), + time: Sinon.match.instanceOf(Date) }); expect(logger.error).to.have.been.calledWithExactly({ complete: "complete", duration: 1, reqId: "id", test: "test", - time: Sinon.match.instanceOf(Date), + time: Sinon.match.instanceOf(Date) }); expect(logger.trace).to.have.been.calledWithExactly({ complete: "complete", duration: 1, reqId: "id", test: "test", - time: Sinon.match.instanceOf(Date), + time: Sinon.match.instanceOf(Date) }); }); it("should create a new Context and log all (with minimalRequestPicker)", () => { @@ -83,14 +83,14 @@ describe("RequestLogger", () => { debug: Sinon.stub(), warn: Sinon.stub(), error: Sinon.stub(), - trace: Sinon.stub(), + trace: Sinon.stub() }; const requestLogger = new RequestLogger(logger, { id: "id", startDate: new Date("2019-01-01"), url: "/url", - ignoreUrlPatterns: ["/admin"], + ignoreUrlPatterns: ["/admin"] }); Sinon.stub(requestLogger as any, "getDuration").returns(1); @@ -110,37 +110,37 @@ describe("RequestLogger", () => { duration: 1, reqId: "id", test: "test", - time: Sinon.match.instanceOf(Date), + time: Sinon.match.instanceOf(Date) }); expect(logger.info).to.have.been.calledWithExactly({ duration: 1, reqId: "id", message: "message", - time: Sinon.match.instanceOf(Date), + time: Sinon.match.instanceOf(Date) }); expect(logger.debug).to.have.been.calledWithExactly({ duration: 1, reqId: "id", test: "test", - time: Sinon.match.instanceOf(Date), + time: Sinon.match.instanceOf(Date) }); expect(logger.warn).to.have.been.calledWithExactly({ duration: 1, reqId: "id", test: "test", - time: Sinon.match.instanceOf(Date), + time: Sinon.match.instanceOf(Date) }); expect(logger.error).to.have.been.calledWithExactly({ duration: 1, reqId: "id", test: "test", - time: Sinon.match.instanceOf(Date), + time: Sinon.match.instanceOf(Date) }); expect(logger.trace).to.have.been.calledWithExactly({ duration: 1, reqId: "id", test: "test", - time: Sinon.match.instanceOf(Date), + time: Sinon.match.instanceOf(Date) }); }); it("should create a new Context and log nothing when pattern match with url", () => { @@ -149,7 +149,7 @@ describe("RequestLogger", () => { debug: Sinon.stub(), warn: Sinon.stub(), error: Sinon.stub(), - trace: Sinon.stub(), + trace: Sinon.stub() }; const requestLogger = new RequestLogger(logger, { @@ -158,7 +158,7 @@ describe("RequestLogger", () => { url: "/admin", ignoreUrlPatterns: ["/admin"], minimalRequestPicker: (o: any) => ({...o, minimal: "minimal"}), - completeRequestPicker: (o: any) => ({...o, complete: "complete"}), + completeRequestPicker: (o: any) => ({...o, complete: "complete"}) }); Sinon.stub(requestLogger as any, "getDuration").returns(1); @@ -176,7 +176,7 @@ describe("RequestLogger", () => { debug: Sinon.stub(), warn: Sinon.stub(), error: Sinon.stub(), - trace: Sinon.stub(), + trace: Sinon.stub() }; const requestLogger = new RequestLogger(logger, { @@ -185,7 +185,7 @@ describe("RequestLogger", () => { url: "/admin", maxStackSize: 2, minimalRequestPicker: (o: any) => ({...o, minimal: "minimal"}), - completeRequestPicker: (o: any) => ({...o, complete: "complete"}), + completeRequestPicker: (o: any) => ({...o, complete: "complete"}) }); Sinon.stub(requestLogger as any, "getDuration").returns(1); diff --git a/packages/common/src/platform/errors/ParamValidationError.spec.ts b/packages/common/src/platform/errors/ParamValidationError.spec.ts index 3701fb27f3c..eb1eae86d50 100644 --- a/packages/common/src/platform/errors/ParamValidationError.spec.ts +++ b/packages/common/src/platform/errors/ParamValidationError.spec.ts @@ -9,7 +9,7 @@ describe("ParseExpressionError", () => { const error = ParamValidationError.from( { service: "name", - expression: "expression", + expression: "expression" } as any, {message: "message"} ); @@ -25,14 +25,14 @@ describe("ParseExpressionError", () => { status: 400, type: "HTTP_EXCEPTION", origin: { - message: "message", - }, + message: "message" + } }); }); it("should throw error from origin error (RequiredValidationError)", () => { const metadata = { service: "name", - expression: "expression", + expression: "expression" } as any; const origin = RequiredValidationError.from(metadata); @@ -53,30 +53,30 @@ describe("ParseExpressionError", () => { message: "It should have required parameter 'expression'", modelName: "name", params: { - missingProperty: "expression", + missingProperty: "expression" }, - schemaPath: "#/required", - }, + schemaPath: "#/required" + } ], headers: {}, name: "REQUIRED_VALIDATION_ERROR", status: 400, - type: "HTTP_EXCEPTION", + type: "HTTP_EXCEPTION" }, requestType: "name", status: 400, - type: "HTTP_EXCEPTION", + type: "HTTP_EXCEPTION" }); }); it("should throw error from origin error (ValidationError)", () => { const metadata = { service: "name", - expression: "expression", + expression: "expression" } as any; const origin = new ValidationError("It should have 1 item", [ { - dataPath: "hello", - }, + dataPath: "hello" + } ]); const error = ParamValidationError.from(metadata, origin); @@ -91,17 +91,17 @@ describe("ParseExpressionError", () => { origin: { errors: [ { - dataPath: "hello", - }, + dataPath: "hello" + } ], headers: {}, name: "VALIDATION_ERROR", status: 400, - type: "HTTP_EXCEPTION", + type: "HTTP_EXCEPTION" }, requestType: "name", status: 400, - type: "HTTP_EXCEPTION", + type: "HTTP_EXCEPTION" }); }); }); diff --git a/packages/common/src/platform/middlewares/GlobalAcceptMimesMiddleware.spec.ts b/packages/common/src/platform/middlewares/GlobalAcceptMimesMiddleware.spec.ts index 604b0c3f259..9014e2a3152 100644 --- a/packages/common/src/platform/middlewares/GlobalAcceptMimesMiddleware.spec.ts +++ b/packages/common/src/platform/middlewares/GlobalAcceptMimesMiddleware.spec.ts @@ -12,12 +12,12 @@ describe("GlobalAcceptMimesMiddleware", () => { it("should return nothing", () => { const request: any = new FakeRequest({ headers: { - accept: "application/json", - }, + accept: "application/json" + } }); const context = PlatformTest.createRequestContext({ - request: new PlatformRequest(request), + request: new PlatformRequest(request) }); const settings = new ServerSettingsService(); @@ -33,12 +33,12 @@ describe("GlobalAcceptMimesMiddleware", () => { it("should throws NotAcceptable", () => { const request: any = new FakeRequest({ headers: { - accept: "text/html", - }, + accept: "text/html" + } }); const context = PlatformTest.createRequestContext({ - request: new PlatformRequest(request), + request: new PlatformRequest(request) }); const settings = new ServerSettingsService(); diff --git a/packages/common/src/platform/middlewares/LogIncomingRequestMiddleware.spec.ts b/packages/common/src/platform/middlewares/LogIncomingRequestMiddleware.spec.ts index b75737e193c..a02054970b1 100644 --- a/packages/common/src/platform/middlewares/LogIncomingRequestMiddleware.spec.ts +++ b/packages/common/src/platform/middlewares/LogIncomingRequestMiddleware.spec.ts @@ -16,13 +16,13 @@ describe("LogIncomingRequestMiddleware", () => { debug: Sinon.stub(), trace: Sinon.stub(), error: Sinon.stub(), - flush: Sinon.stub(), + flush: Sinon.stub() }; const middleware = new LogIncomingRequestMiddleware(injector as any); const request = new FakeRequest({ - logger: injector.logger, + logger: injector.logger }); request.method = "GET"; @@ -44,7 +44,7 @@ describe("LogIncomingRequestMiddleware", () => { event: "request.start", method: "GET", reqId: "id", - url: "originalUrl", + url: "originalUrl" }) ); expect(injector.logger.info).to.have.been.calledWithExactly( @@ -53,7 +53,7 @@ describe("LogIncomingRequestMiddleware", () => { method: "GET", reqId: "id", url: "originalUrl", - status: 200, + status: 200 }) ); expect(injector.logger.info).to.have.been.calledWithExactly(Sinon.match.has("duration", Sinon.match.number)); @@ -64,7 +64,7 @@ describe("LogIncomingRequestMiddleware", () => { const injector = new InjectorService(); injector.settings.logger = { debug: true, - logRequest: true, + logRequest: true }; injector.logger = { info: Sinon.stub(), @@ -72,13 +72,13 @@ describe("LogIncomingRequestMiddleware", () => { debug: Sinon.stub(), trace: Sinon.stub(), error: Sinon.stub(), - flush: Sinon.stub(), + flush: Sinon.stub() }; const middleware = new LogIncomingRequestMiddleware(injector as any); const request = new FakeRequest({ - logger: injector.logger, + logger: injector.logger }); request.method = "GET"; @@ -99,7 +99,7 @@ describe("LogIncomingRequestMiddleware", () => { event: "request.start", method: "GET", reqId: "id", - url: "url", + url: "url" }) ); expect(injector.logger.debug).to.have.been.calledWithExactly( @@ -109,7 +109,7 @@ describe("LogIncomingRequestMiddleware", () => { reqId: "id", url: "url", status: 200, - data: "test", + data: "test" }) ); expect(injector.logger.debug).to.have.been.calledWithExactly(Sinon.match.has("duration", Sinon.match.number)); @@ -125,13 +125,13 @@ describe("LogIncomingRequestMiddleware", () => { debug: Sinon.stub(), trace: Sinon.stub(), error: Sinon.stub(), - flush: Sinon.stub(), + flush: Sinon.stub() }; const middleware = new LogIncomingRequestMiddleware(injector as any); const request = new FakeRequest({ - logger: injector.logger, + logger: injector.logger }); request.method = "GET"; request.url = "url"; @@ -149,7 +149,7 @@ describe("LogIncomingRequestMiddleware", () => { // THEN expect(injector.logger.info).to.have.been.calledWithExactly( Sinon.match({ - event: "request.start", + event: "request.start" }) ); expect(injector.logger.info).to.have.been.calledWithExactly(Sinon.match.has("duration", Sinon.match.number)); @@ -165,13 +165,13 @@ describe("LogIncomingRequestMiddleware", () => { debug: Sinon.stub(), trace: Sinon.stub(), error: Sinon.stub(), - flush: Sinon.stub(), + flush: Sinon.stub() }; const middleware = new LogIncomingRequestMiddleware(injector as any); const request = new FakeRequest({ - logger: injector.logger, + logger: injector.logger }); request.method = "GET"; request.url = "url"; @@ -193,7 +193,7 @@ describe("LogIncomingRequestMiddleware", () => { method: "GET", reqId: "id", url: "originalUrl", - status: 200, + status: 200 }) ); expect(injector.logger.info).to.have.been.calledWithExactly(Sinon.match.has("duration", Sinon.match.number)); diff --git a/packages/common/src/platform/middlewares/LogIncomingRequestMiddleware.ts b/packages/common/src/platform/middlewares/LogIncomingRequestMiddleware.ts index 30f8da55edb..282b00c9a96 100644 --- a/packages/common/src/platform/middlewares/LogIncomingRequestMiddleware.ts +++ b/packages/common/src/platform/middlewares/LogIncomingRequestMiddleware.ts @@ -43,11 +43,11 @@ export class LogIncomingRequestMiddleware implements IMiddleware { if (logStart !== false) { if (debug) { request.ctx.logger.debug({ - event: "request.start", + event: "request.start" }); } else if (logRequest) { request.ctx.logger.info({ - event: "request.start", + event: "request.start" }); } } @@ -66,12 +66,12 @@ export class LogIncomingRequestMiddleware implements IMiddleware { request.ctx.logger.debug({ event: "request.end", status: response.statusCode, - data: request.ctx.data, + data: request.ctx.data }); } else if (logRequest) { request.ctx.logger.info({ event: "request.end", - status: response.statusCode, + status: response.statusCode }); } } @@ -100,7 +100,7 @@ export class LogIncomingRequestMiddleware implements IMiddleware { headers: request.headers, body: request.body, query: request.query, - params: request.params, + params: request.params }; } diff --git a/packages/common/src/platform/middlewares/PlatformContextMiddleware.spec.ts b/packages/common/src/platform/middlewares/PlatformContextMiddleware.spec.ts index b59207125b6..cb2ad6dc3c2 100644 --- a/packages/common/src/platform/middlewares/PlatformContextMiddleware.spec.ts +++ b/packages/common/src/platform/middlewares/PlatformContextMiddleware.spec.ts @@ -12,7 +12,7 @@ describe("PlatformContextMiddleware", () => { const response: any = { send: sandbox.stub(), end: sandbox.stub(), - req: request, + req: request }; const next = sandbox.stub(); @@ -35,7 +35,7 @@ describe("PlatformContextMiddleware", () => { const request: any = {}; const response: any = { end: sandbox.stub(), - req: request, + req: request }; const next = sandbox.stub(); @@ -44,7 +44,7 @@ describe("PlatformContextMiddleware", () => { reqIdBuilder() { return "1"; }, - ignoreUrlPatterns: [], + ignoreUrlPatterns: [] }); sandbox.stub(injector, "emit"); diff --git a/packages/common/src/platform/middlewares/PlatformContextMiddleware.ts b/packages/common/src/platform/middlewares/PlatformContextMiddleware.ts index d2ad8837813..501734b4134 100644 --- a/packages/common/src/platform/middlewares/PlatformContextMiddleware.ts +++ b/packages/common/src/platform/middlewares/PlatformContextMiddleware.ts @@ -54,7 +54,7 @@ export class PlatformContextMiddleware { maxStackSize, injector: this.injector, response, - request, + request }); // deprecated diff --git a/packages/common/src/platform/middlewares/PlatformHeadersMiddleware.spec.ts b/packages/common/src/platform/middlewares/PlatformHeadersMiddleware.spec.ts index 7e0219dfa59..8a0bb834d57 100644 --- a/packages/common/src/platform/middlewares/PlatformHeadersMiddleware.spec.ts +++ b/packages/common/src/platform/middlewares/PlatformHeadersMiddleware.spec.ts @@ -8,7 +8,7 @@ import { PlatformResponse, PlatformTest, Redirect, - Status, + Status } from "@tsed/common"; import {expect} from "chai"; import * as Sinon from "sinon"; diff --git a/packages/common/src/platform/middlewares/PlatformHeadersMiddleware.ts b/packages/common/src/platform/middlewares/PlatformHeadersMiddleware.ts index e924d0ff48c..3afc93eeded 100644 --- a/packages/common/src/platform/middlewares/PlatformHeadersMiddleware.ts +++ b/packages/common/src/platform/middlewares/PlatformHeadersMiddleware.ts @@ -8,7 +8,7 @@ function toHeaders(headers: {[key: string]: any}) { return Object.entries(headers).reduce((headers, [key, item]) => { return { ...headers, - [key]: String(item.value), + [key]: String(item.value) }; }, {}); } @@ -31,7 +31,7 @@ export class PlatformHeadersMiddleware implements IMiddleware { response: {headers = {}}, contentType, redirect, - location, + location } = ctx.endpoint; if (response.statusCode === 200) { diff --git a/packages/common/src/platform/middlewares/PlatformLogMiddleware.spec.ts b/packages/common/src/platform/middlewares/PlatformLogMiddleware.spec.ts index de405e3acbd..abaa1205b95 100644 --- a/packages/common/src/platform/middlewares/PlatformLogMiddleware.spec.ts +++ b/packages/common/src/platform/middlewares/PlatformLogMiddleware.spec.ts @@ -15,7 +15,7 @@ function createContext(settings: any) { debug: Sinon.stub(), trace: Sinon.stub(), error: Sinon.stub(), - flush: Sinon.stub(), + flush: Sinon.stub() }; const middleware = new PlatformLogMiddleware(injector as any); @@ -30,7 +30,7 @@ function createContext(settings: any) { const ctx = PlatformTest.createRequestContext({ request: new PlatformRequest(request as any), - response: new PlatformResponse(response as any), + response: new PlatformResponse(response as any) }); // @ts-ignore @@ -65,7 +65,7 @@ describe("PlatformLogMiddleware", () => { event: "request.start", method: "GET", reqId: "id", - url: "originalUrl", + url: "originalUrl" }) ); expect(injector.logger.info).to.have.been.calledWithExactly( @@ -74,7 +74,7 @@ describe("PlatformLogMiddleware", () => { method: "GET", reqId: "id", url: "originalUrl", - status: 200, + status: 200 }) ); expect(injector.logger.info).to.have.been.calledWithExactly(Sinon.match.has("duration", Sinon.match.number)); @@ -84,7 +84,7 @@ describe("PlatformLogMiddleware", () => { // GIVEN const {request, ctx, middleware, injector} = createContext({ debug: true, - logRequest: true, + logRequest: true }); // @ts-ignore ctx.logger.level = levels().DEBUG; @@ -100,7 +100,7 @@ describe("PlatformLogMiddleware", () => { event: "request.start", method: "GET", reqId: "id", - url: "url", + url: "url" }) ); expect(injector.logger.debug).to.have.been.calledWithExactly( @@ -110,7 +110,7 @@ describe("PlatformLogMiddleware", () => { reqId: "id", url: "url", status: 200, - data: "test", + data: "test" }) ); expect(injector.logger.debug).to.have.been.calledWithExactly(Sinon.match.has("duration", Sinon.match.number)); @@ -130,7 +130,7 @@ describe("PlatformLogMiddleware", () => { // THEN expect(injector.logger.info).to.have.been.calledWithExactly( Sinon.match({ - event: "request.start", + event: "request.start" }) ); expect(injector.logger.info).to.have.been.calledWithExactly(Sinon.match.has("duration", Sinon.match.number)); @@ -153,7 +153,7 @@ describe("PlatformLogMiddleware", () => { method: "GET", reqId: "id", url: "url", - status: 200, + status: 200 }) ); expect(injector.logger.info).to.have.been.calledWithExactly(Sinon.match.has("duration", Sinon.match.number)); diff --git a/packages/common/src/platform/middlewares/PlatformLogMiddleware.ts b/packages/common/src/platform/middlewares/PlatformLogMiddleware.ts index 49e429cbe47..78dd51013fb 100644 --- a/packages/common/src/platform/middlewares/PlatformLogMiddleware.ts +++ b/packages/common/src/platform/middlewares/PlatformLogMiddleware.ts @@ -42,11 +42,11 @@ export class PlatformLogMiddleware implements IMiddleware { if (logStart !== false) { if (debug) { ctx.logger.debug({ - event: "request.start", + event: "request.start" }); } else if (logRequest) { ctx.logger.info({ - event: "request.start", + event: "request.start" }); } } @@ -63,12 +63,12 @@ export class PlatformLogMiddleware implements IMiddleware { ctx.logger.debug({ event: "request.end", status: ctx.response.statusCode, - data: ctx.data, + data: ctx.data }); } else if (logRequest) { ctx.logger.info({ event: "request.end", - status: ctx.response.statusCode, + status: ctx.response.statusCode }); } } @@ -98,7 +98,7 @@ export class PlatformLogMiddleware implements IMiddleware { headers: request.headers, body: request.body, query: request.query, - params: request.params, + params: request.params }; } diff --git a/packages/common/src/platform/middlewares/ResponseViewMiddleware.spec.ts b/packages/common/src/platform/middlewares/ResponseViewMiddleware.spec.ts index b6d980b80dd..c1af076f3e9 100644 --- a/packages/common/src/platform/middlewares/ResponseViewMiddleware.spec.ts +++ b/packages/common/src/platform/middlewares/ResponseViewMiddleware.spec.ts @@ -35,7 +35,7 @@ describe("ResponseViewMiddleware :", () => { "view", { data: "data", - options: "options", + options: "options" }, Sinon.match.func ); diff --git a/packages/common/src/platform/middlewares/bindEndpointMiddleware.spec.ts b/packages/common/src/platform/middlewares/bindEndpointMiddleware.spec.ts index 893c62c2121..b86161c6ee7 100644 --- a/packages/common/src/platform/middlewares/bindEndpointMiddleware.spec.ts +++ b/packages/common/src/platform/middlewares/bindEndpointMiddleware.spec.ts @@ -10,7 +10,7 @@ describe("bindEndpointMiddleware", () => { it("should bind endpoint to the request", async () => { const endpoint = new EndpointMetadata({ target: Test, - propertyKey: "test", + propertyKey: "test" }); const request: any = new FakeRequest(); diff --git a/packages/common/src/platform/registries/ControllerRegistry.spec.ts b/packages/common/src/platform/registries/ControllerRegistry.spec.ts index 63c7932043a..e288d069c55 100644 --- a/packages/common/src/platform/registries/ControllerRegistry.spec.ts +++ b/packages/common/src/platform/registries/ControllerRegistry.spec.ts @@ -14,7 +14,7 @@ describe("ControllerRegistry", () => { const provider = new ControllerProvider(Test); // @ts-ignore provider.router = { - raw: {}, + raw: {} }; settings.onInvoke!(provider, locals, []); diff --git a/packages/common/src/platform/registries/ControllerRegistry.ts b/packages/common/src/platform/registries/ControllerRegistry.ts index 2ae98b499d7..91e61fe332f 100644 --- a/packages/common/src/platform/registries/ControllerRegistry.ts +++ b/packages/common/src/platform/registries/ControllerRegistry.ts @@ -8,5 +8,5 @@ export const ControllerRegistry: TypedProvidersRegistry = GlobalProviders.create onInvoke(provider: ControllerProvider, locals: any) { locals.set(PlatformRouter, provider.router); - }, + } }); diff --git a/packages/common/src/platform/services/Platform.spec.ts b/packages/common/src/platform/services/Platform.spec.ts index cd40b8fe7a4..1b1b9189aaf 100644 --- a/packages/common/src/platform/services/Platform.spec.ts +++ b/packages/common/src/platform/services/Platform.spec.ts @@ -18,13 +18,13 @@ describe("Platform", () => { "should create a router", PlatformTest.inject([InjectorService, Platform], async (injector: InjectorService, platform: Platform) => { const givenRouter = { - use: sandbox.stub(), + use: sandbox.stub() }; injector.addProvider(PlatformRouter, { useFactory() { return givenRouter; - }, + } }); sandbox.spy(injector, "invoke"); @@ -52,15 +52,15 @@ describe("Platform", () => { const driver = { use: sandbox.stub(), raw: { - use: sandbox.stub(), - }, + use: sandbox.stub() + } }; const platform = await PlatformTest.invoke(Platform, [ { token: PlatformApplication, - use: driver, - }, + use: driver + } ]); // WHEN @@ -88,15 +88,15 @@ describe("Platform", () => { const driver = { use: sandbox.stub(), raw: { - use: sandbox.stub(), - }, + use: sandbox.stub() + } }; const platform = await PlatformTest.invoke(Platform, [ { token: PlatformApplication, - use: driver, - }, + use: driver + } ]); // WHEN diff --git a/packages/common/src/platform/services/Platform.ts b/packages/common/src/platform/services/Platform.ts index f5049aec51f..e172203b8e1 100644 --- a/packages/common/src/platform/services/Platform.ts +++ b/packages/common/src/platform/services/Platform.ts @@ -13,7 +13,7 @@ import {PlatformRouter} from "./PlatformRouter"; * @platform */ @Injectable({ - scope: ProviderScope.SINGLETON, + scope: ProviderScope.SINGLETON }) export class Platform { private _routes: IRouteController[] = []; @@ -82,7 +82,7 @@ export class Platform { if (!provider.hasParent()) { this._routes.push({ route, - provider, + provider }); this.app.use(route, provider.router.callback()); } @@ -133,7 +133,7 @@ export class Platform { url: `${endpointUrl}${path || ""}`.replace(/\/\//gi, "/"), className: targetName, methodClassName: String(propertyKey), - parameters: params, + parameters: params }); } }); diff --git a/packages/common/src/platform/services/PlatformApplication.spec.ts b/packages/common/src/platform/services/PlatformApplication.spec.ts index 5f14d13154f..0280de3af3c 100644 --- a/packages/common/src/platform/services/PlatformApplication.spec.ts +++ b/packages/common/src/platform/services/PlatformApplication.spec.ts @@ -16,19 +16,19 @@ function createDriver() { delete: sandbox.stub(), patch: sandbox.stub(), head: sandbox.stub(), - options: sandbox.stub(), + options: sandbox.stub() }; } async function getPlatformApp() { const platformHandler = { - createHandler: sandbox.stub().callsFake((o) => o), + createHandler: sandbox.stub().callsFake((o) => o) }; const platformApp = await PlatformTest.invoke(PlatformApplication, [ { token: PlatformHandler, - use: platformHandler, - }, + use: platformHandler + } ]); platformApp.raw = createDriver() as any; diff --git a/packages/common/src/platform/services/PlatformApplication.ts b/packages/common/src/platform/services/PlatformApplication.ts index b54e19c4cef..551209b7004 100644 --- a/packages/common/src/platform/services/PlatformApplication.ts +++ b/packages/common/src/platform/services/PlatformApplication.ts @@ -15,7 +15,7 @@ declare global { * @platform */ @Injectable({ - scope: ProviderScope.SINGLETON, + scope: ProviderScope.SINGLETON }) export class PlatformApplication extends PlatformDriver { constructor(platformHandler: PlatformHandler) { diff --git a/packages/common/src/platform/services/PlatformHandler.spec.ts b/packages/common/src/platform/services/PlatformHandler.spec.ts index d0572a42279..7ea602ccdd9 100644 --- a/packages/common/src/platform/services/PlatformHandler.spec.ts +++ b/packages/common/src/platform/services/PlatformHandler.spec.ts @@ -12,7 +12,7 @@ import { PlatformRequest, PlatformResponse, PlatformTest, - QueryParams, + QueryParams } from "@tsed/common"; import {Type} from "@tsed/core"; import {InjectorService, Provider} from "@tsed/di"; @@ -33,7 +33,7 @@ function build(injector: InjectorService, type: string | ParamTypes | Type, const response: any = new FakeResponse(); request.ctx = PlatformTest.createRequestContext({ response: new PlatformResponse(response), - request: new PlatformRequest(request), + request: new PlatformRequest(request) }); const next: any = Sinon.stub(); @@ -43,7 +43,7 @@ function build(injector: InjectorService, type: string | ParamTypes | Type, response, next, args: [], - metadata: {} as any, + metadata: {} as any }); if (expression) { @@ -58,7 +58,7 @@ function build(injector: InjectorService, type: string | ParamTypes | Type, param, request, response, - next, + next }; } @@ -92,7 +92,7 @@ describe("PlatformHandler", () => { sandbox.stub(injector, "getProvider").returns(new Provider(Test)); const endpoint = new EndpointMetadata({ target: Test, - propertyKey: "get", + propertyKey: "get" }); // WHEN @@ -147,14 +147,14 @@ describe("PlatformHandler", () => { const response: any = new FakeRequest(); request.ctx = PlatformTest.createRequestContext({ response: new PlatformResponse(response), - request: new PlatformRequest(request), + request: new PlatformRequest(request) }); const handlerMetadata = new HandlerMetadata({ token: Test, target: Test, type: HandlerType.CONTROLLER, - propertyKey: "get", + propertyKey: "get" }); // WHEN @@ -204,7 +204,7 @@ describe("PlatformHandler", () => { token: Test, target: Test, type: HandlerType.CONTROLLER, - propertyKey: "use", + propertyKey: "use" }); // WHEN @@ -237,7 +237,7 @@ describe("PlatformHandler", () => { token: Test, target: Test, type: HandlerType.CONTROLLER, - propertyKey: "get", + propertyKey: "get" }); // WHEN @@ -396,7 +396,7 @@ describe("PlatformHandler", () => { // THEN expect(value).to.deep.eq({ accept: "application/json", - "content-type": "application/json", + "content-type": "application/json" }); }) ); diff --git a/packages/common/src/platform/services/PlatformHandler.ts b/packages/common/src/platform/services/PlatformHandler.ts index 86c70cde063..eeaea10f2f2 100644 --- a/packages/common/src/platform/services/PlatformHandler.ts +++ b/packages/common/src/platform/services/PlatformHandler.ts @@ -8,7 +8,7 @@ import { IHandlerConstructorOptions, IPipe, ParamMetadata, - ParamTypes, + ParamTypes } from "../../mvc"; import {ValidationError} from "../../mvc/errors/ValidationError"; import {HandlerContext} from "../domain/HandlerContext"; @@ -20,7 +20,7 @@ import {UnknownFilterError} from "../errors/UnknownFilterError"; * @platform */ @Injectable({ - scope: ProviderScope.SINGLETON, + scope: ProviderScope.SINGLETON }) export class PlatformHandler { constructor(protected injector: InjectorService) {} @@ -36,7 +36,7 @@ export class PlatformHandler { token: provider.provide, target: provider.useClass, type: HandlerType.CONTROLLER, - propertyKey: obj.propertyKey, + propertyKey: obj.propertyKey }; } else { const provider = injector.getProvider(obj); @@ -46,12 +46,12 @@ export class PlatformHandler { token: provider.provide, target: provider.useClass, type: HandlerType.MIDDLEWARE, - propertyKey: "use", + propertyKey: "use" }; } else { options = { target: obj, - type: HandlerType.FUNCTION, + type: HandlerType.FUNCTION }; } } @@ -85,7 +85,7 @@ export class PlatformHandler { getParam(param: ParamMetadata, context: HandlerContext) { const { ctx, - ctx: {request, response}, + ctx: {request, response} } = context; switch (param.paramType) { @@ -168,7 +168,7 @@ export class PlatformHandler { next, err, metadata, - args: [], + args: [] }); } @@ -180,7 +180,7 @@ export class PlatformHandler { request, response, next, - err, + err }) ); } else { @@ -194,7 +194,7 @@ export class PlatformHandler { } const { - metadata: {parameters}, + metadata: {parameters} } = context; try { diff --git a/packages/common/src/platform/services/PlatformRequest.spec.ts b/packages/common/src/platform/services/PlatformRequest.spec.ts index 521b8c78c47..887b88b8ce8 100644 --- a/packages/common/src/platform/services/PlatformRequest.spec.ts +++ b/packages/common/src/platform/services/PlatformRequest.spec.ts @@ -39,33 +39,33 @@ describe("PlatformRequest", () => { expect(request.url).to.equal("/"); expect(request.body).to.deep.equal({ obj: { - test: "testValue", + test: "testValue" }, - test: "testValue", + test: "testValue" }); expect(request.params).to.deep.equal({ obj: { - test: "testValue", + test: "testValue" }, - test: "testValue", + test: "testValue" }); expect(request.query).to.deep.equal({ obj: { - test: "testValue", + test: "testValue" }, - test: "testValue", + test: "testValue" }); expect(request.cookies).to.deep.equal({ obj: { - test: "testValue", + test: "testValue" }, - test: "testValue", + test: "testValue" }); expect(request.session).to.deep.equal({ obj: { - test: "testValue", + test: "testValue" }, - test: "testValue", + test: "testValue" }); }); }); diff --git a/packages/common/src/platform/services/PlatformRouter.spec.ts b/packages/common/src/platform/services/PlatformRouter.spec.ts index 12d92b57129..73469d5210d 100644 --- a/packages/common/src/platform/services/PlatformRouter.spec.ts +++ b/packages/common/src/platform/services/PlatformRouter.spec.ts @@ -10,7 +10,7 @@ describe("PlatformRouter", () => { const injector = new InjectorService(); Sinon.stub(injector, "invoke"); const routerOptions: any = { - test: "options", + test: "options" }; // WHEN diff --git a/packages/common/src/platform/services/PlatformRouter.ts b/packages/common/src/platform/services/PlatformRouter.ts index c1ddd602ea5..bd3182d68a4 100644 --- a/packages/common/src/platform/services/PlatformRouter.ts +++ b/packages/common/src/platform/services/PlatformRouter.ts @@ -15,7 +15,7 @@ declare global { * @platform */ @Injectable({ - scope: ProviderScope.INSTANCE, + scope: ProviderScope.INSTANCE }) export class PlatformRouter extends PlatformDriver { constructor(platform: PlatformHandler) { diff --git a/packages/common/src/platform/services/RouteService.spec.ts b/packages/common/src/platform/services/RouteService.spec.ts index e9110827123..51adac2dfa1 100644 --- a/packages/common/src/platform/services/RouteService.spec.ts +++ b/packages/common/src/platform/services/RouteService.spec.ts @@ -13,20 +13,20 @@ describe("RouteService", () => { routes: [], addRoutes: Sinon.stub(), addRoute: Sinon.stub(), - getRoutes: Sinon.stub(), + getRoutes: Sinon.stub() }; const routeService = await PlatformTest.invoke(RouteService, [ { token: Platform, - use: platform, - }, + use: platform + } ]); routeService.addRoutes([ { token: Test, - route: "/", - }, + route: "/" + } ]); routeService.addRoute("/", Test); routeService.getRoutes(); @@ -36,8 +36,8 @@ describe("RouteService", () => { expect(platform.addRoutes).to.have.been.calledWithExactly([ { token: Test, - route: "/", - }, + route: "/" + } ]); expect(platform.getRoutes).to.have.been.calledWithExactly(); }); diff --git a/packages/core/src/class/Entity.spec.ts b/packages/core/src/class/Entity.spec.ts index baa5dbe33d3..d564c6f69f9 100644 --- a/packages/core/src/class/Entity.spec.ts +++ b/packages/core/src/class/Entity.spec.ts @@ -19,7 +19,7 @@ describe("EntityDescription", () => { const entityDescription = new EntityTest({ target: Test, propertyKey: "test", - index: 0, + index: 0 }); // entityDescription.required = true; entityDescription.type = Test; diff --git a/packages/core/src/class/ProxyMap.spec.ts b/packages/core/src/class/ProxyMap.spec.ts index bdf7a822531..c55c0aed84f 100644 --- a/packages/core/src/class/ProxyMap.spec.ts +++ b/packages/core/src/class/ProxyMap.spec.ts @@ -175,7 +175,7 @@ describe("ProxyMap", () => { it("should return a list", () => { expect(Array.from(service)).to.deep.eq([ ["test", {type: "type1"}], - ["test3", {type: "type1"}], + ["test3", {type: "type1"}] ]); }); }); diff --git a/packages/core/src/class/Registry.spec.ts b/packages/core/src/class/Registry.spec.ts index 0c3718c1f9f..ee6165664fa 100644 --- a/packages/core/src/class/Registry.spec.ts +++ b/packages/core/src/class/Registry.spec.ts @@ -235,7 +235,7 @@ describe("Registry", () => { let hooks: any; before(() => { hooks = { - onCreate: Sinon.stub(), + onCreate: Sinon.stub() }; registry = new Registry(FakeMetadata, hooks); hasStub = Sinon.stub(registry, "has").returns(false); diff --git a/packages/core/src/class/Storable.ts b/packages/core/src/class/Storable.ts index bac29946703..d696959cd2d 100644 --- a/packages/core/src/class/Storable.ts +++ b/packages/core/src/class/Storable.ts @@ -19,7 +19,7 @@ export abstract class Storable extends Entity { target, propertyKey, index: (isNumber(index) ? index : undefined) as any, - descriptor: isObject(index) ? index : undefined, + descriptor: isObject(index) ? index : undefined }); this._target = target; diff --git a/packages/core/src/class/Store.spec.ts b/packages/core/src/class/Store.spec.ts index ceb08c5bbdc..23bccb6f93e 100644 --- a/packages/core/src/class/Store.spec.ts +++ b/packages/core/src/class/Store.spec.ts @@ -53,8 +53,8 @@ describe("Store", () => { FakeMetadata, "get", { - value: () => {}, - }, + value: () => {} + } ]); }); after(() => { @@ -89,8 +89,8 @@ describe("Store", () => { FakeMetadata, "get", { - set: () => {}, - }, + set: () => {} + } ]); }); after(() => { @@ -110,8 +110,8 @@ describe("Store", () => { FakeMetadata, "get", { - get: () => {}, - }, + get: () => {} + } ]); }); after(() => { diff --git a/packages/core/src/interfaces/Env.ts b/packages/core/src/interfaces/Env.ts index 7cd0a5a8624..d8b21805ab2 100644 --- a/packages/core/src/interfaces/Env.ts +++ b/packages/core/src/interfaces/Env.ts @@ -4,7 +4,7 @@ export enum Env { PROD = "production", DEV = "development", - TEST = "test", + TEST = "test" } /** diff --git a/packages/core/src/utils/DecoratorUtils.spec.ts b/packages/core/src/utils/DecoratorUtils.spec.ts index 7bb5700bea6..e0f1b543e30 100644 --- a/packages/core/src/utils/DecoratorUtils.spec.ts +++ b/packages/core/src/utils/DecoratorUtils.spec.ts @@ -9,7 +9,7 @@ import { UnsupportedDecoratorType, useDecorators, useMethodDecorator, - useMethodDecorators, + useMethodDecorators } from "../../src"; class Test {} @@ -35,8 +35,8 @@ describe("DecoratorUtils", () => { Test.prototype, "props", { - get: () => {}, - }, + get: () => {} + } ]) ).to.equal("property"); }); @@ -47,8 +47,8 @@ describe("DecoratorUtils", () => { Test.prototype, "props", { - set: () => {}, - }, + set: () => {} + } ]) ).to.equal("property"); }); @@ -59,8 +59,8 @@ describe("DecoratorUtils", () => { Test, "props", { - value: () => {}, - }, + value: () => {} + } ]) ).to.equal("method"); }); @@ -71,8 +71,8 @@ describe("DecoratorUtils", () => { Test.prototype, "props", { - value: () => {}, - }, + value: () => {} + } ]) ).to.equal("method"); }); @@ -109,8 +109,8 @@ describe("DecoratorUtils", () => { Test.prototype, "props", { - get: () => {}, - }, + get: () => {} + } ], true ) @@ -124,8 +124,8 @@ describe("DecoratorUtils", () => { Test.prototype, "props", { - set: () => {}, - }, + set: () => {} + } ], true ) @@ -139,8 +139,8 @@ describe("DecoratorUtils", () => { Test, "props", { - value: () => {}, - }, + value: () => {} + } ], true ) @@ -154,8 +154,8 @@ describe("DecoratorUtils", () => { Test.prototype, "props", { - value: () => {}, - }, + value: () => {} + } ], true ) @@ -199,8 +199,8 @@ describe("DecoratorUtils", () => { Test.prototype, "props", { - get: () => {}, - }, + get: () => {} + } ]) ).to.equal("Decorator cannot be used as property decorator on Test.props"); }); @@ -211,8 +211,8 @@ describe("DecoratorUtils", () => { Test.prototype, "props", { - set: () => {}, - }, + set: () => {} + } ]) ).to.equal("Decorator cannot be used as property decorator on Test.props"); }); @@ -223,8 +223,8 @@ describe("DecoratorUtils", () => { Test, "props", { - value: () => {}, - }, + value: () => {} + } ]) ).to.equal("Decorator cannot be used as method.static decorator on Test.props"); }); @@ -235,8 +235,8 @@ describe("DecoratorUtils", () => { Test.prototype, "props", { - value: () => {}, - }, + value: () => {} + } ]) ).to.equal("Decorator cannot be used as method decorator on Test.props"); }); diff --git a/packages/core/src/utils/DecoratorUtils.ts b/packages/core/src/utils/DecoratorUtils.ts index c10ee63414b..37f6eb59f7b 100644 --- a/packages/core/src/utils/DecoratorUtils.ts +++ b/packages/core/src/utils/DecoratorUtils.ts @@ -9,7 +9,7 @@ export enum DecoratorTypes { PROP_STC = "property.static", METHOD = "method", METHOD_STC = "method.static", - CLASS = "class", + CLASS = "class" } /** @@ -86,7 +86,7 @@ export function decorateMethodsOf(klass: any, decorator: any) { Object.defineProperty(prototypeOf(klass), propertyKey, { value(...args: any[]) { return prototypeOf(target)[propertyKey].apply(this, args); - }, + } }); } diff --git a/packages/core/src/utils/ObjectUtils.spec.ts b/packages/core/src/utils/ObjectUtils.spec.ts index 90a15cda31c..804680b2791 100644 --- a/packages/core/src/utils/ObjectUtils.spec.ts +++ b/packages/core/src/utils/ObjectUtils.spec.ts @@ -15,7 +15,7 @@ import { methodsOf, nameOf, nameOfClass, - primitiveOf, + primitiveOf } from "../../src"; class Base { @@ -273,7 +273,7 @@ describe("ObjectUtils", () => { expect(methods).to.deep.eq([ {propertyKey: "test1", target: Test}, {propertyKey: "test3", target: Base}, - {propertyKey: "test2", target: Test}, + {propertyKey: "test2", target: Test} ]); }); }); diff --git a/packages/core/src/utils/applyBefore.spec.ts b/packages/core/src/utils/applyBefore.spec.ts index dc6b638c854..c347f9b8446 100644 --- a/packages/core/src/utils/applyBefore.spec.ts +++ b/packages/core/src/utils/applyBefore.spec.ts @@ -7,7 +7,7 @@ describe("applyBefore", () => { const originalMethod = Sinon.stub(); originalMethod.returns("returns"); const obj = { - method: originalMethod, + method: originalMethod }; const cbStub = Sinon.stub(); diff --git a/packages/core/src/utils/cleanObject.ts b/packages/core/src/utils/cleanObject.ts index a9ac77d0367..ab1521effd4 100644 --- a/packages/core/src/utils/cleanObject.ts +++ b/packages/core/src/utils/cleanObject.ts @@ -10,7 +10,7 @@ export function cleanObject(obj: any): any { ? obj : { ...obj, - [key]: value, + [key]: value }, {} ); diff --git a/packages/core/src/utils/deepClone.spec.ts b/packages/core/src/utils/deepClone.spec.ts index ee8232aad85..7889459995a 100644 --- a/packages/core/src/utils/deepClone.spec.ts +++ b/packages/core/src/utils/deepClone.spec.ts @@ -4,7 +4,7 @@ import {deepClone} from "../../src/utils/deepClone"; describe("deepClone", () => { it("should clone object", () => { const externalObject = { - color: "red", + color: "red" }; class Base { @@ -40,7 +40,7 @@ describe("deepClone", () => { h: Infinity, i: externalObject, j: new Test("test"), - k: [new Test("test"), false, 1, Test], + k: [new Test("test"), false, 1, Test] }; const cloned = deepClone(original); diff --git a/packages/core/src/utils/deepExtends.spec.ts b/packages/core/src/utils/deepExtends.spec.ts index 68cdb3d17d4..2c693c3eb9f 100644 --- a/packages/core/src/utils/deepExtends.spec.ts +++ b/packages/core/src/utils/deepExtends.spec.ts @@ -8,12 +8,12 @@ describe("deepExtends", () => { expect( deepExtends( { - security: ["o"], + security: ["o"] }, undefined ) ).to.deep.eq({ - security: ["o"], + security: ["o"] }); }); it("should merge data (2)", () => { @@ -22,18 +22,18 @@ describe("deepExtends", () => { }; const result = deepExtends( { - security: ["o"], + security: ["o"] }, { security: ["o", "o1"], - withClass: new klass(), + withClass: new klass() } ); expect(result).to.deep.eq({ security: ["o", "o1"], withClass: { - test: "test", - }, + test: "test" + } }); expect(result.withClass).to.be.instanceof(klass); @@ -43,14 +43,14 @@ describe("deepExtends", () => { expect( deepExtends( { - security: [{"1": "o"}], + security: [{"1": "o"}] }, { - security: [{"1": "o"}, {"2": "o1"}], + security: [{"1": "o"}, {"2": "o1"}] } ) ).to.deep.eq({ - security: [{"1": "o"}, {"1": "o"}, {"2": "o1"}], + security: [{"1": "o"}, {"1": "o"}, {"2": "o1"}] }); }); }); @@ -67,7 +67,7 @@ describe("deepExtends", () => { {"4": "4"}, {"1": "1"}, {"2": "2"}, - {"3": "3"}, + {"3": "3"} ]); }); }); @@ -79,10 +79,10 @@ describe("deepExtends", () => { expect( deepExtends( { - security: ["o"], + security: ["o"] }, { - security: ["o", "o1"], + security: ["o", "o1"] }, { default: (collection, value) => { @@ -91,11 +91,11 @@ describe("deepExtends", () => { } return collection; - }, + } } ) ).to.deep.eq({ - security: ["o", "o1"], + security: ["o", "o1"] }); }); @@ -108,9 +108,9 @@ describe("deepExtends", () => { { in: "test", name: "post", - description: "test", - }, - ], + description: "test" + } + ] }, { parameters: [ @@ -118,9 +118,9 @@ describe("deepExtends", () => { { in: "test", name: "util", - description: "test2", - }, - ], + description: "test2" + } + ] }, { parameters: (collection, value) => { @@ -133,15 +133,15 @@ describe("deepExtends", () => { } return collection; - }, + } } ) ).to.deep.eq({ parameters: [ {in: "test", name: "get", description: "test2"}, {in: "test", name: "post", description: "test"}, - {in: "test", name: "util", description: "test2"}, - ], + {in: "test", name: "util", description: "test2"} + ] }); }); }); @@ -158,7 +158,7 @@ describe("deepExtends", () => { {"4": "4"}, {"1": "1"}, {"2": "2"}, - {"3": "3"}, + {"3": "3"} ]); }); }); diff --git a/packages/di/src/class/LocalsContainer.spec.ts b/packages/di/src/class/LocalsContainer.spec.ts index cd12f671e53..d234f46b7c8 100644 --- a/packages/di/src/class/LocalsContainer.spec.ts +++ b/packages/di/src/class/LocalsContainer.spec.ts @@ -7,7 +7,7 @@ describe("LocalsContainer", () => { it("should destroy container", async () => { // GIVEN const instance = { - $onDestroy: Sinon.stub().resolves(), + $onDestroy: Sinon.stub().resolves() }; const container = new LocalsContainer(); container.set("TOKEN", instance); diff --git a/packages/di/src/class/Provider.spec.ts b/packages/di/src/class/Provider.spec.ts index af1a9bbac4c..0999afdbf0b 100644 --- a/packages/di/src/class/Provider.spec.ts +++ b/packages/di/src/class/Provider.spec.ts @@ -29,7 +29,7 @@ describe("Provider", () => { "imports", "useFactory", "useAsyncFactory", - "useValue", + "useValue" ]); expect(provider.clone()).to.deep.eq(provider); }); diff --git a/packages/di/src/decorators/Interceptor.spec.ts b/packages/di/src/decorators/Interceptor.spec.ts index 45cea43930b..a517ee8f045 100644 --- a/packages/di/src/decorators/Interceptor.spec.ts +++ b/packages/di/src/decorators/Interceptor.spec.ts @@ -25,7 +25,7 @@ describe("@Interceptor", () => { expect(interceptorRegistry.merge).to.have.been.calledWithExactly(Test, { instance: undefined, provide: Test, - type: ProviderType.INTERCEPTOR, + type: ProviderType.INTERCEPTOR }); }); }); diff --git a/packages/di/src/decorators/configuration.spec.ts b/packages/di/src/decorators/configuration.spec.ts index 38352f94580..993e55e3863 100644 --- a/packages/di/src/decorators/configuration.spec.ts +++ b/packages/di/src/decorators/configuration.spec.ts @@ -17,7 +17,7 @@ describe("@Configuration", () => { it("should inject configuration", async () => { @Configuration({ - feature: "feature", + feature: "feature" }) @Injectable() class Test { diff --git a/packages/di/src/decorators/constant.spec.ts b/packages/di/src/decorators/constant.spec.ts index 0ec4369a6ca..8ca0f3418c4 100644 --- a/packages/di/src/decorators/constant.spec.ts +++ b/packages/di/src/decorators/constant.spec.ts @@ -18,8 +18,8 @@ describe("@Constant()", () => { bindingType: "constant", propertyKey: "test", expression: "expression", - defaultValue: undefined, - }, + defaultValue: undefined + } }); }); }); diff --git a/packages/di/src/decorators/constant.ts b/packages/di/src/decorators/constant.ts index 173becca2c2..bf698bf2a71 100644 --- a/packages/di/src/decorators/constant.ts +++ b/packages/di/src/decorators/constant.ts @@ -45,8 +45,8 @@ export function Constant(expression: string, defaultValue?: any): any { bindingType: InjectablePropertyType.CONSTANT, propertyKey, expression, - defaultValue, - }, + defaultValue + } } as IInjectableProperties); }; } diff --git a/packages/di/src/decorators/inject.spec.ts b/packages/di/src/decorators/inject.spec.ts index a026ac97c31..91799c971c8 100644 --- a/packages/di/src/decorators/inject.spec.ts +++ b/packages/di/src/decorators/inject.spec.ts @@ -49,8 +49,8 @@ describe("@Inject()", () => { expect(store).to.deep.eq({ test: { bindingType: "method", - propertyKey: "test", - }, + propertyKey: "test" + } }); }); }); @@ -73,8 +73,8 @@ describe("@Inject()", () => { test: { bindingType: "property", propertyKey: "test", - useType: String, - }, + useType: String + } }); }); }); diff --git a/packages/di/src/decorators/inject.ts b/packages/di/src/decorators/inject.ts index 5ef3b5c07c8..4d1ce3b9e56 100644 --- a/packages/di/src/decorators/inject.ts +++ b/packages/di/src/decorators/inject.ts @@ -38,8 +38,8 @@ export function Inject(symbol?: any): Function { [propertyKey]: { bindingType, propertyKey, - useType: symbol || Metadata.getType(target, propertyKey), - }, + useType: symbol || Metadata.getType(target, propertyKey) + } }); break; @@ -47,8 +47,8 @@ export function Inject(symbol?: any): Function { Store.from(target).merge(INJECTABLE_PROP, { [propertyKey]: { bindingType, - propertyKey, - }, + propertyKey + } }); return descriptor; diff --git a/packages/di/src/decorators/injectable.spec.ts b/packages/di/src/decorators/injectable.spec.ts index e360f70bdb4..81777dfddf0 100644 --- a/packages/di/src/decorators/injectable.spec.ts +++ b/packages/di/src/decorators/injectable.spec.ts @@ -25,7 +25,7 @@ describe("@Injectable()", () => { // THEN expect(ProviderRegistry.registerProvider).to.have.been.calledWithExactly({ options: "options", - provide: Test, + provide: Test }); }); }); @@ -48,7 +48,7 @@ describe("@Injectable()", () => { // THEN expect(ProviderRegistry.registerProvider).to.have.been.calledWithExactly({ - provide: Test, + provide: Test }); }); }); diff --git a/packages/di/src/decorators/injectable.ts b/packages/di/src/decorators/injectable.ts index ee649e2e3a4..eb90eb8742a 100644 --- a/packages/di/src/decorators/injectable.ts +++ b/packages/di/src/decorators/injectable.ts @@ -25,7 +25,7 @@ export function Injectable(options: Partial> = {}): Function { return (provide: Type) => { registerProvider({ ...options, - provide, + provide }); }; } diff --git a/packages/di/src/decorators/intercept.ts b/packages/di/src/decorators/intercept.ts index f14c0231996..0c903d27f16 100644 --- a/packages/di/src/decorators/intercept.ts +++ b/packages/di/src/decorators/intercept.ts @@ -16,8 +16,8 @@ export function Intercept(interceptor: Type, options? bindingType: InjectablePropertyType.INTERCEPTOR, propertyKey, useType: interceptor, - options, - }, + options + } } as IInjectableProperties); return descriptor; diff --git a/packages/di/src/decorators/module.ts b/packages/di/src/decorators/module.ts index d663808a74f..a22dc3775df 100644 --- a/packages/di/src/decorators/module.ts +++ b/packages/di/src/decorators/module.ts @@ -49,7 +49,7 @@ export function Module(options: Partial = {}) { imports, deps, injectable: false, - resolvers, + resolvers }) ); } diff --git a/packages/di/src/decorators/service.spec.ts b/packages/di/src/decorators/service.spec.ts index 4f5a33ffbe4..a801291e71f 100644 --- a/packages/di/src/decorators/service.spec.ts +++ b/packages/di/src/decorators/service.spec.ts @@ -23,7 +23,7 @@ describe("Service", () => { expect(serviceRegistry.merge).to.have.been.calledWithExactly(Test, { instance: undefined, provide: Test, - type: ProviderType.SERVICE, + type: ProviderType.SERVICE }); }); }); diff --git a/packages/di/src/decorators/useOpts.spec.ts b/packages/di/src/decorators/useOpts.spec.ts index 8f82a216a13..c65c358af37 100644 --- a/packages/di/src/decorators/useOpts.spec.ts +++ b/packages/di/src/decorators/useOpts.spec.ts @@ -20,7 +20,7 @@ describe("UseOpts", () => { class MyService { @Inject() @UseOpts({ - source: "test1", + source: "test1" }) service1: MyProvider; diff --git a/packages/di/src/decorators/useOpts.ts b/packages/di/src/decorators/useOpts.ts index 455bffb5e66..9730f33f1d4 100644 --- a/packages/di/src/decorators/useOpts.ts +++ b/packages/di/src/decorators/useOpts.ts @@ -52,8 +52,8 @@ export function UseOpts(options: {[key: string]: any}): Function { case DecoratorTypes.PROP: Store.from(target).merge(INJECTABLE_PROP, { [propertyKey as string]: { - options, - }, + options + } }); break; diff --git a/packages/di/src/decorators/value.spec.ts b/packages/di/src/decorators/value.spec.ts index 538f93ad64a..0555e3e1b80 100644 --- a/packages/di/src/decorators/value.spec.ts +++ b/packages/di/src/decorators/value.spec.ts @@ -17,8 +17,8 @@ describe("@Value()", () => { bindingType: "value", propertyKey: "test", expression: "expression", - defaultValue: undefined, - }, + defaultValue: undefined + } }); }); }); diff --git a/packages/di/src/decorators/value.ts b/packages/di/src/decorators/value.ts index 17604af169a..2154ddc6c7a 100644 --- a/packages/di/src/decorators/value.ts +++ b/packages/di/src/decorators/value.ts @@ -45,8 +45,8 @@ export function Value(expression: any, defaultValue?: any) { bindingType: InjectablePropertyType.VALUE, propertyKey, expression, - defaultValue, - }, + defaultValue + } } as IInjectableProperties); }; } diff --git a/packages/di/src/errors/InjectionError.ts b/packages/di/src/errors/InjectionError.ts index 4a0086654ae..3a1d6aed0f9 100644 --- a/packages/di/src/errors/InjectionError.ts +++ b/packages/di/src/errors/InjectionError.ts @@ -17,7 +17,7 @@ export class InjectionError extends Error { if (isString(origin)) { this.origin = { message: origin, - stack: this.stack, + stack: this.stack }; } else { if (origin.tokens) { diff --git a/packages/di/src/interfaces/InjectablePropertyType.ts b/packages/di/src/interfaces/InjectablePropertyType.ts index b081b508dda..64623f60d73 100644 --- a/packages/di/src/interfaces/InjectablePropertyType.ts +++ b/packages/di/src/interfaces/InjectablePropertyType.ts @@ -3,5 +3,5 @@ export enum InjectablePropertyType { PROPERTY = "property", CONSTANT = "constant", VALUE = "value", - INTERCEPTOR = "interceptor", + INTERCEPTOR = "interceptor" } diff --git a/packages/di/src/interfaces/ProviderScope.ts b/packages/di/src/interfaces/ProviderScope.ts index 05b4544ff7e..edc78e05459 100644 --- a/packages/di/src/interfaces/ProviderScope.ts +++ b/packages/di/src/interfaces/ProviderScope.ts @@ -1,5 +1,5 @@ export enum ProviderScope { SINGLETON = "singleton", REQUEST = "request", - INSTANCE = "instance", + INSTANCE = "instance" } diff --git a/packages/di/src/interfaces/ProviderType.ts b/packages/di/src/interfaces/ProviderType.ts index 67153c8a8d2..2a2bd0092d0 100644 --- a/packages/di/src/interfaces/ProviderType.ts +++ b/packages/di/src/interfaces/ProviderType.ts @@ -10,5 +10,5 @@ export enum ProviderType { // NOT STANDARD CONVERTER = "converter", FILTER = "filter", - MIDDLEWARE = "middleware", + MIDDLEWARE = "middleware" } diff --git a/packages/di/src/registries/GlobalProviders.spec.ts b/packages/di/src/registries/GlobalProviders.spec.ts index 1a6016b2341..507511a1376 100644 --- a/packages/di/src/registries/GlobalProviders.spec.ts +++ b/packages/di/src/registries/GlobalProviders.spec.ts @@ -16,7 +16,7 @@ describe("GlobalProviderRegistry", () => { // WHEN const result = providers.createRegistry("test", Provider, { - injectable: false, + injectable: false }); // THEN @@ -24,7 +24,7 @@ describe("GlobalProviderRegistry", () => { expect(setStub).to.have.been.calledWithExactly("test", { registry: result, - injectable: false, + injectable: false }); }); }); @@ -96,7 +96,7 @@ describe("GlobalProviderRegistry", () => { // THEN expect(result).to.deep.eq({ registry: providers, - injectable: true, + injectable: true }); expect(hasStub).to.have.been.calledWithExactly("type"); @@ -110,7 +110,7 @@ describe("GlobalProviderRegistry", () => { // GIVEN const providers = new GlobalProviderRegistry(); const registryStub = { - merge: Sinon.stub(), + merge: Sinon.stub() }; // @ts-ignore @@ -125,7 +125,7 @@ describe("GlobalProviderRegistry", () => { expect(registryStub.merge).to.have.been.calledWithExactly("provide", { provide: "provide", instance: undefined, - type: "type", + type: "type" }); }); }); diff --git a/packages/di/src/registries/GlobalProviders.ts b/packages/di/src/registries/GlobalProviders.ts index 09985902663..a78b6c301fe 100644 --- a/packages/di/src/registries/GlobalProviders.ts +++ b/packages/di/src/registries/GlobalProviders.ts @@ -26,7 +26,7 @@ export class GlobalProviderRegistry extends Registry, IProvider = {injectable: true} ): TypedProvidersRegistry { const registry = new Registry, IProvider>(model, { - onCreate: this.set.bind(this), + onCreate: this.set.bind(this) }); this._registries.set( @@ -34,7 +34,7 @@ export class GlobalProviderRegistry extends Registry, IProvider, IProvider, IProvider, instance?: any): void => { if (!provider.provide) { provider = { - provide: provider, + provide: provider }; } diff --git a/packages/di/src/registries/ProviderRegistry.spec.ts b/packages/di/src/registries/ProviderRegistry.spec.ts index ab6839c7401..2ecd91cd013 100644 --- a/packages/di/src/registries/ProviderRegistry.spec.ts +++ b/packages/di/src/registries/ProviderRegistry.spec.ts @@ -40,7 +40,7 @@ describe("ProviderRegistry", () => { registerProvider({provide: Test}); expect(GlobalProviders.merge).to.have.been.calledWithExactly(Test, { - provide: Test, + provide: Test }); }); }); @@ -66,7 +66,7 @@ describe("ProviderRegistry", () => { provide: token, useValue: "myValue", scope: ProviderScope.SINGLETON, - type: ProviderType.VALUE, + type: ProviderType.VALUE }); }); @@ -79,7 +79,7 @@ describe("ProviderRegistry", () => { provide: token, useValue: "myValue", scope: ProviderScope.REQUEST, - type: ProviderType.VALUE, + type: ProviderType.VALUE }); }); }); @@ -106,7 +106,7 @@ describe("ProviderRegistry", () => { provide: token, useFactory: Sinon.match.func, scope: ProviderScope.SINGLETON, - type: ProviderType.FACTORY, + type: ProviderType.FACTORY }); // @ts-ignore @@ -121,14 +121,14 @@ describe("ProviderRegistry", () => { scope: ProviderScope.REQUEST, useFactory() { return {factory: "factory"}; - }, + } }); expect(GlobalProviders.getRegistry(ProviderType.FACTORY).merge).to.have.been.calledWithExactly(token, { provide: token, useFactory: Sinon.match.func, scope: ProviderScope.REQUEST, - type: ProviderType.FACTORY, + type: ProviderType.FACTORY }); }); }); diff --git a/packages/di/src/registries/ProviderRegistry.ts b/packages/di/src/registries/ProviderRegistry.ts index a84f0477f58..e5004411793 100644 --- a/packages/di/src/registries/ProviderRegistry.ts +++ b/packages/di/src/registries/ProviderRegistry.ts @@ -28,7 +28,7 @@ GlobalProviders.createRegistry(ProviderType.INTERCEPTOR, Provider); * */ GlobalProviders.createRegistry(ProviderType.CONTROLLER, Provider, { - injectable: false, + injectable: false }); /** @@ -109,7 +109,7 @@ export function registerProvider(provider: Partial>): void { export const registerFactory = (provider: any | IProvider, instance?: any): void => { if (!provider.provide) { provider = { - provide: provider, + provide: provider }; } @@ -118,7 +118,7 @@ export const registerFactory = (provider: any | IProvider, instance?: any): scope: ProviderScope.SINGLETON, useFactory() { return instance; - }, + } }, provider, {type: ProviderType.FACTORY} @@ -150,14 +150,14 @@ export const registerFactory = (provider: any | IProvider, instance?: any): export const registerValue = (provider: any | IProvider, value?: any): void => { if (!provider.provide) { provider = { - provide: provider, + provide: provider }; } provider = Object.assign( { scope: ProviderScope.SINGLETON, - useValue: value, + useValue: value }, provider, {type: ProviderType.VALUE} diff --git a/packages/di/src/services/DIConfiguration.spec.ts b/packages/di/src/services/DIConfiguration.spec.ts index 6fe54f091b8..b7c2320cca6 100644 --- a/packages/di/src/services/DIConfiguration.spec.ts +++ b/packages/di/src/services/DIConfiguration.spec.ts @@ -9,18 +9,18 @@ describe("DIConfiguration", () => { configuration.set({ scopes: { - [ProviderType.VALUE]: ProviderScope.SINGLETON, + [ProviderType.VALUE]: ProviderScope.SINGLETON }, shouldResolved: "${scopes.value}", shouldResolved2: "", - shouldResolved3: "{{scopes.value}}", + shouldResolved3: "{{scopes.value}}" }); // WHEN configuration.merge({ scopes: { [ProviderType.VALUE]: ProviderScope.INSTANCE, - [ProviderType.PROVIDER]: ProviderScope.SINGLETON, - }, + [ProviderType.PROVIDER]: ProviderScope.SINGLETON + } }); // THEN @@ -30,12 +30,12 @@ describe("DIConfiguration", () => { "scopes", { provider: "singleton", - value: "singleton", - }, + value: "singleton" + } ], ["shouldResolved", "${scopes.value}"], ["shouldResolved2", ""], - ["shouldResolved3", "{{scopes.value}}"], + ["shouldResolved3", "{{scopes.value}}"] ]); expect(configuration.get("shouldResolved")!).to.eq("singleton"); diff --git a/packages/di/src/services/DIConfiguration.ts b/packages/di/src/services/DIConfiguration.ts index 9d96c8bd082..2b946907511 100644 --- a/packages/di/src/services/DIConfiguration.ts +++ b/packages/di/src/services/DIConfiguration.ts @@ -12,7 +12,7 @@ export class DIConfiguration { scopes: {}, resolvers: [], imports: [], - ...initialProps, + ...initialProps }).forEach(([key, value]) => { this.default.set(key, value); }); @@ -56,7 +56,7 @@ export class DIConfiguration { ownKeys(target: DIConfiguration): PropertyKey[] { return Reflect.ownKeys(target).concat(Array.from(target.default.keys())).concat(Array.from(target.map.keys())); - }, + } }); } diff --git a/packages/di/src/services/InjectorService.spec.ts b/packages/di/src/services/InjectorService.spec.ts index 40999f82514..37344a8a962 100644 --- a/packages/di/src/services/InjectorService.spec.ts +++ b/packages/di/src/services/InjectorService.spec.ts @@ -106,7 +106,7 @@ describe("InjectorService", () => { expect(injector.get).to.have.been.calledWithExactly(token); expect((injector as any).resolve).to.have.been.calledWithExactly(token, locals, {rebuild: true}); expect((injector as any).invoke).to.have.been.calledWithExactly(InjectorService, locals, { - parent: token, + parent: token }); }); }); @@ -230,7 +230,7 @@ describe("InjectorService", () => { const token = class Test {}; const registry = { - onInvoke: Sinon.stub(), + onInvoke: Sinon.stub() }; // @ts-ignore @@ -514,11 +514,11 @@ describe("InjectorService", () => { injector.add(token, { deps: [Provider], configuration: { - test: "test", + test: "test" }, useFactory(provider: any) { return {to: provider}; - }, + } }); // WHEN @@ -537,7 +537,7 @@ describe("InjectorService", () => { deps: [Configuration], useFactory(settings: any) { return {to: settings}; - }, + } }); // WHEN @@ -571,20 +571,20 @@ describe("InjectorService", () => { const injectableProperties = { testMethod: { - bindingType: "method", + bindingType: "method" }, testProp: { - bindingType: "property", + bindingType: "property" }, testConst: { - bindingType: "constant", + bindingType: "constant" }, testValue: { - bindingType: "value", + bindingType: "value" }, testInterceptor: { - bindingType: "interceptor", - }, + bindingType: "interceptor" + } }; Store.from(TestBind).set(INJECTABLE_PROP, injectableProperties); @@ -641,7 +641,7 @@ describe("InjectorService", () => { { bindingType: "property", propertyKey: "prop", - useType: InjectorService, + useType: InjectorService } as any, new Map(), {} @@ -743,7 +743,7 @@ describe("InjectorService", () => { injector.bindInterceptor(instance, { bindingType: "interceptor", propertyKey: "test3", - useType: InterceptorTest, + useType: InterceptorTest } as any); const result = (instance as any).test3("test"); @@ -777,7 +777,7 @@ describe("InjectorService", () => { injector.bindInterceptor(instance, { bindingType: "interceptor", propertyKey: "test3", - useType: InterceptorTest, + useType: InterceptorTest } as any); const result = (instance as any).test3("test"); @@ -797,29 +797,29 @@ describe("InjectorService", () => { injector.settings.set({ scopes: { - [ProviderType.VALUE]: ProviderScope.SINGLETON, - }, + [ProviderType.VALUE]: ProviderScope.SINGLETON + } }); expect(injector.settings.get("scopes")).to.deep.eq({ - [ProviderType.VALUE]: ProviderScope.SINGLETON, + [ProviderType.VALUE]: ProviderScope.SINGLETON }); injector.add(Symbol.for("TOKEN1"), { configuration: { custom: "config", scopes: { - provider_custom: ProviderScope.SINGLETON, - }, - }, + provider_custom: ProviderScope.SINGLETON + } + } }); injector.add(Symbol.for("TOKEN2"), { configuration: { scopes: { - provider_custom_2: ProviderScope.SINGLETON, - }, - }, + provider_custom_2: ProviderScope.SINGLETON + } + } }); // WHEN @@ -830,7 +830,7 @@ describe("InjectorService", () => { expect(injector.settings.get("scopes")).to.deep.eq({ provider_custom_2: "singleton", provider_custom: "singleton", - value: "singleton", + value: "singleton" }); }); }); @@ -853,7 +853,7 @@ describe("InjectorService", () => { const container = new Container(); container.add(MyService, { - deps: [ExternalService], + deps: [ExternalService] }); // WHEN diff --git a/packages/di/src/services/InjectorService.ts b/packages/di/src/services/InjectorService.ts index 0716b3c2189..a7d3f1e46e9 100644 --- a/packages/di/src/services/InjectorService.ts +++ b/packages/di/src/services/InjectorService.ts @@ -9,7 +9,7 @@ import { Metadata, nameOf, prototypeOf, - Store, + Store } from "@tsed/core"; import * as util from "util"; @@ -31,7 +31,7 @@ import { IInvokeOptions, InjectablePropertyType, ProviderScope, - TokenProvider, + TokenProvider } from "../interfaces"; import {GlobalProviders} from "../registries/GlobalProviders"; import {DIConfiguration} from "./DIConfiguration"; @@ -71,7 +71,7 @@ interface InvokeSettings { */ @Injectable({ scope: ProviderScope.SINGLETON, - global: true, + global: true }) export class InjectorService extends Container { public settings: TsED.Configuration & DIConfiguration = new DIConfiguration() as any; @@ -346,7 +346,7 @@ export class InjectorService extends Container { return { ...properties, - ...(store.get(INJECTABLE_PROP) || {}), + ...(store.get(INJECTABLE_PROP) || {}) }; }, {}); @@ -410,7 +410,7 @@ export class InjectorService extends Container { locals.delete(DI_PARAM_OPTIONS); Object.defineProperty(instance, propertyKey, { - get: () => bean, + get: () => bean }); } @@ -425,7 +425,7 @@ export class InjectorService extends Container { get: () => this.settings.get(expression) || defaultValue, set: (value: any) => this.settings.set(expression, value), enumerable: true, - configurable: true, + configurable: true }; Object.defineProperty(instance, propertyKey, descriptor); } @@ -449,7 +449,7 @@ export class InjectorService extends Container { get: () => clone(this.settings.get(expression)), enumerable: true, - configurable: true, + configurable: true }; Object.defineProperty(instance, propertyKey, descriptor); @@ -483,7 +483,7 @@ export class InjectorService extends Container { args, options, proceed: util.deprecate(next, "context.proceed() is deprecated. Use context.next() or next() parameters instead."), - next, + next }; const interceptor = this.get(useType)!; @@ -500,7 +500,7 @@ export class InjectorService extends Container { return interceptor.intercept!( { ...context, - options, + options }, next ); @@ -646,7 +646,7 @@ export class InjectorService extends Container { imports: imports || [], isBindable, construct, - provider, + provider }; } } diff --git a/packages/di/test/integration/configuration.spec.ts b/packages/di/test/integration/configuration.spec.ts index cb00adcc22f..4fd89beb144 100644 --- a/packages/di/test/integration/configuration.spec.ts +++ b/packages/di/test/integration/configuration.spec.ts @@ -17,23 +17,23 @@ describe("DI", () => { @Module({ mount: { - "/rest": [ControllerModule], - }, + "/rest": [ControllerModule] + } }) class MyModule {} const injector = createInjector({ mount: { - "/rest": [ControllerGlobal], + "/rest": [ControllerGlobal] }, - imports: [MyModule], + imports: [MyModule] }); injector.add(MyModule); injector.resolveConfiguration(); expect(injector.settings.mount).to.deep.eq({ - "/rest": [ControllerModule, ControllerGlobal], + "/rest": [ControllerModule, ControllerGlobal] }); }); }); diff --git a/packages/di/test/integration/di.spec.ts b/packages/di/test/integration/di.spec.ts index d2eef2745ff..7e987e02c47 100644 --- a/packages/di/test/integration/di.spec.ts +++ b/packages/di/test/integration/di.spec.ts @@ -9,7 +9,7 @@ import { OnDestroy, ProviderScope, Scope, - Service, + Service } from "../../src"; describe("DI", () => { diff --git a/packages/di/test/integration/resolvers.spec.ts b/packages/di/test/integration/resolvers.spec.ts index e3f084690d2..7122b99566f 100644 --- a/packages/di/test/integration/resolvers.spec.ts +++ b/packages/di/test/integration/resolvers.spec.ts @@ -20,7 +20,7 @@ describe("DI Resolvers", () => { const container = new Container(); container.add(MyService, { - deps: [ExternalService], + deps: [ExternalService] }); // WHEN diff --git a/packages/exceptions/src/core/Exception.spec.ts b/packages/exceptions/src/core/Exception.spec.ts index e31d34d110f..499ce207347 100644 --- a/packages/exceptions/src/core/Exception.spec.ts +++ b/packages/exceptions/src/core/Exception.spec.ts @@ -8,7 +8,7 @@ describe("Exception", () => { exception.setHeader("key", "value"); expect(exception.headers).to.deep.equal({ - key: "value", + key: "value" }); expect(exception.status).to.equal(500); expect(exception.toString()).to.equal("HTTP_EXCEPTION(500): test, innerException: test"); @@ -19,7 +19,7 @@ describe("Exception", () => { exception.setHeaders({key: "value"}); expect(exception.headers).to.deep.equal({ - key: "value", + key: "value" }); expect(exception.status).to.equal(203); expect(exception.toString()).to.equal("HTTP_EXCEPTION(203): test, innerException: test"); diff --git a/packages/exceptions/src/core/Exception.ts b/packages/exceptions/src/core/Exception.ts index 589f38252b3..6bdb176c4fb 100644 --- a/packages/exceptions/src/core/Exception.ts +++ b/packages/exceptions/src/core/Exception.ts @@ -45,7 +45,7 @@ export class Exception extends Error { setHeaders(headers: {[key: string]: any}) { this.headers = { ...this.headers, - ...headers, + ...headers }; return this; diff --git a/packages/exceptions/test/clientErrors.spec.ts b/packages/exceptions/test/clientErrors.spec.ts index bd12ac64b53..5e513a73fd2 100644 --- a/packages/exceptions/test/clientErrors.spec.ts +++ b/packages/exceptions/test/clientErrors.spec.ts @@ -26,7 +26,7 @@ import { UnprocessableEntity, UnsupportedMediaType, UpgradeRequired, - ExpectationFailed, + ExpectationFailed } from "@tsed/exceptions"; import {expect} from "chai"; diff --git a/packages/exceptions/test/redirections.spec.ts b/packages/exceptions/test/redirections.spec.ts index f820d636063..875485899b3 100644 --- a/packages/exceptions/test/redirections.spec.ts +++ b/packages/exceptions/test/redirections.spec.ts @@ -9,7 +9,7 @@ import { TemporaryRedirect, TooManyRedirects, UseProxy, - NotModified, + NotModified } from "@tsed/exceptions"; describe("Redirections", () => { diff --git a/packages/exceptions/test/serverErrors.spec.ts b/packages/exceptions/test/serverErrors.spec.ts index b3993293663..4c02c806fc4 100644 --- a/packages/exceptions/test/serverErrors.spec.ts +++ b/packages/exceptions/test/serverErrors.spec.ts @@ -9,7 +9,7 @@ import { NotImplemented, ProxyError, ServiceUnvailable, - VariantAlsoNegotiates, + VariantAlsoNegotiates } from "@tsed/exceptions"; import {expect} from "chai"; diff --git a/packages/graphql/src/registries/DataSourceServiceRegistry.ts b/packages/graphql/src/registries/DataSourceServiceRegistry.ts index e7ead4cf417..faa22b098b2 100644 --- a/packages/graphql/src/registries/DataSourceServiceRegistry.ts +++ b/packages/graphql/src/registries/DataSourceServiceRegistry.ts @@ -15,7 +15,7 @@ export const DataSourceServiceRegistry: TypedProvidersRegistry = GlobalProviders PROVIDER_TYPE_DATASOURCE_SERVICE, Provider, { - injectable: true, + injectable: true } ); /** diff --git a/packages/graphql/src/registries/ResolverServiceRegistry.ts b/packages/graphql/src/registries/ResolverServiceRegistry.ts index 8704a81e134..866fa6136cf 100644 --- a/packages/graphql/src/registries/ResolverServiceRegistry.ts +++ b/packages/graphql/src/registries/ResolverServiceRegistry.ts @@ -12,7 +12,7 @@ export const PROVIDER_TYPE_RESOLVER_SERVICE = "graphQLResolverService"; */ // tslint:disable-next-line: variable-name export const ResolverServiceRegistry: TypedProvidersRegistry = GlobalProviders.createRegistry(PROVIDER_TYPE_RESOLVER_SERVICE, Provider, { - injectable: true, + injectable: true }); /** * Add a new service in the `ProviderRegistry`. This service will be built when `InjectorService` will be loaded. diff --git a/packages/graphql/src/services/GraphQLService.spec.ts b/packages/graphql/src/services/GraphQLService.spec.ts index 6e18e2349d5..c59e27c06c5 100644 --- a/packages/graphql/src/services/GraphQLService.spec.ts +++ b/packages/graphql/src/services/GraphQLService.spec.ts @@ -19,8 +19,8 @@ class ApolloServer { const {GraphQLService} = proxyquire("../../src/services/GraphQLService", { "apollo-server-express": { - ApolloServer, - }, + ApolloServer + } }); describe("GraphQLService", () => { @@ -50,7 +50,7 @@ describe("GraphQLService", () => { // WHEN const result1 = await service.createServer("key", { - path: "/path", + path: "/path" } as any); const result2 = await service.createServer("key", {path: "/path"} as any); @@ -58,12 +58,12 @@ describe("GraphQLService", () => { expect(result1.args).to.deep.eq([{schema: {schema: "schema"}, dataSources: noop}]); expect(service.createSchema).to.have.been.calledOnceWithExactly({ resolvers: [], - container: service.injectorService, + container: service.injectorService }); expect(result1.applyMiddleware).to.have.been.calledOnceWithExactly( Sinon.match({ app: Sinon.match.func, - path: "/path", + path: "/path" }) ); }); @@ -99,19 +99,19 @@ describe("GraphQLService", () => { server(options: any) { return new ApolloServer(options); }, - installSubscriptionHandlers: true, + installSubscriptionHandlers: true } as any); expect(result.args).to.deep.eq([{schema: {schema: "schema"}, dataSources: noop}]); expect(service.createSchema).to.have.been.calledOnceWithExactly({ resolvers: [], - container: service.injectorService, + container: service.injectorService }); expect(result.applyMiddleware).to.have.been.calledOnceWithExactly( Sinon.match({ app: Sinon.match.func, - path: "/path", + path: "/path" }) ); @@ -140,7 +140,7 @@ describe("GraphQLService", () => { service.createSchema.returns({schema: "schema"}); await service.createServer("key", { - path: "/path", + path: "/path" } as any); // WHEN @@ -154,17 +154,17 @@ describe("GraphQLService", () => { "should return a function with all dataSources", PlatformTest.inject([GraphQLService], (service: any) => { const dataSources = sandbox.stub().returns({ - api: "api", + api: "api" }); const serverConfigSources = sandbox.stub().returns({ - api2: "api2", + api2: "api2" }); const fn = service.createDataSources(dataSources, serverConfigSources); expect(fn()).to.deep.eq({ api2: "api2", - api: "api", + api: "api" }); }) ); @@ -187,8 +187,8 @@ describe("GraphQLService", () => { sandbox.stub(service.injectorService, "getProviders").returns([ { name: DataSource.name, - provide: DataSource, - }, + provide: DataSource + } ]); sandbox.stub(service.injectorService, "invoke").returns(new DataSource()); }) @@ -200,7 +200,7 @@ describe("GraphQLService", () => { const result = service.getDataSources(); expect(result).to.deep.eq({ - dataSource: new DataSource(), + dataSource: new DataSource() }); }); }); diff --git a/packages/graphql/src/services/GraphQLService.ts b/packages/graphql/src/services/GraphQLService.ts index e98c9672d99..9520f0059de 100644 --- a/packages/graphql/src/services/GraphQLService.ts +++ b/packages/graphql/src/services/GraphQLService.ts @@ -36,7 +36,7 @@ export class GraphQLService { dataSources, serverConfig = {}, serverRegistration = {}, - buildSchemaOptions = {} as any, + buildSchemaOptions = {} as any } = settings; if (this.has(id)) { @@ -58,13 +58,13 @@ export class GraphQLService { const schema = await this.createSchema({ container: this.injectorService, ...buildSchemaOptions, - resolvers: [...this.getResolvers(), ...resolvers, ...(buildSchemaOptions.resolvers || [])], + resolvers: [...this.getResolvers(), ...resolvers, ...(buildSchemaOptions.resolvers || [])] }); const defaultServerConfig = { ...serverConfig, dataSources: this.createDataSources(dataSources, serverConfig.dataSources), - schema, + schema }; const server = customServer ? customServer(defaultServerConfig) : new ApolloServer(defaultServerConfig); @@ -78,7 +78,7 @@ export class GraphQLService { this._servers.set(id || "default", { instance: server, - schema, + schema }); return server; @@ -158,7 +158,7 @@ export class GraphQLService { return { ...sources, ...(dataSources ? dataSources() : {}), - ...(serverConfigSources ? serverConfigSources() : {}), + ...(serverConfigSources ? serverConfigSources() : {}) }; }; } diff --git a/packages/graphql/test/app/Server.ts b/packages/graphql/test/app/Server.ts index 5c0c45df6a3..c4f0591013d 100644 --- a/packages/graphql/test/app/Server.ts +++ b/packages/graphql/test/app/Server.ts @@ -15,7 +15,7 @@ const rootDir = resolve(__dirname); httpsPort: false, logger: { level: "info", - logRequest: true, + logRequest: true }, mount: {}, componentsScan: ["${rootDir}/services/**/*.ts", "${rootDir}/graphql/**/*.ts"], @@ -23,10 +23,10 @@ const rootDir = resolve(__dirname); default: { path: "/api/graphql", buildSchemaOptions: { - emitSchemaFile: resolve(__dirname, "../ressources/schema.gql"), - }, - }, - }, + emitSchemaFile: resolve(__dirname, "../ressources/schema.gql") + } + } + } }) export class Server { @Inject() @@ -41,7 +41,7 @@ export class Server { .use(bodyParser.json()) .use( bodyParser.urlencoded({ - extended: true, + extended: true }) ) .use(cookieParser()) diff --git a/packages/graphql/test/app/services/RecipeService.ts b/packages/graphql/test/app/services/RecipeService.ts index 0e74cb76a06..07bc4a67eb4 100644 --- a/packages/graphql/test/app/services/RecipeService.ts +++ b/packages/graphql/test/app/services/RecipeService.ts @@ -9,8 +9,8 @@ export class RecipeService { title: "title", description: "Description", creationDate: new Date("2020-08-20"), - ingredients: [], - }), + ingredients: [] + }) ]; async findById(id: string) { diff --git a/packages/graphql/test/graphql.spec.ts b/packages/graphql/test/graphql.spec.ts index f881b373d45..13dd472feff 100644 --- a/packages/graphql/test/graphql.spec.ts +++ b/packages/graphql/test/graphql.spec.ts @@ -28,7 +28,7 @@ describe("GraphQL", () => { it("should get recipes", async () => { const response = await request.query({ query: GET_RECIPES, - variables: {}, + variables: {} }); expect(response.data).to.deep.eq({ @@ -36,9 +36,9 @@ describe("GraphQL", () => { { creationDate: "2020-08-20T00:00:00.000Z", description: "Description", - title: "title", - }, - ], + title: "title" + } + ] }); }); }); diff --git a/packages/json-mapper/src/components/ArrayMapper.spec.ts b/packages/json-mapper/src/components/ArrayMapper.spec.ts index fa1c3839d18..97bad11c2f0 100644 --- a/packages/json-mapper/src/components/ArrayMapper.spec.ts +++ b/packages/json-mapper/src/components/ArrayMapper.spec.ts @@ -10,7 +10,7 @@ describe("ArrayMapper", () => { type: String, collectionType: Array, next: Sinon.stub().callsFake((o) => String("testMap")), - options: {}, + options: {} }); const arrayMapper = new ArrayMapper(); @@ -26,7 +26,7 @@ describe("ArrayMapper", () => { type: String, collectionType: Array, next: Sinon.stub().callsFake((o) => String("testMap")), - options: {}, + options: {} }); const arrayMapper = new ArrayMapper(); diff --git a/packages/json-mapper/src/components/MapMapper.spec.ts b/packages/json-mapper/src/components/MapMapper.spec.ts index 7f24d2cda2e..de83c19df88 100644 --- a/packages/json-mapper/src/components/MapMapper.spec.ts +++ b/packages/json-mapper/src/components/MapMapper.spec.ts @@ -10,14 +10,14 @@ describe("MapMapper", () => { type: String, collectionType: Map, next: Sinon.stub().callsFake((o) => String("testMap")), - options: {}, + options: {} }); const mapper = new MapMapper(); const value = mapper.deserialize( { - test: "test", + test: "test" }, ctx ); @@ -31,7 +31,7 @@ describe("MapMapper", () => { const ctx = { type: String, collectionType: Array, - next: Sinon.stub().callsFake((o) => String("testMap")), + next: Sinon.stub().callsFake((o) => String("testMap")) }; const mapper = new MapMapper(); diff --git a/packages/json-mapper/src/components/PrimitiveMapper.spec.ts b/packages/json-mapper/src/components/PrimitiveMapper.spec.ts index 687580bdfb2..4aba48d8de2 100644 --- a/packages/json-mapper/src/components/PrimitiveMapper.spec.ts +++ b/packages/json-mapper/src/components/PrimitiveMapper.spec.ts @@ -10,7 +10,7 @@ describe("PrimitiveMapper", () => { const ctx = { type: String, collectionType: undefined, - next: Sinon.stub(), + next: Sinon.stub() }; const value = mapper.deserialize(data, ctx); @@ -23,7 +23,7 @@ describe("PrimitiveMapper", () => { const ctx = { type: String, collectionType: undefined, - next: Sinon.stub(), + next: Sinon.stub() }; const value = mapper.deserialize(data, ctx); @@ -36,7 +36,7 @@ describe("PrimitiveMapper", () => { const ctx = { type: Number, collectionType: undefined, - next: Sinon.stub(), + next: Sinon.stub() }; const value = mapper.deserialize(data, ctx); @@ -49,7 +49,7 @@ describe("PrimitiveMapper", () => { const ctx = { type: Number, collectionType: undefined, - next: Sinon.stub(), + next: Sinon.stub() }; const value = mapper.deserialize(data, ctx); @@ -62,7 +62,7 @@ describe("PrimitiveMapper", () => { const ctx = { type: Number, collectionType: undefined, - next: Sinon.stub(), + next: Sinon.stub() }; const value = mapper.deserialize(data, ctx); @@ -75,7 +75,7 @@ describe("PrimitiveMapper", () => { const ctx = { type: Number, collectionType: undefined, - next: Sinon.stub(), + next: Sinon.stub() }; const value = mapper.deserialize(data, ctx); @@ -88,7 +88,7 @@ describe("PrimitiveMapper", () => { const ctx = { type: Number, collectionType: undefined, - next: Sinon.stub(), + next: Sinon.stub() }; let actualError: any; @@ -105,7 +105,7 @@ describe("PrimitiveMapper", () => { const ctx = { type: Boolean, collectionType: undefined, - next: Sinon.stub(), + next: Sinon.stub() }; expect(mapper.deserialize(1, ctx)).to.deep.eq(true); @@ -118,7 +118,7 @@ describe("PrimitiveMapper", () => { const ctx = { type: Boolean, collectionType: undefined, - next: Sinon.stub(), + next: Sinon.stub() }; expect(mapper.deserialize(0, ctx)).to.deep.eq(false); @@ -133,7 +133,7 @@ describe("PrimitiveMapper", () => { const ctx = { type: Boolean, collectionType: undefined, - next: Sinon.stub(), + next: Sinon.stub() }; expect(mapper.deserialize(null, ctx)).to.deep.eq(null); diff --git a/packages/json-mapper/src/components/SetMapper.spec.ts b/packages/json-mapper/src/components/SetMapper.spec.ts index 168645966b3..b92421251a8 100644 --- a/packages/json-mapper/src/components/SetMapper.spec.ts +++ b/packages/json-mapper/src/components/SetMapper.spec.ts @@ -10,7 +10,7 @@ describe("SetMapper", () => { type: String, collectionType: Set, next: Sinon.stub().callsFake((o) => String("testMap")), - options: {}, + options: {} }); const mapper = new SetMapper(); @@ -26,7 +26,7 @@ describe("SetMapper", () => { const ctx = { type: String, collectionType: Set, - next: Sinon.stub().callsFake((o) => String("testMap")), + next: Sinon.stub().callsFake((o) => String("testMap")) }; const arrayMapper = new SetMapper(); diff --git a/packages/json-mapper/src/domain/JsonMapperContext.ts b/packages/json-mapper/src/domain/JsonMapperContext.ts index 636d0dbc065..fae249ff011 100644 --- a/packages/json-mapper/src/domain/JsonMapperContext.ts +++ b/packages/json-mapper/src/domain/JsonMapperContext.ts @@ -22,7 +22,7 @@ export class JsonMapperContext implements JsonMapperCtx { next(data: any) { return this._next(data, { ...this.options, - type: this.type, + type: this.type }); } } diff --git a/packages/json-mapper/src/utils/deserialize.spec.ts b/packages/json-mapper/src/utils/deserialize.spec.ts index 28dc13bacef..e8ebb86c323 100644 --- a/packages/json-mapper/src/utils/deserialize.spec.ts +++ b/packages/json-mapper/src/utils/deserialize.spec.ts @@ -11,7 +11,7 @@ import { Name, OperationPath, Property, - Required, + Required } from "@tsed/schema"; import {expect} from "chai"; import {Post} from "../../test/helpers/Post"; @@ -25,7 +25,7 @@ function mapToObject(value: any): any { return Array.from(value.entries()).reduce((obj: any, [key, value]) => { return { ...obj, - [key]: value, + [key]: value }; }, {}); } @@ -83,7 +83,7 @@ describe("deserialize()", () => { {}, { collectionType: Array, - type: Object, + type: Object } ) ).to.deep.equal([{}]); @@ -97,7 +97,7 @@ describe("deserialize()", () => { expect(mapToObject(deserialize(false, options))).to.deep.equal({}); expect(mapToObject(deserialize(true, options))).to.deep.equal({}); expect(mapToObject(deserialize({test: 1}, options))).to.deep.equal({ - test: "1", + test: "1" }); }); }); @@ -157,7 +157,7 @@ describe("deserialize()", () => { password: "string", mapped_prop: "mappedProp", roles: undefined, - add: true, + add: true }, {type: Model, additionalProperties: false} ); @@ -167,7 +167,7 @@ describe("deserialize()", () => { id: "id", mappedProp: "mappedProptest", password: "string", - roles: new Map(), + roles: new Map() }); }); it("should transform object to class (additionalProperties = false)", () => { @@ -202,10 +202,10 @@ describe("deserialize()", () => { mapped_prop: "mappedProp", roles: { role1: { - label: "role", - }, + label: "role" + } }, - add: true, + add: true }, {type: Model, additionalProperties: false} ); @@ -215,7 +215,7 @@ describe("deserialize()", () => { id: "id", mappedProp: "mappedProptest", password: "string", - roles: new Map().set("role1", new Role({label: "role"})), + roles: new Map().set("role1", new Role({label: "role"})) }); }); it("should transform object to class (additionalProperties = true)", () => { @@ -250,10 +250,10 @@ describe("deserialize()", () => { mapped_prop: "mappedProp", roles: { role1: { - label: "role", - }, + label: "role" + } }, - add: true, + add: true }, {type: Model, additionalProperties: true} ); @@ -264,7 +264,7 @@ describe("deserialize()", () => { mappedProp: "mappedProptest", password: "string", roles: new Map().set("role1", new Role({label: "role"})), - add: true, + add: true }); }); it("should transform object to class (inherited class)", () => { @@ -301,10 +301,10 @@ describe("deserialize()", () => { mapped_prop: "mappedProp", roles: { role1: { - label: "role", - }, + label: "role" + } }, - add: true, + add: true }, {type: Model} ); @@ -314,7 +314,7 @@ describe("deserialize()", () => { id: "id", mappedProp: "mappedProptest", password: "string", - roles: new Map().set("role1", new Role({label: "role"})), + roles: new Map().set("role1", new Role({label: "role"})) }); }); it("should transform object to class (recursive class)", () => { @@ -325,10 +325,10 @@ describe("deserialize()", () => { name: "name", posts: [ { - id: "id", - }, - ], - }, + id: "id" + } + ] + } }, {type: Post} ); @@ -342,10 +342,10 @@ describe("deserialize()", () => { name: "name", posts: [ { - id: "id", - }, - ], - }, + id: "id" + } + ] + } }); }); }); @@ -383,11 +383,11 @@ describe("deserialize()", () => { mapped_prop: "mappedProp", roles: { role1: { - label: "role", - }, + label: "role" + } }, - add: true, - }, + add: true + } ], {type: Model, collectionType: Array, additionalProperties: false} ); @@ -398,8 +398,8 @@ describe("deserialize()", () => { id: "id", mappedProp: "mappedProptest", password: "string", - roles: new Map().set("role1", new Role({label: "role"})), - }, + roles: new Map().set("role1", new Role({label: "role"})) + } ]); }); it("should transform object to class (array parameter)", () => { @@ -420,19 +420,19 @@ describe("deserialize()", () => { const result = deserialize( [ { - title: "title", - }, + title: "title" + } ], { - store: JsonEntityStore.from(Controller, "method", 0), + store: JsonEntityStore.from(Controller, "method", 0) } ); expect(result[0]).to.be.instanceof(Product); expect(result).to.deep.eq([ { - title: "title", - }, + title: "title" + } ]); }); }); @@ -477,11 +477,11 @@ describe("deserialize()", () => { { _id: "id", data: { - title: "title", - }, + title: "title" + } }, { - store: JsonEntityStore.from(Controller, "method", 0), + store: JsonEntityStore.from(Controller, "method", 0) } ); @@ -490,19 +490,19 @@ describe("deserialize()", () => { expect(result).to.deep.eq({ _id: "id", data: { - title: "title", - }, + title: "title" + } }); const result2 = deserialize( { _id: "id", data: { - id: "id", - }, + id: "id" + } }, { - store: JsonEntityStore.from(Controller2, "method", 0), + store: JsonEntityStore.from(Controller2, "method", 0) } ); @@ -511,8 +511,8 @@ describe("deserialize()", () => { expect(result2).to.deep.eq({ _id: "id", data: { - id: "id", - }, + id: "id" + } }); }); it("should transform object to class (generics property)", () => { @@ -554,9 +554,9 @@ describe("deserialize()", () => { name: "name", id: "id", role: { - level: "level", - }, - }, + level: "level" + } + } }, {store: JsonEntityStore.from(Content)} ); @@ -570,9 +570,9 @@ describe("deserialize()", () => { id: "id", name: "name", role: { - level: "level", - }, - }, + level: "level" + } + } }); }); }); diff --git a/packages/json-mapper/src/utils/deserialize.ts b/packages/json-mapper/src/utils/deserialize.ts index 01ed7585580..53f6e8da8e4 100644 --- a/packages/json-mapper/src/utils/deserialize.ts +++ b/packages/json-mapper/src/utils/deserialize.ts @@ -46,7 +46,7 @@ function transformCollection(src: any, options: JsonDeserializerOptions type, collectionType, options, - next: (data, {collectionType, ...options}) => deserialize(data, options), + next: (data, {collectionType, ...options}) => deserialize(data, options) }); return types?.get(options.collectionType)?.deserialize(src, context); @@ -58,7 +58,7 @@ function transformType(src: any, options: JsonDeserializerOptions deserialize(data, options), + next: (data, {type, ...options}) => deserialize(data, options) }); return types?.get(type)?.deserialize(src, context); @@ -101,7 +101,7 @@ export function plainObjectToClass(src: any, options: JsonDeserializerO value = deserialize(value, { ...next, - collectionType: propStore.collectionType, + collectionType: propStore.collectionType }); if (value !== undefined) { @@ -132,7 +132,7 @@ function buildOptions(options: JsonDeserializerOptions): any { return { ...options, - types: options.types ? options.types : getJsonMapperTypes(), + types: options.types ? options.types : getJsonMapperTypes() }; } diff --git a/packages/json-mapper/src/utils/serialize.spec.ts b/packages/json-mapper/src/utils/serialize.spec.ts index d000a898e16..aee3e371237 100644 --- a/packages/json-mapper/src/utils/serialize.spec.ts +++ b/packages/json-mapper/src/utils/serialize.spec.ts @@ -50,7 +50,7 @@ describe("serialize()", () => { const result = serialize({ toJSON() { return "hello"; - }, + } }); expect(result).to.deep.equal("hello"); @@ -62,15 +62,15 @@ describe("serialize()", () => { const result = serialize({ prop: "1", - roles: [{label: "Admin"}], + roles: [{label: "Admin"}] }); expect(result).to.deep.equal({ prop: "1", roles: [ { - label: "Admin", - }, - ], + label: "Admin" + } + ] }); }); it("should serialize plain object (2)", () => { @@ -80,13 +80,13 @@ describe("serialize()", () => { const result = serialize({ prop: "1", - roles, + roles }); expect(result).to.deep.equal({ prop: "1", roles: { - ro: "le", - }, + ro: "le" + } }); }); }); @@ -128,9 +128,9 @@ describe("serialize()", () => { mapped_prop: "hellotest", roles: { olo: { - label: "label", - }, - }, + label: "label" + } + } }); expect(serialize(model, {api: true, useAlias: false})).to.deep.equal({ @@ -138,9 +138,9 @@ describe("serialize()", () => { mappedProp: "hellotest", roles: { olo: { - label: "label", - }, - }, + label: "label" + } + } }); }); it("should serialize model Array", () => { @@ -181,10 +181,10 @@ describe("serialize()", () => { mapped_prop: "hellotest", roles: { olo: { - label: "label", - }, - }, - }, + label: "label" + } + } + } ]); }); it("should serialize model (inherited class)", () => { @@ -226,9 +226,9 @@ describe("serialize()", () => { mapped_prop: "hellotest", roles: { olo: { - label: "label", - }, - }, + label: "label" + } + } }); expect(serialize(model, {api: true, useAlias: false})).to.deep.equal({ @@ -236,9 +236,9 @@ describe("serialize()", () => { mappedProp: "hellotest", roles: { olo: { - label: "label", - }, - }, + label: "label" + } + } }); }); it("should serialize model (recursive class)", () => { @@ -257,10 +257,10 @@ describe("serialize()", () => { name: "name", posts: [ { - id: "id", - }, - ], - }, + id: "id" + } + ] + } }); }); }); @@ -296,20 +296,20 @@ describe("serialize()", () => { return { id: "id", password: "hellopassword", - mappedProp: "hello", + mappedProp: "hello" }; }; expect(serialize(model, {type: Model})).to.deep.equal({ id: "id", mapped_prop: "hellotest", - password: "hellopassword", + password: "hellopassword" }); expect(serialize(model, {api: true, useAlias: false})).to.deep.equal({ id: "id", mappedProp: "hello", - password: "hellopassword", + password: "hellopassword" }); }); it("should serialize model Array", () => { @@ -350,10 +350,10 @@ describe("serialize()", () => { mapped_prop: "hellotest", roles: { olo: { - label: "label", - }, - }, - }, + label: "label" + } + } + } ]); }); it("should serialize model (inherited class)", () => { @@ -395,9 +395,9 @@ describe("serialize()", () => { mapped_prop: "hellotest", roles: { olo: { - label: "label", - }, - }, + label: "label" + } + } }); expect(serialize(model, {api: true, useAlias: false})).to.deep.equal({ @@ -405,9 +405,9 @@ describe("serialize()", () => { mappedProp: "hellotest", roles: { olo: { - label: "label", - }, - }, + label: "label" + } + } }); }); it("should serialize model (recursive class)", () => { @@ -426,10 +426,10 @@ describe("serialize()", () => { name: "name", posts: [ { - id: "id", - }, - ], - }, + id: "id" + } + ] + } }); }); }); @@ -440,7 +440,7 @@ describe("serialize()", () => { serialize({ serialize() { return {id: "id"}; - }, + } }) ).to.deep.equal({id: "id"}); }); diff --git a/packages/json-mapper/src/utils/serialize.ts b/packages/json-mapper/src/utils/serialize.ts index a81f3926582..840b387f4cb 100644 --- a/packages/json-mapper/src/utils/serialize.ts +++ b/packages/json-mapper/src/utils/serialize.ts @@ -54,7 +54,7 @@ export function classToPlainObject(obj: any, options: JsonSerializerOptions ({ ...newObj, - [key]: serialize(value, options), + [key]: serialize(value, options) }), {} ); @@ -95,7 +95,7 @@ export function serialize(obj: any, {type, collectionType, ...options}: JsonSeri const context = new JsonMapperContext({ type, options, - next: (data, {type, ...options}) => serialize(data, options), + next: (data, {type, ...options}) => serialize(data, options) }); if (types.has(type)) { diff --git a/packages/mongoose/src/MongooseModule.ts b/packages/mongoose/src/MongooseModule.ts index 06741d35bf8..32b246713ed 100644 --- a/packages/mongoose/src/MongooseModule.ts +++ b/packages/mongoose/src/MongooseModule.ts @@ -4,7 +4,7 @@ import {MONGOOSE_CONNECTIONS} from "./services/MongooseConnections"; import {MongooseService} from "./services/MongooseService"; @Module({ - imports: [MONGOOSE_CONNECTIONS], + imports: [MONGOOSE_CONNECTIONS] }) export class MongooseModule implements AfterRoutesInit { constructor(private platformApplication: PlatformApplication, private mongooseService: MongooseService) {} diff --git a/packages/mongoose/src/decorators/dynamicRef.spec.ts b/packages/mongoose/src/decorators/dynamicRef.spec.ts index 636816228af..a104f4b3015 100644 --- a/packages/mongoose/src/decorators/dynamicRef.spec.ts +++ b/packages/mongoose/src/decorators/dynamicRef.spec.ts @@ -23,7 +23,7 @@ describe("@Ref()", () => { expect(store.get(MONGOOSE_SCHEMA)).to.deep.eq({ type: Schema.Types.ObjectId, - refPath: "RefTest", + refPath: "RefTest" }); }); }); diff --git a/packages/mongoose/src/decorators/dynamicRef.ts b/packages/mongoose/src/decorators/dynamicRef.ts index f036b7df2cd..eaea2b9b73e 100644 --- a/packages/mongoose/src/decorators/dynamicRef.ts +++ b/packages/mongoose/src/decorators/dynamicRef.ts @@ -40,14 +40,14 @@ export function DynamicRef(refPath: string) { Schema({ type: String, example: "5ce7ad3028890bd71749d477", - description: "Mongoose Ref ObjectId", + description: "Mongoose Ref ObjectId" }), StoreFn((store: Store) => { delete store.get("schema").$ref; }), StoreMerge(MONGOOSE_SCHEMA, { type: MongooseSchema.Types.ObjectId, - refPath, + refPath }) ); } diff --git a/packages/mongoose/src/decorators/indexed.spec.ts b/packages/mongoose/src/decorators/indexed.spec.ts index b77a7bdd682..0347b42e7a4 100644 --- a/packages/mongoose/src/decorators/indexed.spec.ts +++ b/packages/mongoose/src/decorators/indexed.spec.ts @@ -14,7 +14,7 @@ describe("@Indexed()", () => { it("should set metadata", () => { expect(this.store.get(MONGOOSE_SCHEMA)).to.deep.eq({ - index: true, + index: true }); }); }); diff --git a/packages/mongoose/src/decorators/model.ts b/packages/mongoose/src/decorators/model.ts index ccaaa83bff1..d7fd9e8c977 100644 --- a/packages/mongoose/src/decorators/model.ts +++ b/packages/mongoose/src/decorators/model.ts @@ -57,7 +57,7 @@ export function Model(options: MongooseModelOptions = {}) { applySchemaOptions(schema, schemaOptions(target)); return createModel(target, schema, options.name, options.collection, options.skipInit, connections.get(options.connection)); - }, + } }); }; } diff --git a/packages/mongoose/src/decorators/mongooseIndex.spec.ts b/packages/mongoose/src/decorators/mongooseIndex.spec.ts index bb2d8df1ea7..21e36587624 100644 --- a/packages/mongoose/src/decorators/mongooseIndex.spec.ts +++ b/packages/mongoose/src/decorators/mongooseIndex.spec.ts @@ -22,11 +22,11 @@ describe("@MongooseIndex()", () => { indexes: [ { fields: { - field: "1", + field: "1" }, - options: {}, - }, - ], + options: {} + } + ] }); }); }); diff --git a/packages/mongoose/src/decorators/mongooseIndex.ts b/packages/mongoose/src/decorators/mongooseIndex.ts index 73e2047f463..e81225c2628 100644 --- a/packages/mongoose/src/decorators/mongooseIndex.ts +++ b/packages/mongoose/src/decorators/mongooseIndex.ts @@ -29,7 +29,7 @@ import {schemaOptions} from "../utils/schemaOptions"; export function MongooseIndex(fields: object, options?: any): Function { return (target: any) => { schemaOptions(target, { - indexes: [{fields, options}], + indexes: [{fields, options}] }); }; } diff --git a/packages/mongoose/src/decorators/mongoosePlugin.spec.ts b/packages/mongoose/src/decorators/mongoosePlugin.spec.ts index 93cc678299a..118dcfb9ebd 100644 --- a/packages/mongoose/src/decorators/mongoosePlugin.spec.ts +++ b/packages/mongoose/src/decorators/mongoosePlugin.spec.ts @@ -20,9 +20,9 @@ describe("@MongoosePlugin()", () => { plugins: [ { plugin: fn, - options: {}, - }, - ], + options: {} + } + ] }); }); }); diff --git a/packages/mongoose/src/decorators/mongoosePlugin.ts b/packages/mongoose/src/decorators/mongoosePlugin.ts index 8aadcdc4d3d..f797ce1c750 100644 --- a/packages/mongoose/src/decorators/mongoosePlugin.ts +++ b/packages/mongoose/src/decorators/mongoosePlugin.ts @@ -13,7 +13,7 @@ import {schemaOptions} from "../utils/schemaOptions"; export function MongoosePlugin(plugin: (schema: mongoose.Schema, options?: any) => void, options?: any): Function { return (target: any) => { schemaOptions(target, { - plugins: [{plugin, options}], + plugins: [{plugin, options}] }); }; } diff --git a/packages/mongoose/src/decorators/postHook.spec.ts b/packages/mongoose/src/decorators/postHook.spec.ts index 7993679b2de..0c1e52c67bf 100644 --- a/packages/mongoose/src/decorators/postHook.spec.ts +++ b/packages/mongoose/src/decorators/postHook.spec.ts @@ -21,9 +21,9 @@ describe("@PostHook()", () => { post: [ { method: "method", - fn, - }, - ], + fn + } + ] }); }); }); @@ -36,7 +36,7 @@ describe("@PostHook()", () => { } const { - post: [options], + post: [options] } = schemaOptions(Test); expect(options.method).to.eq("save"); diff --git a/packages/mongoose/src/decorators/postHook.ts b/packages/mongoose/src/decorators/postHook.ts index 8ec5936f01a..12f820a5f2a 100644 --- a/packages/mongoose/src/decorators/postHook.ts +++ b/packages/mongoose/src/decorators/postHook.ts @@ -55,9 +55,9 @@ export function PostHook(method: string, fn?: MongoosePostHookCB | Mongoose post: [ { method, - fn: fn as MongoosePostHookCB | MongoosePostErrorHookCB, - }, - ], + fn: fn as MongoosePostHookCB | MongoosePostErrorHookCB + } + ] }); }; } diff --git a/packages/mongoose/src/decorators/preHook.spec.ts b/packages/mongoose/src/decorators/preHook.spec.ts index fd8713745ad..dd53de21eca 100644 --- a/packages/mongoose/src/decorators/preHook.spec.ts +++ b/packages/mongoose/src/decorators/preHook.spec.ts @@ -24,9 +24,9 @@ describe("@PreHook()", () => { method: "method", parallel: true, fn, - errorCb, - }, - ], + errorCb + } + ] }); }); }); @@ -36,13 +36,13 @@ describe("@PreHook()", () => { class Test { @PreHook("save", { parallel: true, - errorCb: () => {}, + errorCb: () => {} }) static method() {} } const { - pre: [options], + pre: [options] } = schemaOptions(Test); expect(options.method).to.eq("save"); diff --git a/packages/mongoose/src/decorators/preHook.ts b/packages/mongoose/src/decorators/preHook.ts index 9402961f2b5..24c2dbf42ca 100644 --- a/packages/mongoose/src/decorators/preHook.ts +++ b/packages/mongoose/src/decorators/preHook.ts @@ -71,9 +71,9 @@ export function PreHook( { ...(options || {}), method, - fn: fn as MongoosePostHookCB | MongoosePostErrorHookCB, - }, - ], + fn: fn as MongoosePostHookCB | MongoosePostErrorHookCB + } + ] }); }; } diff --git a/packages/mongoose/src/decorators/ref.spec.ts b/packages/mongoose/src/decorators/ref.spec.ts index fbb73b9defc..66c53f55b00 100644 --- a/packages/mongoose/src/decorators/ref.spec.ts +++ b/packages/mongoose/src/decorators/ref.spec.ts @@ -20,7 +20,7 @@ describe("@Ref()", () => { it("should set metadata", () => { expect(this.store.get(MONGOOSE_SCHEMA)).to.deep.eq({ type: Schema.Types.ObjectId, - ref: "RefTest", + ref: "RefTest" }); }); }); @@ -39,7 +39,7 @@ describe("@Ref()", () => { it("should set metadata", () => { expect(this.store.get(MONGOOSE_SCHEMA)).to.deep.eq({ type: Schema.Types.ObjectId, - ref: "RefTest", + ref: "RefTest" }); }); }); diff --git a/packages/mongoose/src/decorators/ref.ts b/packages/mongoose/src/decorators/ref.ts index f9fe2cf8b24..06f44ded3cc 100644 --- a/packages/mongoose/src/decorators/ref.ts +++ b/packages/mongoose/src/decorators/ref.ts @@ -39,14 +39,14 @@ export function Ref(model: string | any, type: MongooseSchemaTypes = MongooseSch Schema({ type: String, example: "5ce7ad3028890bd71749d477", - description: "Mongoose Ref ObjectId", + description: "Mongoose Ref ObjectId" }), StoreFn((store: Store) => { delete store.get("schema").$ref; }), StoreMerge(MONGOOSE_SCHEMA, { type: MongooseSchema.Types[type], - ref: typeof model === "string" ? model : Store.from(model).get(MONGOOSE_MODEL_NAME), + ref: typeof model === "string" ? model : Store.from(model).get(MONGOOSE_MODEL_NAME) }) ); } diff --git a/packages/mongoose/src/decorators/schemaIgnore.spec.ts b/packages/mongoose/src/decorators/schemaIgnore.spec.ts index 3b78018d3db..98583ce10a9 100644 --- a/packages/mongoose/src/decorators/schemaIgnore.spec.ts +++ b/packages/mongoose/src/decorators/schemaIgnore.spec.ts @@ -10,7 +10,7 @@ describe("@SchemaIgnore()", () => { SchemaIgnore()(Test, "test", descriptorOf(Test, "test")); const store = Store.from(Test, "test", descriptorOf(Test, "test")); expect(store.get(MONGOOSE_SCHEMA)).to.deep.eq({ - schemaIgnore: true, + schemaIgnore: true }); }); }); diff --git a/packages/mongoose/src/decorators/select.spec.ts b/packages/mongoose/src/decorators/select.spec.ts index c2f3fbd6e10..a4ce6d4265d 100644 --- a/packages/mongoose/src/decorators/select.spec.ts +++ b/packages/mongoose/src/decorators/select.spec.ts @@ -14,7 +14,7 @@ describe("@Select()", () => { it("should set metadata", () => { expect(this.store.get(MONGOOSE_SCHEMA)).to.deep.eq({ - select: true, + select: true }); }); }); diff --git a/packages/mongoose/src/decorators/trim.spec.ts b/packages/mongoose/src/decorators/trim.spec.ts index ef9f2248b44..5b63a4e1b90 100644 --- a/packages/mongoose/src/decorators/trim.spec.ts +++ b/packages/mongoose/src/decorators/trim.spec.ts @@ -14,7 +14,7 @@ describe("@Trim()", () => { it("should set metadata", () => { expect(this.store.get(MONGOOSE_SCHEMA)).to.deep.eq({ - trim: true, + trim: true }); }); }); diff --git a/packages/mongoose/src/decorators/unique.spec.ts b/packages/mongoose/src/decorators/unique.spec.ts index d69f36ca12a..52dd8114113 100644 --- a/packages/mongoose/src/decorators/unique.spec.ts +++ b/packages/mongoose/src/decorators/unique.spec.ts @@ -14,7 +14,7 @@ describe("@Unique()", () => { it("should set metadata", () => { expect(this.store.get(MONGOOSE_SCHEMA)).to.deep.eq({ - unique: true, + unique: true }); }); }); diff --git a/packages/mongoose/src/decorators/virtualRef.spec.ts b/packages/mongoose/src/decorators/virtualRef.spec.ts index 6b98ecd4502..34787426061 100644 --- a/packages/mongoose/src/decorators/virtualRef.spec.ts +++ b/packages/mongoose/src/decorators/virtualRef.spec.ts @@ -22,7 +22,7 @@ describe("@VirtualRef()", () => { justOne: false, foreignField: "foreign", localField: "_id", - options: undefined, + options: undefined }); }); }); @@ -43,7 +43,7 @@ describe("@VirtualRef()", () => { localField: "_id", foreignField: "foreign", justOne: false, - options: undefined, + options: undefined }); }); }); @@ -57,7 +57,7 @@ describe("@VirtualRef()", () => { foreignField: "foreign", localField: "test_2", justOne: true, - options: {}, + options: {} }) test: any; } @@ -70,7 +70,7 @@ describe("@VirtualRef()", () => { localField: "test_2", foreignField: "foreign", justOne: true, - options: {}, + options: {} }); }); }); @@ -94,7 +94,7 @@ describe("@VirtualRef()", () => { foreignField: "foreign", localField: "test_2", justOne: true, - options: {}, + options: {} }) members: VirtualRef; } @@ -107,17 +107,17 @@ describe("@VirtualRef()", () => { localField: "test_2", foreignField: "foreign", justOne: true, - options: {}, + options: {} }); expect(getJsonSchema(TestBand)).to.deep.equal({ definitions: {}, properties: { members: { - type: "object", - }, + type: "object" + } }, - type: "object", + type: "object" }); }); }); diff --git a/packages/mongoose/src/decorators/virtualRef.ts b/packages/mongoose/src/decorators/virtualRef.ts index 011eb0aae3f..2acce3245fe 100644 --- a/packages/mongoose/src/decorators/virtualRef.ts +++ b/packages/mongoose/src/decorators/virtualRef.ts @@ -38,7 +38,7 @@ function mapToSchema(opts: any) { localField: opts.localField || "_id", foreignField: opts.foreignField, justOne: opts.justOne || false, - options: opts.options, + options: opts.options }; return schema; diff --git a/packages/mongoose/src/interfaces/MongooseSchemaTypes.ts b/packages/mongoose/src/interfaces/MongooseSchemaTypes.ts index b9d85bfb1a9..1dab909cf8f 100644 --- a/packages/mongoose/src/interfaces/MongooseSchemaTypes.ts +++ b/packages/mongoose/src/interfaces/MongooseSchemaTypes.ts @@ -1,5 +1,5 @@ export enum MongooseSchemaTypes { OBJECT_ID = "ObjectId", STRING = "String", - NUMBER = "Number", + NUMBER = "Number" } diff --git a/packages/mongoose/src/registries/MongooseModelRegistry.ts b/packages/mongoose/src/registries/MongooseModelRegistry.ts index 9d70ea99aa7..582a610ad37 100644 --- a/packages/mongoose/src/registries/MongooseModelRegistry.ts +++ b/packages/mongoose/src/registries/MongooseModelRegistry.ts @@ -7,7 +7,7 @@ import {GlobalProviders, Provider, TypedProvidersRegistry} from "@tsed/common"; export const PROVIDER_TYPE_MONGOOSE_MODEL = "mongooseModel"; // tslint:disable-next-line: variable-name export const MongooseModelRegistry: TypedProvidersRegistry = GlobalProviders.createRegistry(PROVIDER_TYPE_MONGOOSE_MODEL, Provider, { - injectable: true, + injectable: true }); /** diff --git a/packages/mongoose/src/services/MongooseConnection.spec.ts b/packages/mongoose/src/services/MongooseConnection.spec.ts index 62911a3837a..9a7aa2f1787 100644 --- a/packages/mongoose/src/services/MongooseConnection.spec.ts +++ b/packages/mongoose/src/services/MongooseConnection.spec.ts @@ -23,17 +23,17 @@ describe("MongooseConnections", () => { get() { return { url: "mongodb://test", - connectionOptions: {options: "options"}, + connectionOptions: {options: "options"} }; - }, - }, + } + } }, { token: MongooseService, use: { - connect: connectStub, - }, - }, + connect: connectStub + } + } ]); // THEN @@ -53,18 +53,18 @@ describe("MongooseConnections", () => { { id: "id", url: "mongodb://test", - connectionOptions: {options: "options"}, - }, + connectionOptions: {options: "options"} + } ]; - }, - }, + } + } }, { token: MongooseService, use: { - connect: connectStub, - }, - }, + connect: connectStub + } + } ]); // THEN @@ -84,19 +84,19 @@ describe("MongooseConnections", () => { urls: { db1: { url: "mongodb://test", - connectionOptions: {options: "options"}, - }, - }, + connectionOptions: {options: "options"} + } + } }; - }, - }, + } + } }, { token: MongooseService, use: { - connect: connectStub, - }, - }, + connect: connectStub + } + } ]); // THEN diff --git a/packages/mongoose/src/services/MongooseConnections.ts b/packages/mongoose/src/services/MongooseConnections.ts index 9c62bc49604..444da30ddd3 100644 --- a/packages/mongoose/src/services/MongooseConnections.ts +++ b/packages/mongoose/src/services/MongooseConnections.ts @@ -20,8 +20,8 @@ function mapOptions(options: IMDBOptions | MDBConnection[]): MDBConnection[] { { id: "default", url, - connectionOptions, - }, + connectionOptions + } ]; } @@ -31,7 +31,7 @@ function mapOptions(options: IMDBOptions | MDBConnection[]): MDBConnection[] { return { ...options, - connectionOptions: options.connectionOptions, + connectionOptions: options.connectionOptions }; }); } @@ -40,7 +40,7 @@ function mapOptions(options: IMDBOptions | MDBConnection[]): MDBConnection[] { return (options as MDBConnection[]).map((settings) => { return { ...settings, - connectionOptions: settings.connectionOptions, + connectionOptions: settings.connectionOptions }; }); } @@ -59,7 +59,7 @@ registerProvider({ current.url, current.connectionOptions || { useNewUrlParser: true, - useUnifiedTopology: true, + useUnifiedTopology: true }, isDefault ); @@ -68,5 +68,5 @@ registerProvider({ } return mongooseService; - }, + } }); diff --git a/packages/mongoose/src/services/MongooseService.spec.ts b/packages/mongoose/src/services/MongooseService.spec.ts index fd1618aec85..5543a2fe4d0 100644 --- a/packages/mongoose/src/services/MongooseService.spec.ts +++ b/packages/mongoose/src/services/MongooseService.spec.ts @@ -10,8 +10,8 @@ describe("Mongoose", () => { beforeEach(async () => { await PlatformTest.create({ logger: { - level: "off", - }, + level: "off" + } }); sandbox.stub(Mongoose, "createConnection"); }); @@ -26,7 +26,7 @@ describe("Mongoose", () => { // GIVEN const instance = { readyState: 1, - close: Sinon.stub(), + close: Sinon.stub() }; (Mongoose.createConnection as any).resolves(instance); @@ -47,7 +47,7 @@ describe("Mongoose", () => { const mongooseService = PlatformTest.get(MongooseService); // GIVEN const instance = { - close: Sinon.stub(), + close: Sinon.stub() }; (Mongoose.createConnection as any).resolves(instance); @@ -63,7 +63,7 @@ describe("Mongoose", () => { const mongooseService = PlatformTest.get(MongooseService); // GIVEN const instance = { - close: Sinon.stub(), + close: Sinon.stub() }; (Mongoose.createConnection as any).resolves(instance); diff --git a/packages/mongoose/src/utils/buildMongooseSchema.spec.ts b/packages/mongoose/src/utils/buildMongooseSchema.spec.ts index 9d14480b36d..d8a2919cda8 100644 --- a/packages/mongoose/src/utils/buildMongooseSchema.spec.ts +++ b/packages/mongoose/src/utils/buildMongooseSchema.spec.ts @@ -22,8 +22,8 @@ describe("buildMongooseSchema", () => { expect(result.schema).to.deep.eq({ test: { required: false, - type: String, - }, + type: String + } }); expect(result.virtuals.size).to.eq(0); @@ -41,7 +41,7 @@ describe("buildMongooseSchema", () => { propertyMetadata.store.set(MONGOOSE_SCHEMA, { ref: "ref", localField: "localField", - foreignField: "foreignField", + foreignField: "foreignField" }); PropertyMetadata.get(Test, "_id"); @@ -56,7 +56,7 @@ describe("buildMongooseSchema", () => { foreignField: "foreignField", justOne: true, localField: "localField", - ref: "ref", + ref: "ref" }); }); }); diff --git a/packages/mongoose/src/utils/createSchema.spec.ts b/packages/mongoose/src/utils/createSchema.spec.ts index 0a390488781..28b1d2e682e 100644 --- a/packages/mongoose/src/utils/createSchema.spec.ts +++ b/packages/mongoose/src/utils/createSchema.spec.ts @@ -10,7 +10,7 @@ describe("createSchema", () => { it("should create schema", () => { enum MyEnum { V1 = "v1", - V2 = "v2", + V2 = "v2" } // GIVEN @@ -41,7 +41,7 @@ describe("createSchema", () => { enum: { enum: ["v1", "v2"], required: false, - type: String, + type: String }, name: { default: "defaultValue", @@ -49,14 +49,14 @@ describe("createSchema", () => { maxlength: 100, minlength: 0, required: false, - type: String, + type: String }, test: { max: 10, min: 0, required: false, - type: Number, - }, + type: Number + } }); }); it("should create schema with required property", () => { @@ -77,7 +77,7 @@ describe("createSchema", () => { // GIVEN enum MyEnum { V1 = "v1", - V2 = "v2", + V2 = "v2" } @Schema() @@ -113,15 +113,15 @@ describe("createSchema", () => { expect(testSchema.obj).to.deep.eq({ test: { type: childrenSchema, - required: false, - }, + required: false + } }); expect(childrenSchema.obj).to.deep.eq({ enum: { enum: ["v1", "v2"], required: false, - type: String, + type: String }, name: { default: "defaultValue", @@ -129,21 +129,21 @@ describe("createSchema", () => { maxlength: 100, minlength: 0, required: false, - type: String, + type: String }, test: { max: 10, min: 0, required: false, - type: Number, - }, + type: Number + } }); }); it("should create schema with ref", () => { // GIVEN enum MyEnum { V1 = "v1", - V2 = "v2", + V2 = "v2" } @Model() @@ -180,15 +180,15 @@ describe("createSchema", () => { test: { type: SchemaMongoose.Types.ObjectId, ref: "Children", - required: false, - }, + required: false + } }); expect(childrenSchema.obj).to.deep.eq({ enum: { enum: ["v1", "v2"], required: false, - type: String, + type: String }, name: { default: "defaultValue", @@ -196,14 +196,14 @@ describe("createSchema", () => { maxlength: 100, minlength: 0, required: false, - type: String, + type: String }, test: { max: 10, min: 0, required: false, - type: Number, - }, + type: Number + } }); const result = new OpenApiModelSchemaBuilder(Test4).build(); @@ -215,11 +215,11 @@ describe("createSchema", () => { test: { description: "Mongoose Ref ObjectId", example: "5ce7ad3028890bd71749d477", - type: "string", - }, + type: "string" + } }, - type: "object", - }, + type: "object" + } }, _responses: {}, _schema: { @@ -227,19 +227,19 @@ describe("createSchema", () => { test: { description: "Mongoose Ref ObjectId", example: "5ce7ad3028890bd71749d477", - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }, - target: Test4, + target: Test4 }); }); it("should create schema with virtual ref", () => { // GIVEN enum MyEnum { V1 = "v1", - V2 = "v2", + V2 = "v2" } @Model() @@ -277,14 +277,14 @@ describe("createSchema", () => { justOne: true, localField: "_id", options: undefined, - ref: "Children2", + ref: "Children2" }); }); it("should create schema with collection (Array of subdocument)", () => { // GIVEN enum MyEnum { V1 = "v1", - V2 = "v2", + V2 = "v2" } @Schema() @@ -321,16 +321,16 @@ describe("createSchema", () => { tests: [ { type: childrenSchema, - required: false, - }, - ], + required: false + } + ] }); expect(childrenSchema.obj).to.deep.eq({ enum: { enum: ["v1", "v2"], required: false, - type: String, + type: String }, name: { default: "defaultValue", @@ -338,21 +338,21 @@ describe("createSchema", () => { maxlength: 100, minlength: 0, required: false, - type: String, + type: String }, test: { max: 10, min: 0, required: false, - type: Number, - }, + type: Number + } }); }); it("should create schema with collection (Array of ref)", () => { // GIVEN enum MyEnum { V1 = "v1", - V2 = "v2", + V2 = "v2" } @Model() @@ -389,16 +389,16 @@ describe("createSchema", () => { { type: SchemaMongoose.Types.ObjectId, ref: "Children3", - required: false, - }, - ], + required: false + } + ] }); }); it("should create schema with collection (Array of virtual ref", () => { // GIVEN enum MyEnum { V1 = "v1", - V2 = "v2", + V2 = "v2" } @Model() @@ -437,14 +437,14 @@ describe("createSchema", () => { justOne: false, localField: "_id", options: undefined, - ref: "Children4", + ref: "Children4" }); }); it("should create schema with collection (Map of subdocument)", () => { // GIVEN enum MyEnum { V1 = "v1", - V2 = "v2", + V2 = "v2" } @Schema() @@ -482,16 +482,16 @@ describe("createSchema", () => { type: Map, of: { type: childrenSchema, - required: false, - }, - }, + required: false + } + } }); expect(childrenSchema.obj).to.deep.eq({ enum: { enum: ["v1", "v2"], required: false, - type: String, + type: String }, name: { default: "defaultValue", @@ -499,21 +499,21 @@ describe("createSchema", () => { maxlength: 100, minlength: 0, required: false, - type: String, + type: String }, test: { max: 10, min: 0, required: false, - type: Number, - }, + type: Number + } }); }); it("should throw error with collection (Set of subdocument)", () => { // GIVEN enum MyEnum { V1 = "v1", - V2 = "v2", + V2 = "v2" } let actualError: any; @@ -563,8 +563,8 @@ describe("createSchema", () => { expect(testSchema.obj).to.deep.eq({ field: { required: false, - type: String, - }, + type: String + } }); }); }); diff --git a/packages/mongoose/src/utils/createSchema.ts b/packages/mongoose/src/utils/createSchema.ts index f453cee7e81..5aaf6990522 100644 --- a/packages/mongoose/src/utils/createSchema.ts +++ b/packages/mongoose/src/utils/createSchema.ts @@ -22,7 +22,7 @@ function setUpTarget(target: Type) { type: getClass(target), checkRequiredValue, ignoreCallback, - withIgnoredProps, + withIgnoredProps }); }; } @@ -104,7 +104,7 @@ export function createSchemaTypeOptions(propertyMetadata: PropertyMetadata): Sch ? function () { return propertyMetadata.isRequired(this[key]); } - : false, + : false }; if (!propertyMetadata.isClass) { @@ -125,7 +125,7 @@ export function createSchemaTypeOptions(propertyMetadata: PropertyMetadata): Sch minlength, maxlength, enum: jsonSchema["enum"], - default: jsonSchema["default"], + default: jsonSchema["default"] }; } else if (!rawMongooseSchema.ref) { // References are handled by the final merge diff --git a/packages/mongoose/src/utils/registerModel.spec.ts b/packages/mongoose/src/utils/registerModel.spec.ts index a4f253afbb5..0b8f8983da5 100644 --- a/packages/mongoose/src/utils/registerModel.spec.ts +++ b/packages/mongoose/src/utils/registerModel.spec.ts @@ -20,7 +20,7 @@ describe("registerModel()", () => { expect(mergeStub).to.have.been.calledWithExactly(Test, { instance: {model: "model"}, provide: Test, - type: "mongooseModel", + type: "mongooseModel" }); }); }); @@ -42,7 +42,7 @@ describe("registerModel()", () => { expect(mergeStub).to.have.been.calledWithExactly(Test, { instance: {model: "model"}, provide: Test, - type: "mongooseModel", + type: "mongooseModel" }); }); }); diff --git a/packages/mongoose/src/utils/schemaOptions.spec.ts b/packages/mongoose/src/utils/schemaOptions.spec.ts index 21b8ca3b341..7b73521d61c 100644 --- a/packages/mongoose/src/utils/schemaOptions.spec.ts +++ b/packages/mongoose/src/utils/schemaOptions.spec.ts @@ -19,7 +19,7 @@ describe("schemaOptions", () => { it("should return schema options (3)", () => { expect(schemaOptions(Test, {options2: "options2"} as any)).to.deep.eq({ options: "options", - options2: "options2", + options2: "options2" }); }); }); @@ -58,7 +58,7 @@ describe("schemaOptions", () => { pre: Sinon.stub(), post: Sinon.stub(), plugin: Sinon.stub(), - index: Sinon.stub(), + index: Sinon.stub() }; before(() => { @@ -68,17 +68,17 @@ describe("schemaOptions", () => { method: "method", parallel: true, fn: (doc: any, pre: any) => {}, - errorCb: "errorCb", - }, + errorCb: "errorCb" + } ], post: [ { method: "method", - fn: "fn", - }, + fn: "fn" + } ], plugins: [{plugin: "plugin", options: "options"}], - indexes: [{fields: "fields", options: "options"}], + indexes: [{fields: "fields", options: "options"}] } as any); }); diff --git a/packages/mongoose/test/helpers/Server.ts b/packages/mongoose/test/helpers/Server.ts index 68a2c79a518..e2157bfd6e3 100644 --- a/packages/mongoose/test/helpers/Server.ts +++ b/packages/mongoose/test/helpers/Server.ts @@ -16,8 +16,8 @@ const rootDir = Path.resolve(__dirname); httpsPort: false, logger: { level: "info", - logRequest: true, - }, + logRequest: true + } }) export class Server { @Inject() @@ -28,7 +28,7 @@ export class Server { .use(bodyParser.json()) .use( bodyParser.urlencoded({ - extended: true, + extended: true }) ) .use(cookieParser()) diff --git a/packages/mongoose/test/multiple-connection.integration.spec.ts b/packages/mongoose/test/multiple-connection.integration.spec.ts index 88d78b94687..11ddd6dcd0d 100644 --- a/packages/mongoose/test/multiple-connection.integration.spec.ts +++ b/packages/mongoose/test/multiple-connection.integration.spec.ts @@ -8,7 +8,7 @@ import {Server} from "./helpers/Server"; @Model({ connection: "customer", - collection: "accounts", + collection: "accounts" }) class CustomerAccount { @ObjectID() @@ -21,7 +21,7 @@ class CustomerAccount { // models/ProductData.ts @Model({ connection: "product", - collection: "data", + collection: "data" }) class ProductData { @ObjectID() @@ -43,18 +43,18 @@ describe("Mongoose", () => { url: config.url, connectionOptions: { ...config.connectionOptions, - dbName: "customerDB", - }, + dbName: "customerDB" + } }, { id: "product", url: config.url, connectionOptions: { ...config.connectionOptions, - dbName: "productDB", - }, - }, - ], + dbName: "productDB" + } + } + ] })(); }); afterEach(TestMongooseContext.clearDatabase); diff --git a/packages/mongoose/test/user.integration.spec.ts b/packages/mongoose/test/user.integration.spec.ts index 59463fbefc0..e5a2342852b 100644 --- a/packages/mongoose/test/user.integration.spec.ts +++ b/packages/mongoose/test/user.integration.spec.ts @@ -15,7 +15,7 @@ describe("Mongoose", () => { // GIVEN const user = new userModel({ email: "test@test.fr", - password: "test", + password: "test" }); // WHEN @@ -41,7 +41,7 @@ describe("Mongoose", () => { TestMongooseContext.inject([TestUser], async (userModel: MongooseModel) => { // GIVEN const user = new userModel({ - email: "test@test.fr", + email: "test@test.fr" }); // WHEN diff --git a/packages/multipartfiles/src/decorators/multerFileSize.spec.ts b/packages/multipartfiles/src/decorators/multerFileSize.spec.ts index 87c03cd4099..47a80248380 100644 --- a/packages/multipartfiles/src/decorators/multerFileSize.spec.ts +++ b/packages/multipartfiles/src/decorators/multerFileSize.spec.ts @@ -13,9 +13,9 @@ describe("MulterFileSize", () => { expect(store.get(MultipartFileMiddleware)).to.deep.eq({ options: { limits: { - fileSize: 100, - }, - }, + fileSize: 100 + } + } }); }); }); diff --git a/packages/multipartfiles/src/decorators/multerOptions.spec.ts b/packages/multipartfiles/src/decorators/multerOptions.spec.ts index 73f5e3d9554..d6a64e8ec7d 100644 --- a/packages/multipartfiles/src/decorators/multerOptions.spec.ts +++ b/packages/multipartfiles/src/decorators/multerOptions.spec.ts @@ -14,8 +14,8 @@ describe("@MulterOptions()", () => { expect(store.get(MultipartFileMiddleware)).to.deep.equal({ options: { - dest: "/", - }, + dest: "/" + } }); }); }); diff --git a/packages/multipartfiles/src/decorators/multerOptions.ts b/packages/multipartfiles/src/decorators/multerOptions.ts index b314265a922..a0bc5fd552d 100644 --- a/packages/multipartfiles/src/decorators/multerOptions.ts +++ b/packages/multipartfiles/src/decorators/multerOptions.ts @@ -53,7 +53,7 @@ export function MulterOptions(options: Multer.Options): MethodDecorator { throw new Error("MulterOptions is only supported on method"); case DecoratorTypes.METHOD: Store.fromMethod(target, propertyKey).merge(MultipartFileMiddleware, { - options, + options }); return descriptor; diff --git a/packages/multipartfiles/src/decorators/multipartFile.spec.ts b/packages/multipartfiles/src/decorators/multipartFile.spec.ts index a9897123bb9..5225bfae218 100644 --- a/packages/multipartfiles/src/decorators/multipartFile.spec.ts +++ b/packages/multipartfiles/src/decorators/multipartFile.spec.ts @@ -46,10 +46,10 @@ describe("@MultipartFile()", () => { fields: [ { maxCount: 1, - name: "file1", - }, + name: "file1" + } ], - options: undefined, + options: undefined }); }); @@ -84,10 +84,10 @@ describe("@MultipartFile()", () => { fields: [ { maxCount: 8, - name: "file1", - }, + name: "file1" + } ], - options: undefined, + options: undefined }); }); @@ -127,8 +127,8 @@ describe("@MultipartFile()", () => { expect(store.get(MultipartFileMiddleware)).to.deep.eq({ any: true, options: { - options: "options", - }, + options: "options" + } }); }); @@ -163,8 +163,8 @@ describe("@MultipartFile()", () => { expect(store.get(MultipartFileMiddleware)).to.deep.eq({ any: true, options: { - options: "options", - }, + options: "options" + } }); }); diff --git a/packages/multipartfiles/src/decorators/multipartFile.ts b/packages/multipartfiles/src/decorators/multipartFile.ts index 2de1d63a28e..ea477ca32de 100644 --- a/packages/multipartfiles/src/decorators/multipartFile.ts +++ b/packages/multipartfiles/src/decorators/multipartFile.ts @@ -69,8 +69,8 @@ export function MultipartFile(name?: string | multer.Options, maxCount?: number) .merge("responses", { "400": { description: ` [fieldName] - Example: File too long file1`, - }, + Example: File too long file1` + } }) .set("multipartAdded", true); @@ -82,17 +82,17 @@ export function MultipartFile(name?: string | multer.Options, maxCount?: number) if (name === undefined) { store.merge(MultipartFileMiddleware, { options, - any: true, + any: true }); } else { store.merge(MultipartFileMiddleware, { fields: [ { name, - maxCount, - }, + maxCount + } ], - options, + options }); } diff --git a/packages/multipartfiles/src/middlewares/MultiparFileMiddleware.spec.ts b/packages/multipartfiles/src/middlewares/MultiparFileMiddleware.spec.ts index 20b97233937..6e1ee3bd7ba 100644 --- a/packages/multipartfiles/src/middlewares/MultiparFileMiddleware.spec.ts +++ b/packages/multipartfiles/src/middlewares/MultiparFileMiddleware.spec.ts @@ -7,12 +7,12 @@ describe("MultipartFileMiddleware", () => { before(() => { this.settings = { uploadDir: "/", - get: Sinon.stub().withArgs("multer").returns({options: "options"}), + get: Sinon.stub().withArgs("multer").returns({options: "options"}) }; this.middleware = new MultipartFileMiddleware(this.settings); this.expressMiddleware = Sinon.stub(); this.middleware.multer = Sinon.stub().returns({ - any: Sinon.stub().returns(this.expressMiddleware), + any: Sinon.stub().returns(this.expressMiddleware) }); this.result = this.middleware.use( @@ -20,9 +20,9 @@ describe("MultipartFileMiddleware", () => { get() { return { options: {options: "options"}, - any: true, + any: true }; - }, + } }, {request: "request"}, {response: "response"} @@ -46,12 +46,12 @@ describe("MultipartFileMiddleware", () => { before(() => { this.settings = { uploadDir: "/", - get: Sinon.stub().withArgs("multer").returns({options: "options"}), + get: Sinon.stub().withArgs("multer").returns({options: "options"}) }; this.middleware = new MultipartFileMiddleware(this.settings); this.expressMiddleware = Sinon.stub(); this.multerApiStub = { - fields: Sinon.stub().returns(this.expressMiddleware), + fields: Sinon.stub().returns(this.expressMiddleware) }; this.middleware.multer = Sinon.stub().returns(this.multerApiStub); @@ -61,9 +61,9 @@ describe("MultipartFileMiddleware", () => { get() { return { options: {options: "options"}, - fields: [{name: "test"}, {name: "test1", maxCount: 4}], + fields: [{name: "test"}, {name: "test1", maxCount: 4}] }; - }, + } }, {request: "request"}, {response: "response"} @@ -82,12 +82,12 @@ describe("MultipartFileMiddleware", () => { expect(this.multerApiStub.fields).to.have.been.calledWithExactly([ { maxCount: undefined, - name: "test", + name: "test" }, { maxCount: 4, - name: "test1", - }, + name: "test1" + } ]); }); it("should create middleware and call it", () => { @@ -99,12 +99,12 @@ describe("MultipartFileMiddleware", () => { before(() => { this.settings = { uploadDir: "/", - get: Sinon.stub().withArgs("multer").returns({options: "options"}), + get: Sinon.stub().withArgs("multer").returns({options: "options"}) }; this.middleware = new MultipartFileMiddleware(this.settings); this.expressMiddleware = Sinon.stub(); this.multerApiStub = { - fields: Sinon.stub().returns(this.expressMiddleware), + fields: Sinon.stub().returns(this.expressMiddleware) }; this.middleware.multer = Sinon.stub().returns(this.multerApiStub); @@ -114,9 +114,9 @@ describe("MultipartFileMiddleware", () => { get() { return { options: {options: "options"}, - fields: [{name: "test"}, {name: "test1", maxCount: 4}], + fields: [{name: "test"}, {name: "test1", maxCount: 4}] }; - }, + } }, {request: "request"}, {response: "response"} @@ -140,12 +140,12 @@ describe("MultipartFileMiddleware", () => { expect(this.multerApiStub.fields).to.have.been.calledWithExactly([ { maxCount: undefined, - name: "test", + name: "test" }, { maxCount: 4, - name: "test1", - }, + name: "test1" + } ]); }); diff --git a/packages/multipartfiles/src/middlewares/MultipartFileMiddleware.ts b/packages/multipartfiles/src/middlewares/MultipartFileMiddleware.ts index 35319814961..8e1db812c1a 100644 --- a/packages/multipartfiles/src/middlewares/MultipartFileMiddleware.ts +++ b/packages/multipartfiles/src/middlewares/MultipartFileMiddleware.ts @@ -27,7 +27,7 @@ export class MultipartFileMiddleware implements IMiddleware { const options = { dest, ...(this.configuration.get("multer") || {}), - ...(conf.options || {}), + ...(conf.options || {}) }; /* istanbul ignore next */ diff --git a/packages/multipartfiles/test/helpers/Server.ts b/packages/multipartfiles/test/helpers/Server.ts index 47883be6d36..7e8cedb916d 100644 --- a/packages/multipartfiles/test/helpers/Server.ts +++ b/packages/multipartfiles/test/helpers/Server.ts @@ -18,23 +18,23 @@ const rootDir = Path.resolve(__dirname); multer: {}, logger: { level: "info", - logRequest: true, + logRequest: true }, mount: { - "/rest": [ArchiveController], + "/rest": [ArchiveController] }, swagger: [ { - path: "/api-doc", - }, - ], + path: "/api-doc" + } + ] }) export class Server extends ServerLoader { public $beforeRoutesInit(): void { this.use(bodyParser.json()) .use( bodyParser.urlencoded({ - extended: true, + extended: true }) ) .use(cookieParser()) diff --git a/packages/multipartfiles/test/helpers/controllers/ArchiveController.ts b/packages/multipartfiles/test/helpers/controllers/ArchiveController.ts index edf428911ba..0d653c93562 100644 --- a/packages/multipartfiles/test/helpers/controllers/ArchiveController.ts +++ b/packages/multipartfiles/test/helpers/controllers/ArchiveController.ts @@ -29,7 +29,7 @@ export class ArchiveController { return { file: media.originalname, formId, - event, + event }; } } diff --git a/packages/passport/src/PassportModule.ts b/packages/passport/src/PassportModule.ts index bb78b8f163a..2d372a74c46 100644 --- a/packages/passport/src/PassportModule.ts +++ b/packages/passport/src/PassportModule.ts @@ -4,7 +4,7 @@ import {PassportSerializerService} from "./services/PassportSerializerService"; import {ProtocolsService} from "./services/ProtocolsService"; @Module({ - scope: ProviderScope.SINGLETON, + scope: ProviderScope.SINGLETON }) export class PassportModule implements OnInit, BeforeRoutesInit { @Constant("passport.userProperty") diff --git a/packages/passport/src/decorators/authenticate.spec.ts b/packages/passport/src/decorators/authenticate.spec.ts index 979526bcc55..519317d41d8 100644 --- a/packages/passport/src/decorators/authenticate.spec.ts +++ b/packages/passport/src/decorators/authenticate.spec.ts @@ -14,10 +14,10 @@ describe("@Authenticate", () => { expect(store.get(PassportMiddleware)).to.deep.equal({ method: "authenticate", options: { - security: "security", + security: "security" }, protocol: "local", - originalUrl: true, + originalUrl: true }); }); it("should store data (without originalUrl)", () => { @@ -32,10 +32,10 @@ describe("@Authenticate", () => { method: "authenticate", options: { security: "security", - originalUrl: false, + originalUrl: false }, protocol: "local", - originalUrl: false, + originalUrl: false }); }); }); diff --git a/packages/passport/src/decorators/authenticate.ts b/packages/passport/src/decorators/authenticate.ts index c38dbbc6ffd..7cef0e1c0be 100644 --- a/packages/passport/src/decorators/authenticate.ts +++ b/packages/passport/src/decorators/authenticate.ts @@ -13,6 +13,6 @@ export function Authenticate(protocol: string | string[] = "*", options: Authent method: "authenticate", security: options.security, originalUrl: options.originalUrl === undefined ? true : options.originalUrl, - options, + options }); } diff --git a/packages/passport/src/decorators/authorize.spec.ts b/packages/passport/src/decorators/authorize.spec.ts index 3d31398f60f..6e31d57449f 100644 --- a/packages/passport/src/decorators/authorize.spec.ts +++ b/packages/passport/src/decorators/authorize.spec.ts @@ -14,10 +14,10 @@ describe("@Authorize", () => { expect(store.get(PassportMiddleware)).to.deep.equal({ method: "authorize", options: { - security: "security", + security: "security" }, originalUrl: true, - protocol: "local", + protocol: "local" }); }); it("should store data (without originalUrl)", () => { @@ -32,10 +32,10 @@ describe("@Authorize", () => { method: "authorize", options: { security: "security", - originalUrl: false, + originalUrl: false }, originalUrl: false, - protocol: "local", + protocol: "local" }); }); }); diff --git a/packages/passport/src/decorators/authorize.ts b/packages/passport/src/decorators/authorize.ts index 34f97f65b8f..504072f6b96 100644 --- a/packages/passport/src/decorators/authorize.ts +++ b/packages/passport/src/decorators/authorize.ts @@ -13,6 +13,6 @@ export function Authorize(protocol: string | string[] = "*", options: AuthorizeO method: "authorize", security: options.security, originalUrl: options.originalUrl === undefined ? true : options.originalUrl, - options, + options }); } diff --git a/packages/passport/src/decorators/protocol.ts b/packages/passport/src/decorators/protocol.ts index f05ead7ceeb..2ed13127e86 100644 --- a/packages/passport/src/decorators/protocol.ts +++ b/packages/passport/src/decorators/protocol.ts @@ -16,9 +16,9 @@ export function Protocol(options: ProtocolOptionsDecorator) { Configuration({ passport: { protocols: { - [options.name]: options, - }, - }, + [options.name]: options + } + } }) ); } diff --git a/packages/passport/src/middlewares/PassportMiddleware.spec.ts b/packages/passport/src/middlewares/PassportMiddleware.spec.ts index e8d18256d76..3c33309ed22 100644 --- a/packages/passport/src/middlewares/PassportMiddleware.spec.ts +++ b/packages/passport/src/middlewares/PassportMiddleware.spec.ts @@ -17,7 +17,7 @@ describe("PassportMiddleware", () => { // GIVEN const middleware = new PassportMiddleware(); middleware.protocolsService = { - getProtocolsNames: sandbox.stub().returns(["local"]), + getProtocolsNames: sandbox.stub().returns(["local"]) } as any; const request: any = {}; @@ -26,9 +26,9 @@ describe("PassportMiddleware", () => { get: sandbox.stub().returns({ options: {}, protocol: "local", - method: "authenticate", - }), - }, + method: "authenticate" + }) + } }; // WHEN @@ -41,23 +41,23 @@ describe("PassportMiddleware", () => { // GIVEN const middleware = new PassportMiddleware(); middleware.protocolsService = { - getProtocolsNames: sandbox.stub().returns(["local"]), + getProtocolsNames: sandbox.stub().returns(["local"]) } as any; const request: any = { user: {}, isAuthenticated() { return true; - }, + } }; const endpoint: any = { store: { get: sandbox.stub().returns({ options: {}, protocol: "local", - method: "authenticate", - }), - }, + method: "authenticate" + }) + } }; // WHEN @@ -71,7 +71,7 @@ describe("PassportMiddleware", () => { // GIVEN const middleware = new PassportMiddleware(); middleware.protocolsService = { - getProtocolsNames: sandbox.stub().returns(["local", "basic"]), + getProtocolsNames: sandbox.stub().returns(["local", "basic"]) } as any; const request: any = {}; @@ -80,9 +80,9 @@ describe("PassportMiddleware", () => { get: sandbox.stub().returns({ options: {}, protocol: "*", - method: "authenticate", - }), - }, + method: "authenticate" + }) + } }; // WHEN @@ -95,24 +95,24 @@ describe("PassportMiddleware", () => { // GIVEN const middleware = new PassportMiddleware(); middleware.protocolsService = { - getProtocolsNames: sandbox.stub().returns(["local", "basic"]), + getProtocolsNames: sandbox.stub().returns(["local", "basic"]) } as any; const request: any = { url: "/", originalUrl: "/rest", query: { - protocol: "basic", - }, + protocol: "basic" + } }; const endpoint: any = { store: { get: sandbox.stub().returns({ options: {}, protocol: ":protocol", - method: "authenticate", - }), - }, + method: "authenticate" + }) + } }; // WHEN @@ -126,7 +126,7 @@ describe("PassportMiddleware", () => { // GIVEN const middleware = new PassportMiddleware(); middleware.protocolsService = { - getProtocolsNames: sandbox.stub().returns(["local", "basic"]), + getProtocolsNames: sandbox.stub().returns(["local", "basic"]) } as any; const request: any = {}; @@ -135,9 +135,9 @@ describe("PassportMiddleware", () => { get: sandbox.stub().returns({ options: {}, protocol: ":protocol", - method: "authenticate", - }), - }, + method: "authenticate" + }) + } }; // WHEN diff --git a/packages/passport/src/registries/ProtocolRegistries.ts b/packages/passport/src/registries/ProtocolRegistries.ts index db33fc9a886..5ed102967f3 100644 --- a/packages/passport/src/registries/ProtocolRegistries.ts +++ b/packages/passport/src/registries/ProtocolRegistries.ts @@ -11,7 +11,7 @@ export const PROVIDER_TYPE_PROTOCOL = "protocol"; */ // tslint:disable-next-line: variable-name export const ProtocolRegistry: TypedProvidersRegistry = GlobalProviders.createRegistry(PROVIDER_TYPE_PROTOCOL, Provider, { - injectable: true, + injectable: true }); /** * Add a new service in the `ProviderRegistry`. This service will be built when `InjectorService` will be loaded. diff --git a/packages/passport/src/services/PassportSerializerService.spec.ts b/packages/passport/src/services/PassportSerializerService.spec.ts index ba7c9ad19b2..0db02939f34 100644 --- a/packages/passport/src/services/PassportSerializerService.spec.ts +++ b/packages/passport/src/services/PassportSerializerService.spec.ts @@ -55,8 +55,8 @@ describe("PassportSerializerService", () => { null, { email: "email@email.fr", - id: "id", - }, + id: "id" + } ]); }) ); diff --git a/packages/passport/src/services/ProtocolsService.spec.ts b/packages/passport/src/services/ProtocolsService.spec.ts index f2ca4371f0c..9fc82f73cd1 100644 --- a/packages/passport/src/services/ProtocolsService.spec.ts +++ b/packages/passport/src/services/ProtocolsService.spec.ts @@ -16,8 +16,8 @@ describe("ProtocolsService", () => { useStrategy: Strategy as any, settings: { prop1: "prop1", - prop2: "prop2", - }, + prop2: "prop2" + } }) class LocalProtocol { $onInstall() {} @@ -34,11 +34,11 @@ describe("ProtocolsService", () => { local: { settings: { prop2: "prop2-server", - prop3: "prop3", - }, - }, - }, - }, + prop3: "prop3" + } + } + } + } }) ); afterEach(PlatformTest.reset); @@ -72,7 +72,7 @@ describe("ProtocolsService", () => { passReqToCallback: true, prop1: "prop1", prop2: "prop2-server", - prop3: "prop3", + prop3: "prop3" }, Sinon.match.func ); @@ -88,7 +88,7 @@ describe("ProtocolsService", () => { const provider = injector.getProvider(LocalProtocol)!; const req = { res: {}, - ctx: new RequestContext({id: "1", logger: {}, url: "/"}), + ctx: new RequestContext({id: "1", logger: {}, url: "/"}) }; // WHEN const result = protocolService.invoke(provider); @@ -112,7 +112,7 @@ describe("ProtocolsService", () => { const provider = injector.getProvider(LocalProtocol)!; const req = { res: {}, - ctx: new RequestContext({id: "1", logger: {}, url: "/"}), + ctx: new RequestContext({id: "1", logger: {}, url: "/"}) }; // WHEN const result = protocolService.invoke(provider); diff --git a/packages/passport/src/services/ProtocolsService.ts b/packages/passport/src/services/ProtocolsService.ts index 2effa588334..cf560f9268d 100644 --- a/packages/passport/src/services/ProtocolsService.ts +++ b/packages/passport/src/services/ProtocolsService.ts @@ -44,8 +44,8 @@ export class ProtocolsService { useStrategy, settings: { ...settings, - passReqToCallback: true, - }, + passReqToCallback: true + } }; } @@ -54,7 +54,7 @@ export class ProtocolsService { token: provider.provide, target: provider.useClass, type: HandlerType.CONTROLLER, - propertyKey: "$onVerify", + propertyKey: "$onVerify" }); const platform = this.injector.get(Platform)!; diff --git a/packages/passport/src/utils/getProtocolsFromRequest.spec.ts b/packages/passport/src/utils/getProtocolsFromRequest.spec.ts index 9d0cb005b5b..38679e2fc8f 100644 --- a/packages/passport/src/utils/getProtocolsFromRequest.spec.ts +++ b/packages/passport/src/utils/getProtocolsFromRequest.spec.ts @@ -30,8 +30,8 @@ describe("getProtocolsFromRequest", () => { const defaultProtocols = ["default"]; const req = { params: { - protocol: "basic", - }, + protocol: "basic" + } }; const result = getProtocolsFromRequest(req, ":protocol", defaultProtocols); @@ -41,7 +41,7 @@ describe("getProtocolsFromRequest", () => { it("should not get protocol from request", () => { const defaultProtocols = ["default"]; const req = { - params: {}, + params: {} }; const result = getProtocolsFromRequest(req, ":protocol", defaultProtocols); @@ -52,8 +52,8 @@ describe("getProtocolsFromRequest", () => { const defaultProtocols = ["default"]; const req = { query: { - protocol: "basic", - }, + protocol: "basic" + } }; const result = getProtocolsFromRequest(req, ":protocol", defaultProtocols); @@ -64,8 +64,8 @@ describe("getProtocolsFromRequest", () => { const defaultProtocols = ["default"]; const req = { body: { - protocol: "basic", - }, + protocol: "basic" + } }; const result = getProtocolsFromRequest(req, ":protocol", defaultProtocols); @@ -76,8 +76,8 @@ describe("getProtocolsFromRequest", () => { const defaultProtocols = ["default"]; const req = { params: { - protocol: "basic", - }, + protocol: "basic" + } }; const result = getProtocolsFromRequest(req, "basic", defaultProtocols); @@ -88,8 +88,8 @@ describe("getProtocolsFromRequest", () => { const defaultProtocols = ["default"]; const req = { params: { - protocol: "basic", - }, + protocol: "basic" + } }; const result = getProtocolsFromRequest(req, "other", defaultProtocols); diff --git a/packages/platform-express/test/app/Server.ts b/packages/platform-express/test/app/Server.ts index e7b41331720..f2b4a4b2bb0 100644 --- a/packages/platform-express/test/app/Server.ts +++ b/packages/platform-express/test/app/Server.ts @@ -11,12 +11,12 @@ export const rootDir = __dirname; @Configuration({ logger: { - level: "off", + level: "off" }, statics: { - "/": `${rootDir}/public`, + "/": `${rootDir}/public` }, - viewsDir: `${rootDir}/views`, + viewsDir: `${rootDir}/views` }) export class Server { @Inject() @@ -36,7 +36,7 @@ export class Server { .use(bodyParser.json()) .use( bodyParser.urlencoded({ - extended: true, + extended: true }) ) .use( @@ -45,8 +45,8 @@ export class Server { resave: false, saveUninitialized: true, cookie: { - secure: false, // set true if HTTPS is enabled - }, + secure: false // set true if HTTPS is enabled + } }) ); } diff --git a/packages/platform-express/test/merge-params.spec.ts b/packages/platform-express/test/merge-params.spec.ts index 6b10a7262dd..e33b689655a 100644 --- a/packages/platform-express/test/merge-params.spec.ts +++ b/packages/platform-express/test/merge-params.spec.ts @@ -8,7 +8,7 @@ import {rootDir, Server} from "./app/Server"; const utils = PlatformTestUtils.create({ rootDir, platform: PlatformExpress, - server: Server, + server: Server }); @Controller("/merge-params/:parentId") @@ -18,7 +18,7 @@ class TestMergeParamsCtrl { get(@PathParams("parentId") parentId: string, @PathParams("id") id: string) { return { parentId, - id, + id }; } } @@ -29,8 +29,8 @@ describe("MergeParams", () => { before( utils.bootstrap({ mount: { - "/rest": [TestMergeParamsCtrl], - }, + "/rest": [TestMergeParamsCtrl] + } }) ); after(utils.reset); @@ -44,7 +44,7 @@ describe("MergeParams", () => { expect(body).to.deep.eq({ id: "ID", - parentId: "parentID", + parentId: "parentID" }); }); }); diff --git a/packages/platform-express/test/platform-express.spec.ts b/packages/platform-express/test/platform-express.spec.ts index 28cb0ab6af9..0f7b41d07a8 100644 --- a/packages/platform-express/test/platform-express.spec.ts +++ b/packages/platform-express/test/platform-express.spec.ts @@ -5,7 +5,7 @@ import {rootDir, Server} from "./app/Server"; const utils = PlatformTestUtils.create({ rootDir, platform: PlatformExpress, - server: Server, + server: Server }); describe("PlatformExpress", () => { diff --git a/packages/platform-test-utils/src/errors/CustomBadRequest.ts b/packages/platform-test-utils/src/errors/CustomBadRequest.ts index 6482e82825a..4a956c775a6 100644 --- a/packages/platform-test-utils/src/errors/CustomBadRequest.ts +++ b/packages/platform-test-utils/src/errors/CustomBadRequest.ts @@ -10,7 +10,7 @@ export class CustomBadRequest extends BadRequest implements ResponseErrorObject super(message); this.errors = ["test"]; this.headers = { - "X-HEADER-ERROR": "deny", + "X-HEADER-ERROR": "deny" }; } } diff --git a/packages/platform-test-utils/src/errors/CustomInternalError.ts b/packages/platform-test-utils/src/errors/CustomInternalError.ts index 5d51e4f0e62..77e3b6e78d1 100644 --- a/packages/platform-test-utils/src/errors/CustomInternalError.ts +++ b/packages/platform-test-utils/src/errors/CustomInternalError.ts @@ -10,7 +10,7 @@ export class CustomInternalError extends InternalServerError implements Response super(message); this.errors = ["test"]; this.headers = { - "X-HEADER-ERROR": "deny", + "X-HEADER-ERROR": "deny" }; } } diff --git a/packages/platform-test-utils/src/index.ts b/packages/platform-test-utils/src/index.ts index 9a4a6676bf8..f3710f8faae 100644 --- a/packages/platform-test-utils/src/index.ts +++ b/packages/platform-test-utils/src/index.ts @@ -12,14 +12,14 @@ export class PlatformTestUtils { test(name: string, options: any = {}) { specsContainer.get(name)!({ ...this.options, - ...options, + ...options }); } bootstrap(options: any = {}) { return PlatformTest.bootstrap(this.options.server, { ...this.options, - ...options, + ...options }); } diff --git a/packages/platform-test-utils/src/modules/feature/FeatureModule.ts b/packages/platform-test-utils/src/modules/feature/FeatureModule.ts index 9b7185c3663..4f440bdac3b 100644 --- a/packages/platform-test-utils/src/modules/feature/FeatureModule.ts +++ b/packages/platform-test-utils/src/modules/feature/FeatureModule.ts @@ -3,7 +3,7 @@ import {FeatureController} from "./controllers/FeatureController"; @Module({ mount: { - "/rest": [FeatureController], - }, + "/rest": [FeatureController] + } }) export class FeatureModule {} diff --git a/packages/platform-test-utils/src/tests/testAcceptMime.ts b/packages/platform-test-utils/src/tests/testAcceptMime.ts index d7d94310d1d..d13da56be3c 100644 --- a/packages/platform-test-utils/src/tests/testAcceptMime.ts +++ b/packages/platform-test-utils/src/tests/testAcceptMime.ts @@ -9,7 +9,7 @@ class TestAcceptMimeCtrl { @AcceptMime("application/json") scenario1(@HeaderParams("Accept") accept: string) { return { - accept, + accept }; } } @@ -21,8 +21,8 @@ export function testAcceptMime(options: PlatformTestOptions) { PlatformTest.bootstrap(options.server, { ...options, mount: { - "/rest": [TestAcceptMimeCtrl], - }, + "/rest": [TestAcceptMimeCtrl] + } }) ); before(() => { @@ -34,19 +34,19 @@ export function testAcceptMime(options: PlatformTestOptions) { const response = await request .post("/rest/accept-mime/scenario-1") .set({ - Accept: "application/json", + Accept: "application/json" }) .expect(200); expect(response.body).to.deep.equal({ - accept: "application/json", + accept: "application/json" }); }); it("should return a 406 response when Accept header doesn't match with @AcceptMime(\"application/json\")", async () => { const response = await request .post("/rest/accept-mime/scenario-1") .set({ - Accept: "application/xml", + Accept: "application/xml" }) .expect(406); diff --git a/packages/platform-test-utils/src/tests/testAuth.ts b/packages/platform-test-utils/src/tests/testAuth.ts index b9486b90c21..f88661943d9 100644 --- a/packages/platform-test-utils/src/tests/testAuth.ts +++ b/packages/platform-test-utils/src/tests/testAuth.ts @@ -58,9 +58,9 @@ export function OAuth(options: any = {}): Function { in: "header", name: "Authorization", type: "string", - required: true, - }, - ], + required: true + } + ] }), Returns(401, {description: "Unauthorized"}), Returns(403, {description: "Forbidden"}) @@ -77,7 +77,7 @@ class TestAuthCtrl { this.tokenService.token("access_token"); return { - access_token: this.tokenService.token(), + access_token: this.tokenService.token() }; } @@ -86,7 +86,7 @@ class TestAuthCtrl { token() { return { id: "id", - name: "name", + name: "name" }; } @@ -94,7 +94,7 @@ class TestAuthCtrl { @OAuth({role: "admin", scopes: ["admin"]}) admin() { return { - granted: true, + granted: true }; } @@ -103,7 +103,7 @@ class TestAuthCtrl { this.tokenService.token("admin_token"); return { - access_token: this.tokenService.token(), + access_token: this.tokenService.token() }; } } @@ -115,14 +115,14 @@ export function testAuth(options: PlatformTestOptions) { PlatformTest.bootstrap(options.server, { ...options, mount: { - "/rest": [TestAuthCtrl], + "/rest": [TestAuthCtrl] }, swagger: [ { path: "/doc", - spec: baseSpec as any, - }, - ], + spec: baseSpec as any + } + ] }) ); before(() => { @@ -136,7 +136,7 @@ export function testAuth(options: PlatformTestOptions) { await request .get("/rest/auth/userinfo") .set({ - Authorization: "wrong", + Authorization: "wrong" }) .expect(400); @@ -147,24 +147,24 @@ export function testAuth(options: PlatformTestOptions) { const {body: userInfo} = await request .get("/rest/auth/userinfo") .set({ - Authorization: body.access_token, + Authorization: body.access_token }) .expect(200); expect(userInfo).to.deep.eq({ id: "id", - name: "name", + name: "name" }); await request .get("/rest/auth/admin") .set({ - Authorization: body.access_token, + Authorization: body.access_token }) .expect(403); const { - body: {access_token}, + body: {access_token} } = await request.post("/rest/auth/stepUp").expect(200); expect(access_token).to.equal("admin_token"); @@ -172,12 +172,12 @@ export function testAuth(options: PlatformTestOptions) { const {body: result} = await request .get("/rest/auth/admin") .set({ - Authorization: access_token, + Authorization: access_token }) .expect(200); expect(result).to.deep.eq({ - granted: true, + granted: true }); }); }); @@ -193,7 +193,7 @@ export function testAuth(options: PlatformTestOptions) { description: "", termsOfService: "", title: "Api documentation", - version: "1.0.0", + version: "1.0.0" }, paths: { "/rest/auth/admin": { @@ -204,49 +204,49 @@ export function testAuth(options: PlatformTestOptions) { in: "header", name: "Authorization", required: true, - type: "string", - }, + type: "string" + } ], responses: { "200": { - description: "Success", + description: "Success" }, "401": { - description: "Unauthorized", + description: "Unauthorized" }, "403": { - description: "Forbidden", - }, + description: "Forbidden" + } }, security: [ { - global_auth: ["admin"], - }, + global_auth: ["admin"] + } ], - tags: ["TestAuthCtrl"], - }, + tags: ["TestAuthCtrl"] + } }, "/rest/auth/authorize": { post: { operationId: "TestAuthCtrl.authorize", responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["TestAuthCtrl"], - }, + tags: ["TestAuthCtrl"] + } }, "/rest/auth/stepUp": { post: { operationId: "TestAuthCtrl.stepUp", responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["TestAuthCtrl"], - }, + tags: ["TestAuthCtrl"] + } }, "/rest/auth/userinfo": { get: { @@ -256,37 +256,37 @@ export function testAuth(options: PlatformTestOptions) { in: "header", name: "Authorization", required: true, - type: "string", - }, + type: "string" + } ], responses: { "200": { - description: "Success", + description: "Success" }, "401": { - description: "Unauthorized", + description: "Unauthorized" }, "403": { - description: "Forbidden", - }, + description: "Forbidden" + } }, security: [ { - global_auth: [], - }, + global_auth: [] + } ], - tags: ["TestAuthCtrl"], - }, - }, + tags: ["TestAuthCtrl"] + } + } }, produces: ["application/json"], securityDefinitions: {}, swagger: "2.0", tags: [ { - name: "TestAuthCtrl", - }, - ], + name: "TestAuthCtrl" + } + ] }); }); }); diff --git a/packages/platform-test-utils/src/tests/testBodyParams.ts b/packages/platform-test-utils/src/tests/testBodyParams.ts index ccc09cac24c..5551e972b26 100644 --- a/packages/platform-test-utils/src/tests/testBodyParams.ts +++ b/packages/platform-test-utils/src/tests/testBodyParams.ts @@ -34,8 +34,8 @@ export function testBodyParams(options: PlatformTestOptions) { PlatformTest.bootstrap(options.server, { ...options, mount: { - "/rest": [TestBodyParamsCtrl], - }, + "/rest": [TestBodyParamsCtrl] + } }) ); before(() => { @@ -48,18 +48,18 @@ export function testBodyParams(options: PlatformTestOptions) { const response = await request .post("/rest/body-params/scenario-1") .set({ - "Content-Type": "application/json", + "Content-Type": "application/json" }) .send({ - id: "id", + id: "id" }) .expect(201); expect(response.body).to.deep.equal({ contentType: "application/json", payload: { - id: "id", - }, + id: "id" + } }); }); }); @@ -68,7 +68,7 @@ export function testBodyParams(options: PlatformTestOptions) { const response = await request .post("/rest/body-params/scenario-2") .send({ - test: ["value"], + test: ["value"] }) .expect(200); diff --git a/packages/platform-test-utils/src/tests/testChildrenControllers.ts b/packages/platform-test-utils/src/tests/testChildrenControllers.ts index a68e22c91bc..b511e3eb2d8 100644 --- a/packages/platform-test-utils/src/tests/testChildrenControllers.ts +++ b/packages/platform-test-utils/src/tests/testChildrenControllers.ts @@ -13,7 +13,7 @@ class TestChildController { @Controller({ path: "/controllers", - children: [TestChildController], + children: [TestChildController] }) class TestController { @Get("/scenario-1") @@ -28,8 +28,8 @@ export function testChildrenControllers(options: PlatformTestOptions) { PlatformTest.bootstrap(options.server, { ...options, mount: { - "/rest": [TestController], - }, + "/rest": [TestController] + } }) ); beforeEach(() => { diff --git a/packages/platform-test-utils/src/tests/testCookies.ts b/packages/platform-test-utils/src/tests/testCookies.ts index 4ffa57a4961..a231d04641e 100644 --- a/packages/platform-test-utils/src/tests/testCookies.ts +++ b/packages/platform-test-utils/src/tests/testCookies.ts @@ -21,8 +21,8 @@ export function testCookies(options: PlatformTestOptions) { PlatformTest.bootstrap(options.server, { ...options, mount: { - "/rest": [CookiesCtrl], - }, + "/rest": [CookiesCtrl] + } }) ); before(() => { diff --git a/packages/platform-test-utils/src/tests/testCustom404.ts b/packages/platform-test-utils/src/tests/testCustom404.ts index 7c60535690c..3b865618f7f 100644 --- a/packages/platform-test-utils/src/tests/testCustom404.ts +++ b/packages/platform-test-utils/src/tests/testCustom404.ts @@ -16,8 +16,8 @@ export function testCustom404(options: PlatformTestOptions) { PlatformTest.bootstrap(CustomServer, { ...options, mount: { - "/rest": [], - }, + "/rest": [] + } }) ); diff --git a/packages/platform-test-utils/src/tests/testErrors.ts b/packages/platform-test-utils/src/tests/testErrors.ts index 2a6fac678e5..1ac2eb97e2a 100644 --- a/packages/platform-test-utils/src/tests/testErrors.ts +++ b/packages/platform-test-utils/src/tests/testErrors.ts @@ -72,8 +72,8 @@ export function testErrors(options: PlatformTestOptions) { PlatformTest.bootstrap(options.server, { ...options, mount: { - "/rest": [ErrorsCtrl], - }, + "/rest": [ErrorsCtrl] + } }) ); before(() => { diff --git a/packages/platform-test-utils/src/tests/testHandlers.ts b/packages/platform-test-utils/src/tests/testHandlers.ts index 11ca5cb11c5..fc81e24cec9 100644 --- a/packages/platform-test-utils/src/tests/testHandlers.ts +++ b/packages/platform-test-utils/src/tests/testHandlers.ts @@ -55,8 +55,8 @@ export function testHandlers(options: PlatformTestOptions) { PlatformTest.bootstrap(options.server, { ...options, mount: { - "/rest": [HandlersCtrl], - }, + "/rest": [HandlersCtrl] + } }) ); before(() => { diff --git a/packages/platform-test-utils/src/tests/testHeaderParams.ts b/packages/platform-test-utils/src/tests/testHeaderParams.ts index c8a461f0a42..b5384ee8e4c 100644 --- a/packages/platform-test-utils/src/tests/testHeaderParams.ts +++ b/packages/platform-test-utils/src/tests/testHeaderParams.ts @@ -24,7 +24,7 @@ export class HeaderParamsCtrl { public scenario1(@Req() request: Req, @HeaderParams("authorization") auth: string): any { return { user: request.user, - token: auth, + token: auth }; } @@ -40,8 +40,8 @@ export function testHeaderParams(options: PlatformTestOptions) { PlatformTest.bootstrap(options.server, { ...options, mount: { - "/rest": [HeaderParamsCtrl], - }, + "/rest": [HeaderParamsCtrl] + } }) ); before(() => { @@ -54,7 +54,7 @@ export function testHeaderParams(options: PlatformTestOptions) { const {body}: any = await request .get("/rest/header-params/scenario-1") .set({ - Authorization: "tokenauth", + Authorization: "tokenauth" }) .expect(200); @@ -68,12 +68,12 @@ export function testHeaderParams(options: PlatformTestOptions) { const response = await request .post("/rest/header-params/scenario-2") .set({ - "Content-Type": "application/json", + "Content-Type": "application/json" }) .expect(200); expect(response.body).to.deep.equal({ - contentType: "application/json", + contentType: "application/json" }); }); }); diff --git a/packages/platform-test-utils/src/tests/testHeaders.ts b/packages/platform-test-utils/src/tests/testHeaders.ts index 92a0743735d..c2ccd0f614f 100644 --- a/packages/platform-test-utils/src/tests/testHeaders.ts +++ b/packages/platform-test-utils/src/tests/testHeaders.ts @@ -31,8 +31,8 @@ export function testHeaders(options: PlatformTestOptions) { PlatformTest.bootstrap(options.server, { ...options, mount: { - "/rest": [HeadersCtrl], - }, + "/rest": [HeadersCtrl] + } }) ); before(() => { diff --git a/packages/platform-test-utils/src/tests/testInheritanceController.ts b/packages/platform-test-utils/src/tests/testInheritanceController.ts index 196e7a7d0f2..e22b7cfa0de 100644 --- a/packages/platform-test-utils/src/tests/testInheritanceController.ts +++ b/packages/platform-test-utils/src/tests/testInheritanceController.ts @@ -10,7 +10,7 @@ import { Post, Property, Returns, - Status, + Status } from "@tsed/common"; import {NotFound} from "@tsed/exceptions"; import {Summary} from "@tsed/swagger"; @@ -90,8 +90,8 @@ export function testInheritanceController(options: PlatformTestOptions) { PlatformTest.bootstrap(options.server, { ...options, mount: { - "/rest": [ResourcesCtrl], - }, + "/rest": [ResourcesCtrl] + } }) ); before(() => { @@ -110,7 +110,7 @@ export function testInheritanceController(options: PlatformTestOptions) { expect(body).to.deep.eq({ id: "1", - name: "John hello You!", + name: "John hello You!" }); }); @@ -118,7 +118,7 @@ export function testInheritanceController(options: PlatformTestOptions) { const {body} = await request .post("/rest/resources") .send({ - name: "july", + name: "july" }) .expect(201); diff --git a/packages/platform-test-utils/src/tests/testLocals.ts b/packages/platform-test-utils/src/tests/testLocals.ts index cb003194da7..ec7625357f4 100644 --- a/packages/platform-test-utils/src/tests/testLocals.ts +++ b/packages/platform-test-utils/src/tests/testLocals.ts @@ -17,7 +17,7 @@ class LocalsCtrl { @Use(middleware) public testStackMiddlewares(@Request("user") user: any, @Locals("id") id: any, @Context("uid") uid: string): any { return { - id: `${user}-${id}-${uid}`, + id: `${user}-${id}-${uid}` }; } } @@ -28,8 +28,8 @@ export function testLocals(options: PlatformTestOptions) { PlatformTest.bootstrap(options.server, { ...options, mount: { - "/rest": [LocalsCtrl], - }, + "/rest": [LocalsCtrl] + } }) ); before(() => { diff --git a/packages/platform-test-utils/src/tests/testLocation.ts b/packages/platform-test-utils/src/tests/testLocation.ts index 500995488ff..f873c438371 100644 --- a/packages/platform-test-utils/src/tests/testLocation.ts +++ b/packages/platform-test-utils/src/tests/testLocation.ts @@ -19,8 +19,8 @@ export function testLocation(options: PlatformTestOptions) { PlatformTest.bootstrap(options.server, { ...options, mount: { - "/rest": [LocationCtrl], - }, + "/rest": [LocationCtrl] + } }) ); before(() => { diff --git a/packages/platform-test-utils/src/tests/testModule.ts b/packages/platform-test-utils/src/tests/testModule.ts index d96979f9b40..4dafdb38352 100644 --- a/packages/platform-test-utils/src/tests/testModule.ts +++ b/packages/platform-test-utils/src/tests/testModule.ts @@ -19,9 +19,9 @@ export function testModule(options: PlatformTestOptions) { PlatformTest.bootstrap(options.server, { ...options, mount: { - "/rest": [TestRootCtrl], + "/rest": [TestRootCtrl] }, - imports: [FeatureModule], + imports: [FeatureModule] }) ); before(() => { diff --git a/packages/platform-test-utils/src/tests/testPathParams.ts b/packages/platform-test-utils/src/tests/testPathParams.ts index 3c7fbfac714..92b48b24b76 100644 --- a/packages/platform-test-utils/src/tests/testPathParams.ts +++ b/packages/platform-test-utils/src/tests/testPathParams.ts @@ -47,8 +47,8 @@ export function testPathParams(options: PlatformTestOptions) { PlatformTest.bootstrap(options.server, { ...options, mount: { - "/rest": [TestPathParamsCtrl], - }, + "/rest": [TestPathParamsCtrl] + } }) ); before(() => { diff --git a/packages/platform-test-utils/src/tests/testQueryParams.ts b/packages/platform-test-utils/src/tests/testQueryParams.ts index 4a8fd4664cd..ad750b75b71 100644 --- a/packages/platform-test-utils/src/tests/testQueryParams.ts +++ b/packages/platform-test-utils/src/tests/testQueryParams.ts @@ -33,8 +33,8 @@ export function testQueryParams(options: PlatformTestOptions) { PlatformTest.bootstrap(options.server, { ...options, mount: { - "/rest": [TestQueryParamsCtrl], - }, + "/rest": [TestQueryParamsCtrl] + } }) ); before(() => { diff --git a/packages/platform-test-utils/src/tests/testRedirect.ts b/packages/platform-test-utils/src/tests/testRedirect.ts index 2698bb5861f..328538d1134 100644 --- a/packages/platform-test-utils/src/tests/testRedirect.ts +++ b/packages/platform-test-utils/src/tests/testRedirect.ts @@ -26,8 +26,8 @@ export function testRedirect(options: PlatformTestOptions) { PlatformTest.bootstrap(options.server, { ...options, mount: { - "/rest": [RedirectCtrl], - }, + "/rest": [RedirectCtrl] + } }) ); before(() => { diff --git a/packages/platform-test-utils/src/tests/testResponse.ts b/packages/platform-test-utils/src/tests/testResponse.ts index b7e2e2454f6..991ac92d621 100644 --- a/packages/platform-test-utils/src/tests/testResponse.ts +++ b/packages/platform-test-utils/src/tests/testResponse.ts @@ -41,7 +41,7 @@ class TestResponseParamsCtrl { response.status(201); return { - id: 1, + id: 1 }; } @@ -67,7 +67,7 @@ class TestResponseParamsCtrl { }); return { - id: 1, + id: 1 }; } @@ -125,8 +125,8 @@ export function testResponse(options: PlatformTestOptions) { PlatformTest.bootstrap(options.server, { ...options, mount: { - "/rest": [TestResponseParamsCtrl], - }, + "/rest": [TestResponseParamsCtrl] + } }) ); before(() => { diff --git a/packages/platform-test-utils/src/tests/testRouting.ts b/packages/platform-test-utils/src/tests/testRouting.ts index a1baf10e9e2..cf7262147f8 100644 --- a/packages/platform-test-utils/src/tests/testRouting.ts +++ b/packages/platform-test-utils/src/tests/testRouting.ts @@ -37,8 +37,8 @@ export function testRouting(options: PlatformTestOptions) { PlatformTest.bootstrap(options.server, { ...options, mount: { - "/rest": [TestRoutingController], - }, + "/rest": [TestRoutingController] + } }) ); before(() => { diff --git a/packages/platform-test-utils/src/tests/testScopeRequest.ts b/packages/platform-test-utils/src/tests/testScopeRequest.ts index 94f2c511756..1cf3bffa9c1 100644 --- a/packages/platform-test-utils/src/tests/testScopeRequest.ts +++ b/packages/platform-test-utils/src/tests/testScopeRequest.ts @@ -54,8 +54,8 @@ export function testScopeRequest(options: PlatformTestOptions) { PlatformTest.bootstrap(options.server, { ...options, mount: { - "/rest": [ScopeRequestCtrl], - }, + "/rest": [ScopeRequestCtrl] + } }) ); before(() => { @@ -91,20 +91,20 @@ export function testScopeRequest(options: PlatformTestOptions) { id: "0", idCtrl: "0", idSrv: "0", - userId: "0", + userId: "0" }, { id: "1", idCtrl: "1", idSrv: "1", - userId: "1", + userId: "1" }, { id: "2", idCtrl: "2", idSrv: "2", - userId: "2", - }, + userId: "2" + } ]); }); }); diff --git a/packages/platform-test-utils/src/tests/testSession.ts b/packages/platform-test-utils/src/tests/testSession.ts index 4a0ce2d6c29..d19324c177c 100644 --- a/packages/platform-test-utils/src/tests/testSession.ts +++ b/packages/platform-test-utils/src/tests/testSession.ts @@ -12,7 +12,7 @@ import { Required, Returns, Session, - Status, + Status } from "@tsed/common"; import {NotFound} from "@tsed/exceptions"; import {Indexed, Unique} from "@tsed/mongoose"; @@ -78,8 +78,8 @@ export function testSession(options: PlatformTestOptions) { PlatformTest.bootstrap(options.server, { ...options, mount: { - "/rest": [SessionCtrl], - }, + "/rest": [SessionCtrl] + } }) ); before(() => { @@ -97,7 +97,7 @@ export function testSession(options: PlatformTestOptions) { await request.post("/rest/session/connect").send({ name: "name", email: "test@test.fr", - password: "password1234", + password: "password1234" }); // @ts-ignore @@ -105,7 +105,7 @@ export function testSession(options: PlatformTestOptions) { expect(response.body).to.deep.eq({ email: "test@test.fr", - name: "name", + name: "name" }); await request.get("/rest/session/logout").expect(204); diff --git a/packages/platform-test-utils/src/tests/testStatics.ts b/packages/platform-test-utils/src/tests/testStatics.ts index 36f4f1b4849..32840c756e2 100644 --- a/packages/platform-test-utils/src/tests/testStatics.ts +++ b/packages/platform-test-utils/src/tests/testStatics.ts @@ -10,8 +10,8 @@ export function testStatics(options: PlatformTestOptions) { PlatformTest.bootstrap(options.server, { ...options, mount: { - "/": [], - }, + "/": [] + } }) ); beforeEach(() => { diff --git a/packages/platform-test-utils/src/tests/testView.ts b/packages/platform-test-utils/src/tests/testView.ts index 369aba3a877..c9da4dbc6e1 100644 --- a/packages/platform-test-utils/src/tests/testView.ts +++ b/packages/platform-test-utils/src/tests/testView.ts @@ -18,7 +18,7 @@ class ViewCtrl { @View("view.ejs", {opts: "opts"}) testScenario1() { return { - world: "world", + world: "world" }; } @@ -26,7 +26,7 @@ class ViewCtrl { @View("view", {opts: "opts"}) // missing extension testScenario2() { return { - world: "world", + world: "world" }; } } @@ -38,8 +38,8 @@ export function testView(options: PlatformTestOptions) { PlatformTest.bootstrap(options.server, { ...options, mount: { - "/rest": [ViewCtrl], - }, + "/rest": [ViewCtrl] + } }) ); before(() => { diff --git a/packages/schema/src/constants/httpStatusMessages.ts b/packages/schema/src/constants/httpStatusMessages.ts index a7fc0f75a98..6a1be2c7b36 100644 --- a/packages/schema/src/constants/httpStatusMessages.ts +++ b/packages/schema/src/constants/httpStatusMessages.ts @@ -58,5 +58,5 @@ export const HTTP_STATUS_MESSAGES: {[key: string]: string} = { "508": "Loop Detected", "509": "Unassigned", "510": "Not Extended", - "511": "Network Authentication Required", + "511": "Network Authentication Required" }; diff --git a/packages/schema/src/decorators/collections/collectionOf.spec.ts b/packages/schema/src/decorators/collections/collectionOf.spec.ts index 40607ecc798..f10ad5968bf 100644 --- a/packages/schema/src/decorators/collections/collectionOf.spec.ts +++ b/packages/schema/src/decorators/collections/collectionOf.spec.ts @@ -19,12 +19,12 @@ describe("@CollectionOf", () => { properties: { num: { items: { - type: "number", + type: "number" }, - type: "array", - }, + type: "array" + } }, - type: "object", + type: "object" }); }); it("should declare a collection (Array of Model)", () => { @@ -55,23 +55,23 @@ describe("@CollectionOf", () => { Nested: { properties: { id: { - type: "string", - }, + type: "string" + } }, - type: "object", - }, + type: "object" + } }, properties: { prop: { items: { - $ref: "#/definitions/Nested", + $ref: "#/definitions/Nested" }, minItems: 1, maxItems: 10, - type: "array", - }, + type: "array" + } }, - type: "object", + type: "object" }); }); it("should declare a collection (Array of Model on param)", () => { @@ -101,27 +101,27 @@ describe("@CollectionOf", () => { Model: { properties: { id: { - type: "string", + type: "string" }, prop: { - $ref: "#/definitions/Nested", - }, + $ref: "#/definitions/Nested" + } }, - type: "object", + type: "object" }, Nested: { properties: { id: { - type: "string", - }, + type: "string" + } }, - type: "object", - }, + type: "object" + } }, items: { - $ref: "#/definitions/Model", + $ref: "#/definitions/Model" }, - type: "array", + type: "array" }); }); it("should declare a collection (Map of)", () => { @@ -138,14 +138,14 @@ describe("@CollectionOf", () => { properties: { num: { additionalProperties: { - type: "number", + type: "number" }, maxProperties: 5, minProperties: 2, - type: "object", - }, + type: "object" + } }, - type: "object", + type: "object" }); }); it("should declare a collection (Set of)", () => { @@ -162,13 +162,13 @@ describe("@CollectionOf", () => { properties: { num: { items: { - type: "number", + type: "number" }, type: "array", - uniqueItems: true, - }, + uniqueItems: true + } }, - type: "object", + type: "object" }); }); it("should declare collection with additional props", () => { @@ -186,14 +186,14 @@ describe("@CollectionOf", () => { words: { type: "array", items: { - type: "string", + type: "string" }, maxItems: 10, minItems: 0, - uniqueItems: true, - }, + uniqueItems: true + } }, - type: "object", + type: "object" }); }); it("should declare collection with additional props and contains", () => { @@ -211,13 +211,13 @@ describe("@CollectionOf", () => { words: { type: "array", contains: { - type: "string", + type: "string" }, maxItems: 10, - minItems: 0, - }, + minItems: 0 + } }, - type: "object", + type: "object" }); }); }); @@ -241,12 +241,12 @@ describe("@ArrayOf", () => { properties: { num: { items: { - type: "number", + type: "number" }, - type: "array", - }, + type: "array" + } }, - type: "object", + type: "object" }); }); }); @@ -270,14 +270,14 @@ describe("@MapOf", () => { properties: { num: { additionalProperties: { - type: "number", + type: "number" }, maxProperties: 5, minProperties: 2, - type: "object", - }, + type: "object" + } }, - type: "object", + type: "object" }); }); }); diff --git a/packages/schema/src/decorators/collections/maxItems.spec.ts b/packages/schema/src/decorators/collections/maxItems.spec.ts index 2cfa4de4ee5..d82561b1404 100644 --- a/packages/schema/src/decorators/collections/maxItems.spec.ts +++ b/packages/schema/src/decorators/collections/maxItems.spec.ts @@ -16,13 +16,13 @@ describe("@MaxItems", () => { properties: { num: { items: { - type: "number", + type: "number" }, maxItems: 10, - type: "array", - }, + type: "array" + } }, - type: "object", + type: "object" }); }); it("should throw error", () => { diff --git a/packages/schema/src/decorators/collections/maxProperties.spec.ts b/packages/schema/src/decorators/collections/maxProperties.spec.ts index eee42937155..6e7df5afd90 100644 --- a/packages/schema/src/decorators/collections/maxProperties.spec.ts +++ b/packages/schema/src/decorators/collections/maxProperties.spec.ts @@ -16,10 +16,10 @@ describe("@MaxProperties", () => { properties: { prop: { maxProperties: 10, - type: "object", - }, + type: "object" + } }, - type: "object", + type: "object" }); }); it("should declare max value (Map)", () => { @@ -34,10 +34,10 @@ describe("@MaxProperties", () => { properties: { prop: { maxProperties: 10, - type: "object", - }, + type: "object" + } }, - type: "object", + type: "object" }); }); it("should declare max value on class", () => { @@ -48,7 +48,7 @@ describe("@MaxProperties", () => { // THEN expect(getJsonSchema(Model)).to.deep.equal({ maxProperties: 10, - type: "object", + type: "object" }); }); it("should declare max value on param", () => { @@ -63,8 +63,8 @@ describe("@MaxProperties", () => { definitions: {}, tags: [ { - name: "MyController", - }, + name: "MyController" + } ], paths: { "/": { @@ -77,19 +77,19 @@ describe("@MaxProperties", () => { required: false, schema: { maxProperties: 10, - type: "object", - }, - }, + type: "object" + } + } ], responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["MyController"], - }, - }, - }, + tags: ["MyController"] + } + } + } }); }); it("should throw an error when the given parameters is as negative integer", () => { diff --git a/packages/schema/src/decorators/collections/minItems.spec.ts b/packages/schema/src/decorators/collections/minItems.spec.ts index 4dae8ec05b4..8d968c89991 100644 --- a/packages/schema/src/decorators/collections/minItems.spec.ts +++ b/packages/schema/src/decorators/collections/minItems.spec.ts @@ -16,13 +16,13 @@ describe("@MinItems", () => { properties: { num: { items: { - type: "number", + type: "number" }, minItems: 10, - type: "array", - }, + type: "array" + } }, - type: "object", + type: "object" }); }); it("should throw error", () => { diff --git a/packages/schema/src/decorators/collections/minProperties.spec.ts b/packages/schema/src/decorators/collections/minProperties.spec.ts index 997606d34c4..e1c82b48fe4 100644 --- a/packages/schema/src/decorators/collections/minProperties.spec.ts +++ b/packages/schema/src/decorators/collections/minProperties.spec.ts @@ -16,10 +16,10 @@ describe("@MinProperties", () => { properties: { prop: { minProperties: 10, - type: "object", - }, + type: "object" + } }, - type: "object", + type: "object" }); }); it("should declare min value (Map)", () => { @@ -34,10 +34,10 @@ describe("@MinProperties", () => { properties: { prop: { minProperties: 10, - type: "object", - }, + type: "object" + } }, - type: "object", + type: "object" }); }); it("should declare min value on class", () => { @@ -48,7 +48,7 @@ describe("@MinProperties", () => { // THEN expect(getJsonSchema(Model)).to.deep.equal({ minProperties: 10, - type: "object", + type: "object" }); }); it("should declare min value on param", () => { @@ -63,8 +63,8 @@ describe("@MinProperties", () => { definitions: {}, tags: [ { - name: "MyController", - }, + name: "MyController" + } ], paths: { "/": { @@ -77,19 +77,19 @@ describe("@MinProperties", () => { required: false, schema: { minProperties: 10, - type: "object", - }, - }, + type: "object" + } + } ], responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["MyController"], - }, - }, - }, + tags: ["MyController"] + } + } + } }); }); it("should throw an error when the given parameters is as negative integer", () => { diff --git a/packages/schema/src/decorators/collections/uniqueItems.spec.ts b/packages/schema/src/decorators/collections/uniqueItems.spec.ts index 8e2d95d018f..e6c13dc50d1 100644 --- a/packages/schema/src/decorators/collections/uniqueItems.spec.ts +++ b/packages/schema/src/decorators/collections/uniqueItems.spec.ts @@ -17,13 +17,13 @@ describe("@UniqueItems", () => { properties: { num: { items: { - type: "number", + type: "number" }, uniqueItems: true, - type: "array", - }, + type: "array" + } }, - type: "object", + type: "object" }); }); }); diff --git a/packages/schema/src/decorators/common/additionalProperties.spec.ts b/packages/schema/src/decorators/common/additionalProperties.spec.ts index 3c145ee9d91..07991576700 100644 --- a/packages/schema/src/decorators/common/additionalProperties.spec.ts +++ b/packages/schema/src/decorators/common/additionalProperties.spec.ts @@ -15,10 +15,10 @@ describe("AdditionalProperties", () => { additionalProperties: true, properties: { id: { - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }); }); }); diff --git a/packages/schema/src/decorators/common/allow.spec.ts b/packages/schema/src/decorators/common/allow.spec.ts index 9e1ed16bdea..ec420745df2 100644 --- a/packages/schema/src/decorators/common/allow.spec.ts +++ b/packages/schema/src/decorators/common/allow.spec.ts @@ -20,11 +20,11 @@ describe("@Allow", () => { properties: { allow: { type: "string", - minLength: 1, - }, + minLength: 1 + } }, required: ["allow"], - type: "object", + type: "object" }); const validate = new Ajv().compile(classSchema); @@ -45,11 +45,11 @@ describe("@Allow", () => { expect(classSchema).to.deep.equal({ properties: { allow: { - type: "string", - }, + type: "string" + } }, required: ["allow"], - type: "object", + type: "object" }); const validate = new Ajv().compile(classSchema); @@ -70,11 +70,11 @@ describe("@Allow", () => { properties: { allow: { minLength: 1, - type: ["string", "null"], - }, + type: ["string", "null"] + } }, required: ["allow"], - type: "object", + type: "object" }); const validate = new Ajv().compile(classSchema); @@ -101,26 +101,26 @@ describe("@Allow", () => { NestedModel: { properties: { prop: { - type: "string", - }, + type: "string" + } }, - type: "object", - }, + type: "object" + } }, properties: { allow: { oneOf: [ { - type: "null", + type: "null" }, { - $ref: "#/definitions/NestedModel", - }, - ], - }, + $ref: "#/definitions/NestedModel" + } + ] + } }, required: ["allow"], - type: "object", + type: "object" }); const validate = new Ajv().compile(classSchema); diff --git a/packages/schema/src/decorators/common/allow.ts b/packages/schema/src/decorators/common/allow.ts index 7de9244e206..d45809d5fd5 100644 --- a/packages/schema/src/decorators/common/allow.ts +++ b/packages/schema/src/decorators/common/allow.ts @@ -24,10 +24,10 @@ function applyNullRule(store: JsonEntityStore, values: any[]) { properties[store.propertyKey as any] = { oneOf: [ { - type: "null", + type: "null" }, - propSchema, - ], + propSchema + ] }; } } else { diff --git a/packages/schema/src/decorators/common/any.spec.ts b/packages/schema/src/decorators/common/any.spec.ts index 4f78a9c2ae5..d52ca58e975 100644 --- a/packages/schema/src/decorators/common/any.spec.ts +++ b/packages/schema/src/decorators/common/any.spec.ts @@ -14,10 +14,10 @@ describe("@Any", () => { expect(getJsonSchema(Model)).to.deep.equal({ properties: { prop: { - type: ["integer", "number", "string", "boolean", "array", "object", "null"], - }, + type: ["integer", "number", "string", "boolean", "array", "object", "null"] + } }, - type: "object", + type: "object" }); }); it("should declare any prop (uniq type)", () => { @@ -31,10 +31,10 @@ describe("@Any", () => { expect(getJsonSchema(Model)).to.deep.equal({ properties: { prop: { - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }); }); it("should declare any prop (with list)", () => { @@ -48,10 +48,10 @@ describe("@Any", () => { expect(getJsonSchema(Model)).to.deep.equal({ properties: { prop: { - type: ["string", "number", "boolean", "null"], - }, + type: ["string", "number", "boolean", "null"] + } }, - type: "object", + type: "object" }); }); it("should declare any prop (with string, list)", () => { @@ -65,10 +65,10 @@ describe("@Any", () => { expect(getJsonSchema(Model)).to.deep.equal({ properties: { prop: { - type: ["string", "null"], - }, + type: ["string", "null"] + } }, - type: "object", + type: "object" }); }); }); diff --git a/packages/schema/src/decorators/common/const.spec.ts b/packages/schema/src/decorators/common/const.spec.ts index e54fa98bc3e..2dd6b4a44c1 100644 --- a/packages/schema/src/decorators/common/const.spec.ts +++ b/packages/schema/src/decorators/common/const.spec.ts @@ -18,10 +18,10 @@ describe("@Const", () => { properties: { num: { const: "10", - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }); }); }); diff --git a/packages/schema/src/decorators/common/default.spec.ts b/packages/schema/src/decorators/common/default.spec.ts index eed3f90e47a..48fa704ecd2 100644 --- a/packages/schema/src/decorators/common/default.spec.ts +++ b/packages/schema/src/decorators/common/default.spec.ts @@ -17,10 +17,10 @@ describe("@Default", () => { properties: { num: { default: "10", - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }); }); }); diff --git a/packages/schema/src/decorators/common/description.spec.ts b/packages/schema/src/decorators/common/description.spec.ts index e2e7953db6f..babf4fe3cd2 100644 --- a/packages/schema/src/decorators/common/description.spec.ts +++ b/packages/schema/src/decorators/common/description.spec.ts @@ -13,7 +13,7 @@ describe("@Description", () => { // THEN expect(getJsonSchema(Model)).to.deep.equal({ description: "Description", - type: "object", + type: "object" }); }); it("should declare description on method", () => { @@ -36,14 +36,14 @@ describe("@Description", () => { parameters: [], responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["Model"], - }, - }, + tags: ["Model"] + } + } }, - tags: [{name: "Model"}], + tags: [{name: "Model"}] }); }); it("should declare description on property", () => { @@ -59,10 +59,10 @@ describe("@Description", () => { properties: { method: { description: "Description", - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }); }); it("should declare description on params (QUERY)", () => { @@ -78,8 +78,8 @@ describe("@Description", () => { definitions: {}, tags: [ { - name: "Model", - }, + name: "Model" + } ], paths: { "/": { @@ -90,18 +90,18 @@ describe("@Description", () => { description: "Description", in: "query", required: false, - type: "string", - }, + type: "string" + } ], responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["Model"], - }, - }, - }, + tags: ["Model"] + } + } + } }); }); it("should declare description on params (BODY)", () => { @@ -122,16 +122,16 @@ describe("@Description", () => { MyModel: { properties: { id: { - type: "string", - }, + type: "string" + } }, - type: "object", - }, + type: "object" + } }, tags: [ { - name: "MyController", - }, + name: "MyController" + } ], paths: { "/": { @@ -144,19 +144,19 @@ describe("@Description", () => { required: false, description: "Description", schema: { - $ref: "#/definitions/MyModel", - }, - }, + $ref: "#/definitions/MyModel" + } + } ], responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["MyController"], - }, - }, - }, + tags: ["MyController"] + } + } + } }); }); it("should declare description on params (BODY - openapi3)", () => { @@ -178,17 +178,17 @@ describe("@Description", () => { MyModel: { properties: { id: { - type: "string", - }, + type: "string" + } }, - type: "object", - }, - }, + type: "object" + } + } }, tags: [ { - name: "MyController", - }, + name: "MyController" + } ], paths: { "/": { @@ -199,22 +199,22 @@ describe("@Description", () => { content: { "application/json": { schema: { - $ref: "#/components/schemas/MyModel", - }, - }, + $ref: "#/components/schemas/MyModel" + } + } }, description: "Description", - required: false, + required: false }, responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["MyController"], - }, - }, - }, + tags: ["MyController"] + } + } + } }); }); it("should throw error when the decorator isn't used with a supported decorator type", () => { diff --git a/packages/schema/src/decorators/common/enum.spec.ts b/packages/schema/src/decorators/common/enum.spec.ts index 55e3ff9c2ee..5ac73e4c136 100644 --- a/packages/schema/src/decorators/common/enum.spec.ts +++ b/packages/schema/src/decorators/common/enum.spec.ts @@ -15,10 +15,10 @@ describe("@Enum", () => { properties: { num: { enum: ["0", "1"], - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }); }); it("should declare prop (mixed type)", () => { @@ -32,10 +32,10 @@ describe("@Enum", () => { properties: { num: { enum: ["0", "1", 10], - type: ["string", "number"], - }, + type: ["string", "number"] + } }, - type: "object", + type: "object" }); }); it("should declare prop (mixed type and null)", () => { @@ -49,10 +49,10 @@ describe("@Enum", () => { properties: { num: { enum: ["0", "1", 10, null], - type: ["string", "number", "null"], - }, + type: ["string", "number", "null"] + } }, - type: "object", + type: "object" }); }); }); @@ -60,7 +60,7 @@ describe("@Enum", () => { describe("when is a typescript enum (string)", () => { enum SomeEnum { ENUM_1 = "enum1", - ENUM_2 = "enum2", + ENUM_2 = "enum2" } it("should declare prop", () => { @@ -74,10 +74,10 @@ describe("@Enum", () => { properties: { num: { enum: ["enum1", "enum2"], - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }); }); }); @@ -85,7 +85,7 @@ describe("@Enum", () => { describe("when is a typescript enum (index)", () => { enum SomeEnum { ENUM_1, - ENUM_2, + ENUM_2 } it("should declare prop", () => { @@ -99,10 +99,10 @@ describe("@Enum", () => { properties: { num: { enum: [0, 1], - type: "number", - }, + type: "number" + } }, - type: "object", + type: "object" }); }); }); @@ -111,7 +111,7 @@ describe("@Enum", () => { enum SomeEnum { ENUM_1, ENUM_2 = "test", - ENUM_3 = "test2", + ENUM_3 = "test2" } it("should declare prop", () => { @@ -125,10 +125,10 @@ describe("@Enum", () => { properties: { num: { enum: [0, "test", "test2"], - type: ["number", "string"], - }, + type: ["number", "string"] + } }, - type: "object", + type: "object" }); }); }); diff --git a/packages/schema/src/decorators/common/example.spec.ts b/packages/schema/src/decorators/common/example.spec.ts index 3679194f933..4b675aa5f35 100644 --- a/packages/schema/src/decorators/common/example.spec.ts +++ b/packages/schema/src/decorators/common/example.spec.ts @@ -7,7 +7,7 @@ describe("@Example", () => { it("should declare description on class", () => { // WHEN @Example({ - default: {id: "id"}, + default: {id: "id"} }) class Model {} @@ -15,10 +15,10 @@ describe("@Example", () => { expect(getJsonSchema(Model)).to.deep.equal({ examples: [ { - id: "id", - }, + id: "id" + } ], - type: "object", + type: "object" }); }); it("should declare description on class with description", () => { @@ -29,7 +29,7 @@ describe("@Example", () => { // THEN expect(getJsonSchema(Model)).to.deep.equal({ examples: ["description"], - type: "object", + type: "object" }); }); it("should declare description on property", () => { @@ -45,10 +45,10 @@ describe("@Example", () => { properties: { method: { examples: ["Examples"], - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }); }); it("should throw error when the decorator isn't used with a supported decorator type", () => { diff --git a/packages/schema/src/decorators/common/exclusiveMaximum.spec.ts b/packages/schema/src/decorators/common/exclusiveMaximum.spec.ts index ea7c7539262..a94f7482d0e 100644 --- a/packages/schema/src/decorators/common/exclusiveMaximum.spec.ts +++ b/packages/schema/src/decorators/common/exclusiveMaximum.spec.ts @@ -17,10 +17,10 @@ describe("@ExclusiveMaximum", () => { properties: { num: { exclusiveMaximum: 0, - type: "number", - }, + type: "number" + } }, - type: "object", + type: "object" }); }); }); diff --git a/packages/schema/src/decorators/common/exclusiveMinimum.spec.ts b/packages/schema/src/decorators/common/exclusiveMinimum.spec.ts index b3c70202810..2eb966c2be3 100644 --- a/packages/schema/src/decorators/common/exclusiveMinimum.spec.ts +++ b/packages/schema/src/decorators/common/exclusiveMinimum.spec.ts @@ -17,10 +17,10 @@ describe("@ExclusiveMinimum", () => { properties: { num: { exclusiveMinimum: 0, - type: "number", - }, + type: "number" + } }, - type: "object", + type: "object" }); }); }); diff --git a/packages/schema/src/decorators/common/format.spec.ts b/packages/schema/src/decorators/common/format.spec.ts index c17cb56fc15..9a3e9a7159c 100644 --- a/packages/schema/src/decorators/common/format.spec.ts +++ b/packages/schema/src/decorators/common/format.spec.ts @@ -15,10 +15,10 @@ describe("@Format", () => { properties: { email: { format: "email", - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }); }); }); @@ -36,10 +36,10 @@ describe("@Email", () => { properties: { email: { format: "email", - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }); }); }); @@ -57,10 +57,10 @@ describe("@DateFormat", () => { properties: { prop: { format: "date", - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }); }); }); @@ -78,10 +78,10 @@ describe("@TimeFormat", () => { properties: { prop: { format: "time", - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }); }); }); @@ -99,10 +99,10 @@ describe("@DateTime", () => { properties: { prop: { format: "date-time", - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }); }); }); @@ -120,10 +120,10 @@ describe("@Uri", () => { properties: { prop: { format: "uri", - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }); }); }); diff --git a/packages/schema/src/decorators/common/ignore.spec.ts b/packages/schema/src/decorators/common/ignore.spec.ts index 2306f3454ec..e9808d4d7e3 100644 --- a/packages/schema/src/decorators/common/ignore.spec.ts +++ b/packages/schema/src/decorators/common/ignore.spec.ts @@ -16,10 +16,10 @@ describe("@Ignore", () => { expect(getJsonSchema(Model)).to.deep.equal({ properties: { prop2: { - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }); }); @@ -36,10 +36,10 @@ describe("@Ignore", () => { expect(getJsonSchema(Model)).to.deep.equal({ properties: { prop2: { - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }); }); }); diff --git a/packages/schema/src/decorators/common/integer.spec.ts b/packages/schema/src/decorators/common/integer.spec.ts index dcd48fecb10..d6f74a51cd9 100644 --- a/packages/schema/src/decorators/common/integer.spec.ts +++ b/packages/schema/src/decorators/common/integer.spec.ts @@ -14,10 +14,10 @@ describe("@Integer", () => { properties: { prop: { multipleOf: 1, - type: "integer", - }, + type: "integer" + } }, - type: "object", + type: "object" }); }); }); diff --git a/packages/schema/src/decorators/common/maxLength.spec.ts b/packages/schema/src/decorators/common/maxLength.spec.ts index 5e7ed9536e5..d2c620bfd5f 100644 --- a/packages/schema/src/decorators/common/maxLength.spec.ts +++ b/packages/schema/src/decorators/common/maxLength.spec.ts @@ -17,10 +17,10 @@ describe("@MaxLength", () => { properties: { word: { maxLength: 0, - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }); }); it("should throw error", () => { @@ -52,11 +52,11 @@ describe("@MaxLength", () => { type: "array", items: { maxLength: 0, - type: "string", - }, - }, + type: "string" + } + } }, - type: "object", + type: "object" }); }); }); diff --git a/packages/schema/src/decorators/common/maximum.spec.ts b/packages/schema/src/decorators/common/maximum.spec.ts index 0752a05eb42..552283d6b9a 100644 --- a/packages/schema/src/decorators/common/maximum.spec.ts +++ b/packages/schema/src/decorators/common/maximum.spec.ts @@ -18,10 +18,10 @@ describe("@Maximum", () => { properties: { num: { maximum: 0, - type: "number", - }, + type: "number" + } }, - type: "object", + type: "object" }); }); @@ -39,10 +39,10 @@ describe("@Maximum", () => { properties: { num: { exclusiveMaximum: 0, - type: "number", - }, + type: "number" + } }, - type: "object", + type: "object" }); }); it("should declare maximum value (collection)", () => { @@ -62,11 +62,11 @@ describe("@Maximum", () => { type: "array", items: { maximum: 0, - type: "number", - }, - }, + type: "number" + } + } }, - type: "object", + type: "object" }); }); }); diff --git a/packages/schema/src/decorators/common/minLength.spec.ts b/packages/schema/src/decorators/common/minLength.spec.ts index 0c17970e9c8..bd333b30d5b 100644 --- a/packages/schema/src/decorators/common/minLength.spec.ts +++ b/packages/schema/src/decorators/common/minLength.spec.ts @@ -18,10 +18,10 @@ describe("@MinLength", () => { properties: { word: { minLength: 0, - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }); }); it("should throw error", () => { @@ -53,11 +53,11 @@ describe("@MinLength", () => { type: "array", items: { minLength: 0, - type: "string", - }, - }, + type: "string" + } + } }, - type: "object", + type: "object" }); }); it("should declare minimum value on collection (collection)", () => { @@ -77,13 +77,13 @@ describe("@MinLength", () => { type: "array", items: { minLength: 0, - type: "string", + type: "string" }, maxItems: 10, - minItems: 0, - }, + minItems: 0 + } }, - type: "object", + type: "object" }); }); }); diff --git a/packages/schema/src/decorators/common/minimum.spec.ts b/packages/schema/src/decorators/common/minimum.spec.ts index 9b358a92ad0..e78016fb86f 100644 --- a/packages/schema/src/decorators/common/minimum.spec.ts +++ b/packages/schema/src/decorators/common/minimum.spec.ts @@ -18,10 +18,10 @@ describe("@Minimum", () => { properties: { num: { minimum: 0, - type: "number", - }, + type: "number" + } }, - type: "object", + type: "object" }); }); @@ -39,10 +39,10 @@ describe("@Minimum", () => { properties: { num: { exclusiveMinimum: 0, - type: "number", - }, + type: "number" + } }, - type: "object", + type: "object" }); }); @@ -63,11 +63,11 @@ describe("@Minimum", () => { type: "array", items: { minimum: 0, - type: "number", - }, - }, + type: "number" + } + } }, - type: "object", + type: "object" }); }); }); diff --git a/packages/schema/src/decorators/common/multipleOf.spec.ts b/packages/schema/src/decorators/common/multipleOf.spec.ts index 98ad203e0ea..23877738283 100644 --- a/packages/schema/src/decorators/common/multipleOf.spec.ts +++ b/packages/schema/src/decorators/common/multipleOf.spec.ts @@ -15,10 +15,10 @@ describe("MultipleOf", () => { properties: { num: { multipleOf: 2, - type: "number", - }, + type: "number" + } }, - type: "object", + type: "object" }); }); diff --git a/packages/schema/src/decorators/common/name.spec.ts b/packages/schema/src/decorators/common/name.spec.ts index 629ac5f18bd..07f7a856a67 100644 --- a/packages/schema/src/decorators/common/name.spec.ts +++ b/packages/schema/src/decorators/common/name.spec.ts @@ -16,10 +16,10 @@ describe("@Name", () => { expect(getJsonSchema(Model)).to.deep.equal({ properties: { num2: { - type: "number", - }, + type: "number" + } }, - type: "object", + type: "object" }); }); it("should declare name on class", () => { @@ -37,8 +37,8 @@ describe("@Name", () => { definitions: {}, tags: [ { - name: "AwesomeController", - }, + name: "AwesomeController" + } ], paths: { "/": { @@ -48,13 +48,13 @@ describe("@Name", () => { parameters: [], responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["AwesomeController"], - }, - }, - }, + tags: ["AwesomeController"] + } + } + } }); }); }); diff --git a/packages/schema/src/decorators/common/pattern.spec.ts b/packages/schema/src/decorators/common/pattern.spec.ts index 0d4df2ee513..f2e8aac4c11 100644 --- a/packages/schema/src/decorators/common/pattern.spec.ts +++ b/packages/schema/src/decorators/common/pattern.spec.ts @@ -17,10 +17,10 @@ describe("@Pattern", () => { properties: { num: { pattern: "(a|b)", - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }); }); }); diff --git a/packages/schema/src/decorators/common/required.spec.ts b/packages/schema/src/decorators/common/required.spec.ts index b3ebabb71b7..68d0cc8ef8a 100644 --- a/packages/schema/src/decorators/common/required.spec.ts +++ b/packages/schema/src/decorators/common/required.spec.ts @@ -16,11 +16,11 @@ describe("@Required", () => { expect(classSchema.schema.toJSON()).to.deep.equal({ properties: { num: { - type: "number", - }, + type: "number" + } }, required: ["num"], - type: "object", + type: "object" }); }); it("should declare required field (false)", () => { @@ -36,10 +36,10 @@ describe("@Required", () => { expect(classSchema.schema.toJSON()).to.deep.equal({ properties: { num: { - type: "number", - }, + type: "number" + } }, - type: "object", + type: "object" }); }); it("should throw error when the decorator isn't used with a supported decorator type", () => { diff --git a/packages/schema/src/decorators/common/schema.spec.ts b/packages/schema/src/decorators/common/schema.spec.ts index e0d81c626ad..5e1686e92e3 100644 --- a/packages/schema/src/decorators/common/schema.spec.ts +++ b/packages/schema/src/decorators/common/schema.spec.ts @@ -6,7 +6,7 @@ describe("Schema()", () => { it("should store data", () => { class Test { @Schema({ - pattern: "a|b", + pattern: "a|b" }) test: string; } @@ -15,10 +15,10 @@ describe("Schema()", () => { properties: { test: { pattern: "a|b", - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }); }); }); diff --git a/packages/schema/src/decorators/common/title.spec.ts b/packages/schema/src/decorators/common/title.spec.ts index d7216c03db5..4f0fd0e48a4 100644 --- a/packages/schema/src/decorators/common/title.spec.ts +++ b/packages/schema/src/decorators/common/title.spec.ts @@ -12,10 +12,10 @@ describe("Title()", () => { properties: { test: { title: "Title", - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }); }); }); diff --git a/packages/schema/src/decorators/generics/genericOf.spec.ts b/packages/schema/src/decorators/generics/genericOf.spec.ts index afd70322760..f55871cdc15 100644 --- a/packages/schema/src/decorators/generics/genericOf.spec.ts +++ b/packages/schema/src/decorators/generics/genericOf.spec.ts @@ -29,29 +29,29 @@ describe("@GenericOf", () => { Product: { properties: { label: { - type: "string", - }, + type: "string" + } }, - type: "object", - }, + type: "object" + } }, properties: { submissions: { properties: { data: { items: { - $ref: "#/definitions/Product", + $ref: "#/definitions/Product" }, - type: "array", + type: "array" }, totalCount: { - type: "number", - }, + type: "number" + } }, - type: "object", - }, + type: "object" + } }, - type: "object", + type: "object" }); }); it("should generate Generic pagination with nested model", () => { @@ -79,26 +79,26 @@ describe("@GenericOf", () => { Product: { properties: { label: { - type: "string", - }, + type: "string" + } }, - type: "object", - }, + type: "object" + } }, properties: { submission: { properties: { _id: { - type: "string", + type: "string" }, data: { - $ref: "#/definitions/Product", - }, + $ref: "#/definitions/Product" + } }, - type: "object", - }, + type: "object" + } }, - type: "object", + type: "object" }); }); it("should generate Generic pagination with nested model (deep generics)", () => { @@ -135,11 +135,11 @@ describe("@GenericOf", () => { Product: { properties: { label: { - type: "string", - }, + type: "string" + } }, - type: "object", - }, + type: "object" + } }, properties: { submissions: { @@ -148,24 +148,24 @@ describe("@GenericOf", () => { items: { properties: { _id: { - type: "string", + type: "string" }, data: { - $ref: "#/definitions/Product", - }, + $ref: "#/definitions/Product" + } }, - type: "object", + type: "object" }, - type: "array", + type: "array" }, totalCount: { - type: "number", - }, + type: "number" + } }, - type: "object", - }, + type: "object" + } }, - type: "object", + type: "object" }); }); }); diff --git a/packages/schema/src/decorators/operations/consumes.spec.ts b/packages/schema/src/decorators/operations/consumes.spec.ts index 2ab8369c62c..d97c1b5024c 100644 --- a/packages/schema/src/decorators/operations/consumes.spec.ts +++ b/packages/schema/src/decorators/operations/consumes.spec.ts @@ -13,8 +13,8 @@ describe("Consumes", () => { definitions: {}, tags: [ { - name: "MyController", - }, + name: "MyController" + } ], paths: { "/": { @@ -24,13 +24,13 @@ describe("Consumes", () => { consumes: ["text/json"], responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["MyController"], - }, - }, - }, + tags: ["MyController"] + } + } + } }); }); it("should store metadata (openspec)", () => { @@ -42,12 +42,12 @@ describe("Consumes", () => { expect(getSpec(MyController, {spec: SpecTypes.OPENAPI})).to.deep.eq({ components: { - schemas: {}, + schemas: {} }, tags: [ { - name: "MyController", - }, + name: "MyController" + } ], paths: { "/": { @@ -56,13 +56,13 @@ describe("Consumes", () => { parameters: [], responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["MyController"], - }, - }, - }, + tags: ["MyController"] + } + } + } }); }); it("should store metadata (class)", () => { @@ -79,8 +79,8 @@ describe("Consumes", () => { definitions: {}, tags: [ { - name: "MyController", - }, + name: "MyController" + } ], paths: { "/": { @@ -90,10 +90,10 @@ describe("Consumes", () => { consumes: ["text/json"], responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["MyController"], + tags: ["MyController"] }, post: { operationId: "myControllerPost", @@ -101,13 +101,13 @@ describe("Consumes", () => { consumes: ["text/json"], responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["MyController"], - }, - }, - }, + tags: ["MyController"] + } + } + } }); }); it("should throw error for unsupported usage", () => { diff --git a/packages/schema/src/decorators/operations/deprecated.spec.ts b/packages/schema/src/decorators/operations/deprecated.spec.ts index 3dc262dbfe3..548bb1c93a3 100644 --- a/packages/schema/src/decorators/operations/deprecated.spec.ts +++ b/packages/schema/src/decorators/operations/deprecated.spec.ts @@ -13,8 +13,8 @@ describe("Deprecated", () => { definitions: {}, tags: [ { - name: "MyController", - }, + name: "MyController" + } ], paths: { "/": { @@ -24,13 +24,13 @@ describe("Deprecated", () => { deprecated: true, responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["MyController"], - }, - }, - }, + tags: ["MyController"] + } + } + } }); }); it("should store metadata (openspec)", () => { @@ -42,12 +42,12 @@ describe("Deprecated", () => { expect(getSpec(MyController, {spec: SpecTypes.OPENAPI})).to.deep.eq({ components: { - schemas: {}, + schemas: {} }, tags: [ { - name: "MyController", - }, + name: "MyController" + } ], paths: { "/": { @@ -57,13 +57,13 @@ describe("Deprecated", () => { parameters: [], responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["MyController"], - }, - }, - }, + tags: ["MyController"] + } + } + } }); }); it("should store metadata (class)", () => { @@ -80,8 +80,8 @@ describe("Deprecated", () => { definitions: {}, tags: [ { - name: "MyController", - }, + name: "MyController" + } ], paths: { "/": { @@ -91,10 +91,10 @@ describe("Deprecated", () => { deprecated: true, responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["MyController"], + tags: ["MyController"] }, post: { operationId: "myControllerPost", @@ -102,13 +102,13 @@ describe("Deprecated", () => { deprecated: true, responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["MyController"], - }, - }, - }, + tags: ["MyController"] + } + } + } }); }); it("should throw error for unsupported usage", () => { diff --git a/packages/schema/src/decorators/operations/in.spec.ts b/packages/schema/src/decorators/operations/in.spec.ts index 9c6f77524be..1bd94852b0d 100644 --- a/packages/schema/src/decorators/operations/in.spec.ts +++ b/packages/schema/src/decorators/operations/in.spec.ts @@ -10,7 +10,7 @@ describe("In", () => { // THEN getSpec(Controller, { - spec: SpecTypes.SWAGGER, + spec: SpecTypes.SWAGGER }); const paramSchema = JsonEntityStore.from(Controller, "method", 0); @@ -23,14 +23,14 @@ describe("In", () => { in: "path", name: "basic", required: true, - type: "string", - }, + type: "string" + } ], responses: { "200": { - description: "Success", - }, - }, + description: "Success" + } + } }); }); it("should declare all schema correctly (method)", async () => { @@ -42,7 +42,7 @@ describe("In", () => { // THEN getSpec(Controller, { - spec: SpecTypes.SWAGGER, + spec: SpecTypes.SWAGGER }); const paramSchema = JsonEntityStore.from(Controller, "method", 0); @@ -55,21 +55,21 @@ describe("In", () => { in: "path", name: "basic", required: true, - type: "string", + type: "string" }, { in: "header", name: "Authorization", required: true, type: "string", - description: "description", - }, + description: "description" + } ], responses: { "200": { - description: "Success", - }, - }, + description: "Success" + } + } }); }); it("should throw error for unsupported usage", () => { diff --git a/packages/schema/src/decorators/operations/operationId.spec.ts b/packages/schema/src/decorators/operations/operationId.spec.ts index 5c5db4ac7fb..4ee7552f729 100644 --- a/packages/schema/src/decorators/operations/operationId.spec.ts +++ b/packages/schema/src/decorators/operations/operationId.spec.ts @@ -13,8 +13,8 @@ describe("OperationId", () => { definitions: {}, tags: [ { - name: "MyController", - }, + name: "MyController" + } ], paths: { "/": { @@ -23,13 +23,13 @@ describe("OperationId", () => { parameters: [], responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["MyController"], - }, - }, - }, + tags: ["MyController"] + } + } + } }); }); it("should throw error for unsupported usage", () => { diff --git a/packages/schema/src/decorators/operations/operationPath.spec.ts b/packages/schema/src/decorators/operations/operationPath.spec.ts index 839a01b6e07..bb4b536ff06 100644 --- a/packages/schema/src/decorators/operations/operationPath.spec.ts +++ b/packages/schema/src/decorators/operations/operationPath.spec.ts @@ -12,8 +12,8 @@ describe("OperationPath", () => { definitions: {}, tags: [ { - name: "MyController", - }, + name: "MyController" + } ], paths: { "/": { @@ -22,13 +22,13 @@ describe("OperationPath", () => { parameters: [], responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["MyController"], - }, - }, - }, + tags: ["MyController"] + } + } + } }); }); it("should throw error for unsupported usage", () => { diff --git a/packages/schema/src/decorators/operations/operationPath.ts b/packages/schema/src/decorators/operations/operationPath.ts index 936e4a3b3f2..0fbac0d9a58 100644 --- a/packages/schema/src/decorators/operations/operationPath.ts +++ b/packages/schema/src/decorators/operations/operationPath.ts @@ -10,7 +10,7 @@ export enum OperationMethods { HEAD = "HEAD", DELETE = "DELETE", OPTIONS = "OPTIONS", - CUSTOM = "CUSTOM", + CUSTOM = "CUSTOM" } /** diff --git a/packages/schema/src/decorators/operations/path.spec.ts b/packages/schema/src/decorators/operations/path.spec.ts index 0bf58158806..f55b68c1302 100644 --- a/packages/schema/src/decorators/operations/path.spec.ts +++ b/packages/schema/src/decorators/operations/path.spec.ts @@ -13,8 +13,8 @@ describe("Path", () => { definitions: {}, tags: [ { - name: "MyController", - }, + name: "MyController" + } ], paths: { "/path": { @@ -23,13 +23,13 @@ describe("Path", () => { parameters: [], responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["MyController"], - }, - }, - }, + tags: ["MyController"] + } + } + } }); }); it("should throw error for unsupported usage", () => { diff --git a/packages/schema/src/decorators/operations/produces.spec.ts b/packages/schema/src/decorators/operations/produces.spec.ts index c15f098954e..51340856d81 100644 --- a/packages/schema/src/decorators/operations/produces.spec.ts +++ b/packages/schema/src/decorators/operations/produces.spec.ts @@ -13,8 +13,8 @@ describe("Produces", () => { definitions: {}, tags: [ { - name: "MyController", - }, + name: "MyController" + } ], paths: { "/": { @@ -24,13 +24,13 @@ describe("Produces", () => { produces: ["text/json"], responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["MyController"], - }, - }, - }, + tags: ["MyController"] + } + } + } }); }); it("should store metadata (openspec)", () => { @@ -42,12 +42,12 @@ describe("Produces", () => { expect(getSpec(MyController, {spec: SpecTypes.OPENAPI})).to.deep.eq({ components: { - schemas: {}, + schemas: {} }, tags: [ { - name: "MyController", - }, + name: "MyController" + } ], paths: { "/": { @@ -56,13 +56,13 @@ describe("Produces", () => { parameters: [], responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["MyController"], - }, - }, - }, + tags: ["MyController"] + } + } + } }); }); it("should store metadata (class)", () => { @@ -79,8 +79,8 @@ describe("Produces", () => { definitions: {}, tags: [ { - name: "MyController", - }, + name: "MyController" + } ], paths: { "/": { @@ -90,10 +90,10 @@ describe("Produces", () => { produces: ["text/json"], responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["MyController"], + tags: ["MyController"] }, post: { operationId: "myControllerPost", @@ -101,13 +101,13 @@ describe("Produces", () => { produces: ["text/json"], responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["MyController"], - }, - }, - }, + tags: ["MyController"] + } + } + } }); }); it("should throw error for unsupported usage", () => { diff --git a/packages/schema/src/decorators/operations/returns.spec.ts b/packages/schema/src/decorators/operations/returns.spec.ts index 5fbb9b42cd3..cbe743feff6 100644 --- a/packages/schema/src/decorators/operations/returns.spec.ts +++ b/packages/schema/src/decorators/operations/returns.spec.ts @@ -18,8 +18,8 @@ describe("@Returns", () => { definitions: {}, tags: [ { - name: "Controller", - }, + name: "Controller" + } ], paths: { "/": { @@ -30,14 +30,14 @@ describe("@Returns", () => { "200": { description: "description", schema: { - type: "string", - }, - }, + type: "string" + } + } }, - tags: ["Controller"], - }, - }, - }, + tags: ["Controller"] + } + } + } }); }); it("should declare a return type (Status().Type())", async () => { @@ -55,8 +55,8 @@ describe("@Returns", () => { definitions: {}, tags: [ { - name: "Controller", - }, + name: "Controller" + } ], paths: { "/": { @@ -67,14 +67,14 @@ describe("@Returns", () => { "200": { description: "description", schema: { - type: "string", - }, - }, + type: "string" + } + } }, - tags: ["Controller"], - }, - }, - }, + tags: ["Controller"] + } + } + } }); }); it("should declare a return type with headers", async () => { @@ -85,11 +85,11 @@ describe("@Returns", () => { .Description("description") .Header("x-token", "token") .Header("x-header", { - value: "", + value: "" }) .Examples({test: "Examples"}) .Schema({ - minLength: 3, + minLength: 3 })) method() {} } @@ -101,8 +101,8 @@ describe("@Returns", () => { definitions: {}, tags: [ { - name: "Controller", - }, + name: "Controller" + } ], paths: { "/": { @@ -115,24 +115,24 @@ describe("@Returns", () => { headers: { "x-header": { example: "", - type: "string", + type: "string" }, "x-token": { example: "token", - type: "string", - }, + type: "string" + } }, examples: {test: "Examples"}, schema: { type: "string", - minLength: 3, - }, - }, + minLength: 3 + } + } }, - tags: ["Controller"], - }, - }, - }, + tags: ["Controller"] + } + } + } }); }); it("should declare a return type with content-type", async () => { @@ -148,12 +148,12 @@ describe("@Returns", () => { expect(spec).to.deep.equal({ components: { - schemas: {}, + schemas: {} }, tags: [ { - name: "Controller", - }, + name: "Controller" + } ], paths: { "/": { @@ -165,18 +165,18 @@ describe("@Returns", () => { content: { "text/json": { schema: { - type: "string", - }, - }, + type: "string" + } + } }, description: "description", - examples: ["Examples"], - }, + examples: ["Examples"] + } }, - tags: ["Controller"], - }, - }, - }, + tags: ["Controller"] + } + } + } }); }); it("should declare error response", async () => { @@ -196,8 +196,8 @@ describe("@Returns", () => { definitions: {}, tags: [ { - name: "Controller", - }, + name: "Controller" + } ], paths: { "/": { @@ -209,26 +209,26 @@ describe("@Returns", () => { "200": { description: "Success", schema: { - type: "object", - }, + type: "object" + } }, "401": { description: "Unauthorized", schema: { - type: "string", - }, + type: "string" + } }, "400": { description: "Bad request", schema: { - type: "string", - }, - }, + type: "string" + } + } }, - tags: ["Controller"], - }, - }, - }, + tags: ["Controller"] + } + } + } }); }); it("should throw an error when using of with String", async () => { @@ -290,8 +290,8 @@ describe("@Returns", () => { definitions: {}, tags: [ { - name: "Controller", - }, + name: "Controller" + } ], paths: { "/": { @@ -304,16 +304,16 @@ describe("@Returns", () => { description: "description", schema: { items: { - type: "string", + type: "string" }, - type: "array", - }, - }, + type: "array" + } + } }, - tags: ["Controller"], - }, - }, - }, + tags: ["Controller"] + } + } + } }); }); it("should declare an Array of Model", async () => { @@ -337,16 +337,16 @@ describe("@Returns", () => { Model: { properties: { id: { - type: "string", - }, + type: "string" + } }, - type: "object", - }, + type: "object" + } }, tags: [ { - name: "Controller", - }, + name: "Controller" + } ], paths: { "/": { @@ -359,16 +359,16 @@ describe("@Returns", () => { description: "description", schema: { items: { - $ref: "#/definitions/Model", + $ref: "#/definitions/Model" }, - type: "array", - }, - }, + type: "array" + } + } }, - tags: ["Controller"], - }, - }, - }, + tags: ["Controller"] + } + } + } }); }); it("should declare an Generic of Model", async () => { @@ -412,16 +412,16 @@ describe("@Returns", () => { Product: { properties: { title: { - type: "string", - }, + type: "string" + } }, - type: "object", - }, + type: "object" + } }, tags: [ { - name: "Controller", - }, + name: "Controller" + } ], paths: { "/": { @@ -439,27 +439,27 @@ describe("@Returns", () => { type: "object", properties: { _id: { - type: "string", + type: "string" }, data: { - $ref: "#/definitions/Product", - }, - }, + $ref: "#/definitions/Product" + } + } }, - type: "array", + type: "array" }, totalCount: { - type: "number", - }, + type: "number" + } }, - type: "object", - }, - }, + type: "object" + } + } }, - tags: ["Controller"], - }, - }, - }, + tags: ["Controller"] + } + } + } }); }); }); diff --git a/packages/schema/src/decorators/operations/returns.ts b/packages/schema/src/decorators/operations/returns.ts index 27e49c9806c..b35a2ad30a8 100644 --- a/packages/schema/src/decorators/operations/returns.ts +++ b/packages/schema/src/decorators/operations/returns.ts @@ -6,7 +6,7 @@ import { isPrimitiveOrPrimitiveClass, isString, Type, - UnsupportedDecoratorType, + UnsupportedDecoratorType } from "@tsed/core"; import {HTTP_STATUS_MESSAGES} from "../../constants/httpStatusMessages"; import {JsonEntityStore} from "../../domain/JsonEntityStore"; @@ -311,7 +311,7 @@ export function Returns(status?: string | number, model?: Type | any): Retu decorator.Headers = (headers: JsonHeaders) => { response.headers({ ...(response.get("headers") || {}), - ...mapHeaders(headers), + ...mapHeaders(headers) }); return decorator; @@ -319,7 +319,7 @@ export function Returns(status?: string | number, model?: Type | any): Retu decorator.Header = (key: string, value: string | JsonHeader) => { decorator.Headers({ - [key]: value, + [key]: value }); return decorator; diff --git a/packages/schema/src/decorators/operations/security.spec.ts b/packages/schema/src/decorators/operations/security.spec.ts index 02c2e5ecd70..dcfafd0cab0 100644 --- a/packages/schema/src/decorators/operations/security.spec.ts +++ b/packages/schema/src/decorators/operations/security.spec.ts @@ -14,8 +14,8 @@ describe("Security", () => { definitions: {}, tags: [ { - name: "MyController", - }, + name: "MyController" + } ], paths: { "/": { @@ -24,16 +24,16 @@ describe("Security", () => { parameters: [], responses: { "200": { - description: "Success", - }, + description: "Success" + } }, security: { - oauth: ["user"], + oauth: ["user"] }, - tags: ["MyController"], - }, - }, - }, + tags: ["MyController"] + } + } + } }); }); it("should store metadata (class)", () => { @@ -51,8 +51,8 @@ describe("Security", () => { definitions: {}, tags: [ { - name: "MyController", - }, + name: "MyController" + } ], paths: { "/": { @@ -61,29 +61,29 @@ describe("Security", () => { parameters: [], responses: { "200": { - description: "Success", - }, + description: "Success" + } }, security: { - oauth: ["user"], + oauth: ["user"] }, - tags: ["MyController"], + tags: ["MyController"] }, post: { operationId: "myControllerPost", parameters: [], responses: { "200": { - description: "Success", - }, + description: "Success" + } }, security: { - oauth: ["admin", "user"], + oauth: ["admin", "user"] }, - tags: ["MyController"], - }, - }, - }, + tags: ["MyController"] + } + } + } }); }); it("should throw error for unsupported usage", () => { diff --git a/packages/schema/src/decorators/operations/summary.spec.ts b/packages/schema/src/decorators/operations/summary.spec.ts index d2dd74fa7d2..67d5e781e77 100644 --- a/packages/schema/src/decorators/operations/summary.spec.ts +++ b/packages/schema/src/decorators/operations/summary.spec.ts @@ -14,8 +14,8 @@ describe("Summary", () => { definitions: {}, tags: [ { - name: "MyController", - }, + name: "MyController" + } ], paths: { "/": { @@ -24,14 +24,14 @@ describe("Summary", () => { parameters: [], responses: { "200": { - description: "Success", - }, + description: "Success" + } }, summary: "summary", - tags: ["MyController"], - }, - }, - }, + tags: ["MyController"] + } + } + } }); }); it("should throw error for unsupported usage", () => { diff --git a/packages/schema/src/decorators/operations/tags.spec.ts b/packages/schema/src/decorators/operations/tags.spec.ts index 8897e5a9f0f..19b2abc033c 100644 --- a/packages/schema/src/decorators/operations/tags.spec.ts +++ b/packages/schema/src/decorators/operations/tags.spec.ts @@ -20,13 +20,13 @@ describe("Tags", () => { parameters: [], responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["api"], - }, - }, - }, + tags: ["api"] + } + } + } }); }); it("should store metadata (method - map)", () => { @@ -41,8 +41,8 @@ describe("Tags", () => { tags: [ { name: "api", - description: "description", - }, + description: "description" + } ], paths: { "/": { @@ -51,13 +51,13 @@ describe("Tags", () => { parameters: [], responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["api"], - }, - }, - }, + tags: ["api"] + } + } + } }); }); it("should store metadata (class)", () => { @@ -81,23 +81,23 @@ describe("Tags", () => { parameters: [], responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["api"], + tags: ["api"] }, post: { operationId: "myControllerPost", parameters: [], responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["allow", "api"], - }, - }, - }, + tags: ["allow", "api"] + } + } + } }); }); it("should throw error for unsupported usage", () => { diff --git a/packages/schema/src/decorators/operations/tags.ts b/packages/schema/src/decorators/operations/tags.ts index 7aa968218f7..3a59f7739f8 100644 --- a/packages/schema/src/decorators/operations/tags.ts +++ b/packages/schema/src/decorators/operations/tags.ts @@ -6,7 +6,7 @@ function mapTags(tags: (string | JsonTag)[]) { return tags.map((tag) => { if (typeof tag === "string") { return { - name: tag, + name: tag }; } diff --git a/packages/schema/src/domain/JsonEntityStore.ts b/packages/schema/src/domain/JsonEntityStore.ts index a0fb0574933..0c9adedc5ce 100644 --- a/packages/schema/src/domain/JsonEntityStore.ts +++ b/packages/schema/src/domain/JsonEntityStore.ts @@ -8,7 +8,7 @@ import { isCollection, isPromise, Store, - Type, + Type } from "@tsed/core"; import {JsonOperation} from "./JsonOperation"; import {JsonParameter} from "./JsonParameter"; @@ -21,7 +21,7 @@ export interface JsonEntityStoreOptions extends EntityOptions { const getSchema = (type: any) => { if (isCollection(type) || !isClass(type)) { return JsonSchema.from({ - type, + type }); } @@ -170,7 +170,7 @@ export class JsonEntityStore extends Entity implements JsonEntityStoreOptions { target: args[0], propertyKey: args[1], index: typeof args[2] === "number" ? args[2] : undefined, - descriptor: typeof args[2] === "object" ? args[2] : undefined, + descriptor: typeof args[2] === "object" ? args[2] : undefined }); store.set(JsonEntityStore, jsonSchemaStore); @@ -219,7 +219,7 @@ export class JsonEntityStore extends Entity implements JsonEntityStoreOptions { case DecoratorTypes.CLASS: this._schema = JsonSchema.from({ - type: this.type, + type: this.type }); break; case DecoratorTypes.METHOD: @@ -244,7 +244,7 @@ export class JsonEntityStore extends Entity implements JsonEntityStoreOptions { parentStore.children.set(this.propertyName, this); schema = JsonSchema.from({ - type: this.collectionType || this.type, + type: this.collectionType || this.type }); if (this.collectionType) { @@ -275,7 +275,7 @@ export class JsonEntityStore extends Entity implements JsonEntityStoreOptions { } this._schema = JsonSchema.from({ - type: this.collectionType || this.type, + type: this.collectionType || this.type }); if (this.collectionType) { diff --git a/packages/schema/src/domain/JsonFormatTypes.ts b/packages/schema/src/domain/JsonFormatTypes.ts index 5af9665e12f..45aead512c6 100644 --- a/packages/schema/src/domain/JsonFormatTypes.ts +++ b/packages/schema/src/domain/JsonFormatTypes.ts @@ -13,5 +13,5 @@ export enum JsonFormatTypes { JSON_POINTER = "json-pointer", RELATIVE_JSON_POINTER = "relative-json-pointer", UUID = "uuid", - REGEX = "regex", + REGEX = "regex" } diff --git a/packages/schema/src/domain/JsonMap.spec.ts b/packages/schema/src/domain/JsonMap.spec.ts index 9dccb3f688a..53a0394d975 100644 --- a/packages/schema/src/domain/JsonMap.spec.ts +++ b/packages/schema/src/domain/JsonMap.spec.ts @@ -4,11 +4,11 @@ import {expect} from "chai"; describe("JsonMap", () => { it("should serialize a JsonMap", () => { const map = new JsonMap({ - id: "id", + id: "id" }); expect(map.toJSON()).to.deep.eq({ - id: "id", + id: "id" }); }); }); diff --git a/packages/schema/src/domain/JsonOperation.spec.ts b/packages/schema/src/domain/JsonOperation.spec.ts index 5f9abc379c2..32f47c41644 100644 --- a/packages/schema/src/domain/JsonOperation.spec.ts +++ b/packages/schema/src/domain/JsonOperation.spec.ts @@ -20,19 +20,19 @@ describe("JsonOperation", () => { description: "Success", headers: { "x-token2": {example: "token2", type: "string"}, - "x-token": {example: "token", type: "string"}, + "x-token": {example: "token", type: "string"} }, - schema: {type: "object"}, + schema: {type: "object"} }); expect(entity.operation?.getHeadersOf(200)).to.deep.equal({ "x-token": { example: "token", - type: "string", + type: "string" }, "x-token2": { example: "token2", - type: "string", - }, + type: "string" + } }); }); }); @@ -54,23 +54,23 @@ describe("JsonOperation", () => { in: "body", name: "body", required: false, - type: "string", - }, + type: "string" + } ], responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["MyController"], - }, - }, + tags: ["MyController"] + } + } }, tags: [ { - name: "MyController", - }, - ], + name: "MyController" + } + ] }); }); }); diff --git a/packages/schema/src/domain/JsonOperation.ts b/packages/schema/src/domain/JsonOperation.ts index 379ca9c1006..c799570a1ad 100644 --- a/packages/schema/src/domain/JsonOperation.ts +++ b/packages/schema/src/domain/JsonOperation.ts @@ -184,7 +184,7 @@ export class JsonOperation extends JsonMap { this.operationPaths.set(String(method) + String(path), { ...options, method, - path, + path }); return this; @@ -212,8 +212,8 @@ export class JsonOperation extends JsonMap { if (this.get("responses").size === 0) { operation.responses = { "200": { - description: HTTP_STATUS_MESSAGES[200], - }, + description: HTTP_STATUS_MESSAGES[200] + } }; } @@ -251,7 +251,7 @@ function toJsonParameter(parameter: any) { return new JsonParameter({ in: JsonParameterTypes.BODY, name: JsonParameterTypes.BODY, - ...parameter, + ...parameter }); } diff --git a/packages/schema/src/domain/JsonParameter.ts b/packages/schema/src/domain/JsonParameter.ts index a9b68a57c54..ce447c48f48 100644 --- a/packages/schema/src/domain/JsonParameter.ts +++ b/packages/schema/src/domain/JsonParameter.ts @@ -59,7 +59,7 @@ export class JsonParameter extends JsonMap implements Nest const {type, schema, ...parameter} = super.toJSON(options); const jsonSchema = serializeItem(this.$schema, { ...options, - ...popGenerics(this), + ...popGenerics(this) }); parameter.required = parameter.required || this.get("in") === "path"; @@ -77,14 +77,14 @@ export class JsonParameter extends JsonMap implements Nest type: "array", collectionFormat: "multi", items: { - type: "string", - }, + type: "string" + } }; } return { ...parameter, - ...jsonSchema, + ...jsonSchema }; } else { parameter.schema = jsonSchema; @@ -107,8 +107,8 @@ export class JsonParameter extends JsonMap implements Nest ...parameter, name: key, required: (schema.required || []).includes(key), - ...prop, - }, + ...prop + } ]; }, []); } diff --git a/packages/schema/src/domain/JsonParameterTypes.ts b/packages/schema/src/domain/JsonParameterTypes.ts index e3a8a5f5ba1..00a278284fb 100644 --- a/packages/schema/src/domain/JsonParameterTypes.ts +++ b/packages/schema/src/domain/JsonParameterTypes.ts @@ -3,7 +3,7 @@ export enum JsonParameterTypes { PATH = "path", QUERY = "query", HEADER = "header", - COOKIES = "cookies", + COOKIES = "cookies" } export function isParameterType(type: string) { diff --git a/packages/schema/src/domain/JsonSchema.spec.ts b/packages/schema/src/domain/JsonSchema.spec.ts index a7c2f137858..a3735a62d97 100644 --- a/packages/schema/src/domain/JsonSchema.spec.ts +++ b/packages/schema/src/domain/JsonSchema.spec.ts @@ -23,7 +23,7 @@ describe("JsonSchema", () => { const validate = new Ajv().compile(schema); expect(schema).to.deep.equal({ - type: "string", + type: "string" }); expect(validate("This is a string")).to.equal(true); @@ -44,7 +44,7 @@ describe("JsonSchema", () => { expect(schema).to.deep.equal({ type: "string", minLength: 2, - maxLength: 3, + maxLength: 3 }); expect(validate("A")).to.equal(false); @@ -63,7 +63,7 @@ describe("JsonSchema", () => { expect(schema).to.deep.equal({ type: "string", - pattern: "^(\\([0-9]{3}\\))?[0-9]{3}-[0-9]{4}$", + pattern: "^(\\([0-9]{3}\\))?[0-9]{3}-[0-9]{4}$" }); expect(validate("555-1212")).to.equal(true); @@ -79,7 +79,7 @@ describe("JsonSchema", () => { const result = JsonSchema.from({type: Date}).toObject(); expect(result).to.deep.equal({ - type: "string", + type: "string" }); }); @@ -88,7 +88,7 @@ describe("JsonSchema", () => { expect(result).to.deep.equal({ type: "string", - format: "date-time", + format: "date-time" }); }); }); @@ -101,7 +101,7 @@ describe("JsonSchema", () => { const validate = new Ajv().compile(schema); expect(schema).to.deep.equal({ - type: "number", + type: "number" }); expect(validate(42)).to.equal(true); expect(validate(-1)).to.equal(true); @@ -119,7 +119,7 @@ describe("JsonSchema", () => { expect(schema).to.deep.equal({ type: "integer", - multipleOf: 1.0, + multipleOf: 1.0 }); expect(validate(42)).to.equal(true); expect(validate(42.0)).to.equal(true); @@ -135,7 +135,7 @@ describe("JsonSchema", () => { expect(schema).to.deep.equal({ type: "number", - multipleOf: 10, + multipleOf: 10 }); expect(validate(0)).to.equal(true); expect(validate(10)).to.equal(true); @@ -153,7 +153,7 @@ describe("JsonSchema", () => { expect(schema).to.deep.equal({ type: "number", minimum: 0, - exclusiveMaximum: 100, + exclusiveMaximum: 100 }); expect(validate(0)).to.equal(true); expect(validate(10)).to.equal(true); @@ -168,7 +168,7 @@ describe("JsonSchema", () => { expect(schema).to.deep.equal({ type: "number", exclusiveMinimum: 0, - maximum: 100, + maximum: 100 }); expect(validate(-1)).to.equal(false); expect(validate(0)).to.equal(false); @@ -188,13 +188,13 @@ describe("JsonSchema", () => { const validate = new Ajv().compile(schema); expect(schema).to.deep.equal({ - type: "object", + type: "object" }); expect( validate({ key: "value", - another_key: "another_value", + another_key: "another_value" }) ).to.equal(true); expect( @@ -209,14 +209,14 @@ describe("JsonSchema", () => { Mars: 6.4185e23, Mercury: 3.3022e23, Moon: 7.349e22, - Pluto: 1.25e22, + Pluto: 1.25e22 }) ).to.equal(true); expect( validate({ 0.01: "cm", 1: "m", - 1000: "km", + 1000: "km" }) ).to.equal(true); expect(validate("Not an object")).to.equal(false); @@ -233,9 +233,9 @@ describe("JsonSchema", () => { street_name: {type: "string"}, street_type: { type: "string", - enum: ["Street", "Avenue", "Boulevard"], - }, - }, + enum: ["Street", "Avenue", "Boulevard"] + } + } }).toObject(); const validate = new Ajv().compile(schema); @@ -248,7 +248,7 @@ describe("JsonSchema", () => { number: 1600, street_name: "Pennsylvania", street_type: "Avenue", - direction: "NW", + direction: "NW" }) ).to.equal(true); }); @@ -260,10 +260,10 @@ describe("JsonSchema", () => { street_name: {type: "string"}, street_type: { type: "string", - enum: ["Street", "Avenue", "Boulevard"], - }, + enum: ["Street", "Avenue", "Boulevard"] + } }, - additionalProperties: false, // Unauthorized unknown properties + additionalProperties: false // Unauthorized unknown properties }).toObject(); expect(schema).to.deep.eq({ @@ -273,10 +273,10 @@ describe("JsonSchema", () => { street_name: {type: "string"}, street_type: { type: "string", - enum: ["Street", "Avenue", "Boulevard"], - }, + enum: ["Street", "Avenue", "Boulevard"] + } }, - additionalProperties: false, // Unauthorized unknown properties + additionalProperties: false // Unauthorized unknown properties }); const validate = new Ajv().compile(schema); @@ -287,7 +287,7 @@ describe("JsonSchema", () => { number: 1600, street_name: "Pennsylvania", street_type: "Avenue", - direction: "NW", + direction: "NW" }) ).to.equal(false); }); @@ -299,10 +299,10 @@ describe("JsonSchema", () => { street_name: {type: "string"}, street_type: { type: "string", - enum: ["Street", "Avenue", "Boulevard"], - }, + enum: ["Street", "Avenue", "Boulevard"] + } }, - additionalProperties: JsonSchema.from({type: "string"}), + additionalProperties: JsonSchema.from({type: "string"}) }).toObject(); const validate = new Ajv().compile(schema); @@ -313,7 +313,7 @@ describe("JsonSchema", () => { number: 1600, street_name: "Pennsylvania", street_type: "Avenue", - direction: "NW", + direction: "NW" }) ).to.equal(true); expect( @@ -321,7 +321,7 @@ describe("JsonSchema", () => { number: 1600, street_name: "Pennsylvania", street_type: "Avenue", - office_number: 201, + office_number: 201 }) ).to.equal(false); }); @@ -335,9 +335,9 @@ describe("JsonSchema", () => { name: {type: "string"}, email: {type: "string"}, address: {type: "string"}, - telephone: {type: "string"}, + telephone: {type: "string"} }, - required: ["name", "email", "email"], + required: ["name", "email", "email"] }); const schema = jsonSchema.toObject(); @@ -348,16 +348,16 @@ describe("JsonSchema", () => { name: {type: "string"}, email: {type: "string"}, address: {type: "string"}, - telephone: {type: "string"}, + telephone: {type: "string"} }, - required: ["name", "email"], + required: ["name", "email"] }); const validate = new Ajv().compile(schema); expect( validate({ name: "William Shakespeare", - email: "bill@stratford-upon-avon.co.uk", + email: "bill@stratford-upon-avon.co.uk" }) ).to.equal(true); expect( @@ -365,13 +365,13 @@ describe("JsonSchema", () => { name: "William Shakespeare", email: "bill@stratford-upon-avon.co.uk", address: "Henley Street, Stratford-upon-Avon, Warwickshire, England", - authorship: "in question", + authorship: "in question" }) ).to.equal(true); expect( validate({ name: "William Shakespeare", - address: "Henley Street, Stratford-upon-Avon, Warwickshire, England", + address: "Henley Street, Stratford-upon-Avon, Warwickshire, England" }) ).to.equal(false); }); @@ -379,17 +379,17 @@ describe("JsonSchema", () => { const schema = JsonSchema.from({ type: "object", properties: { - name: {type: "string"}, + name: {type: "string"} }, - required: ["name"], + required: ["name"] }).toObject(); expect(schema).to.deep.equal({ type: "object", properties: { - name: {type: "string"}, + name: {type: "string"} }, - required: ["name"], + required: ["name"] }); const validate = new Ajv().compile(schema); @@ -404,17 +404,17 @@ describe("JsonSchema", () => { const schema = JsonSchema.from({ type: "object", properties: { - name: {type: "number"}, + name: {type: "number"} }, - required: ["name"], + required: ["name"] }).toObject(); expect(schema).to.deep.equal({ type: "object", properties: { - name: {type: "number"}, + name: {type: "number"} }, - required: ["name"], + required: ["name"] }); const validate = new Ajv().compile(schema); @@ -431,10 +431,10 @@ describe("JsonSchema", () => { properties: { name: { type: "string", - minLength: 1, - }, + minLength: 1 + } }, - required: ["name"], + required: ["name"] }).toObject(); expect(schema).to.deep.equal({ @@ -442,10 +442,10 @@ describe("JsonSchema", () => { properties: { name: { type: "string", - minLength: 1, - }, + minLength: 1 + } }, - required: ["name"], + required: ["name"] }); const validate = new Ajv().compile(schema); @@ -460,17 +460,17 @@ describe("JsonSchema", () => { const schema = JsonSchema.from({ type: "object", properties: { - name: {type: "number", exclusiveMinimum: 0}, + name: {type: "number", exclusiveMinimum: 0} }, - required: ["name"], + required: ["name"] }).toObject(); expect(schema).to.deep.equal({ type: "object", properties: { - name: {type: "number", exclusiveMinimum: 0}, + name: {type: "number", exclusiveMinimum: 0} }, - required: ["name"], + required: ["name"] }); const validate = new Ajv().compile(schema); @@ -487,19 +487,19 @@ describe("JsonSchema", () => { const schema = JsonSchema.from({ type: "object", propertyNames: JsonSchema.from({ - pattern: "^[A-Za-z_][A-Za-z0-9_]*$", - }), + pattern: "^[A-Za-z_][A-Za-z0-9_]*$" + }) }).toObject(); const validate = new Ajv().compile(schema); expect( validate({ - _a_proper_token_001: "value", + _a_proper_token_001: "value" }) ).to.equal(true); expect( validate({ - "001 invalid": "value", + "001 invalid": "value" }) ).to.equal(false); }); @@ -510,7 +510,7 @@ describe("JsonSchema", () => { const schema = JsonSchema.from({ type: "object", minProperties: 2, - maxProperties: 3, + maxProperties: 3 }).toObject(); const validate = new Ajv().compile(schema); @@ -531,14 +531,14 @@ describe("JsonSchema", () => { properties: { name: {type: "string"}, credit_card: {type: "number"}, - billing_address: {type: "string"}, + billing_address: {type: "string"} }, required: ["name"], dependencies: { - credit_card: ["billing_address"], - }, + credit_card: ["billing_address"] + } }).toObject(); expect(schema).to.deep.eq({ @@ -547,14 +547,14 @@ describe("JsonSchema", () => { properties: { name: {type: "string"}, credit_card: {type: "number"}, - billing_address: {type: "string"}, + billing_address: {type: "string"} }, required: ["name"], dependencies: { - credit_card: ["billing_address"], - }, + credit_card: ["billing_address"] + } }); const validate = new Ajv().compile(schema); @@ -562,24 +562,24 @@ describe("JsonSchema", () => { validate({ name: "John Doe", credit_card: 5555555555555555, - billing_address: "555 Debtor's Lane", + billing_address: "555 Debtor's Lane" }) ).to.equal(true); expect( validate({ name: "John Doe", - credit_card: 5555555555555555, + credit_card: 5555555555555555 }) ).to.equal(false); expect( validate({ - name: "John Doe", + name: "John Doe" }) ).to.equal(true); expect( validate({ name: "John Doe", - billing_address: "555 Debtor's Lane", + billing_address: "555 Debtor's Lane" }) ).to.equal(true); }); @@ -590,28 +590,28 @@ describe("JsonSchema", () => { properties: { name: {type: "string"}, credit_card: {type: "number"}, - billing_address: {type: "string"}, + billing_address: {type: "string"} }, required: ["name"], dependencies: { credit_card: ["billing_address"], - billing_address: ["credit_card"], - }, + billing_address: ["credit_card"] + } }).toObject(); const validate = new Ajv().compile(schema); expect( validate({ name: "John Doe", - credit_card: 5555555555555555, + credit_card: 5555555555555555 }) ).to.equal(false); expect( validate({ name: "John Doe", - billing_address: "555 Debtor's Lane", + billing_address: "555 Debtor's Lane" }) ).to.equal(false); }); @@ -623,7 +623,7 @@ describe("JsonSchema", () => { properties: { name: {type: "string"}, - credit_card: {type: "number"}, + credit_card: {type: "number"} }, required: ["name"], @@ -631,11 +631,11 @@ describe("JsonSchema", () => { dependencies: { credit_card: { properties: { - billing_address: {type: "string"}, + billing_address: {type: "string"} }, - required: ["billing_address"], - }, - }, + required: ["billing_address"] + } + } }).toObject(); const validate = new Ajv().compile(schema); @@ -643,24 +643,24 @@ describe("JsonSchema", () => { validate({ name: "John Doe", credit_card: 5555555555555555, - billing_address: "555 Debtor's Lane", + billing_address: "555 Debtor's Lane" }) ).to.equal(true); expect( validate({ name: "John Doe", - credit_card: 5555555555555555, + credit_card: 5555555555555555 }) ).to.equal(false); expect( validate({ - name: "John Doe", + name: "John Doe" }) ).to.equal(true); expect( validate({ name: "John Doe", - billing_address: "555 Debtor's Lane", + billing_address: "555 Debtor's Lane" }) ).to.equal(true); }); @@ -673,9 +673,9 @@ describe("JsonSchema", () => { type: "object", patternProperties: { "^S_": {type: "string"}, - "^I_": {type: "integer"}, + "^I_": {type: "integer"} }, - additionalProperties: false, + additionalProperties: false }).toObject(); expect(schema).to.deep.equal({ @@ -684,10 +684,10 @@ describe("JsonSchema", () => { "^S_": {type: "string"}, "^I_": { type: "integer", - multipleOf: 1, - }, + multipleOf: 1 + } }, - additionalProperties: false, + additionalProperties: false }); const validate = new Ajv().compile(schema); @@ -701,25 +701,25 @@ describe("JsonSchema", () => { const schema = JsonSchema.from({ type: "object", properties: { - builtin: {type: "number"}, + builtin: {type: "number"} }, patternProperties: { "^S_": {type: "string"}, - "^I_": {type: "integer"}, + "^I_": {type: "integer"} }, - additionalProperties: JsonSchema.from({type: "string"}), + additionalProperties: JsonSchema.from({type: "string"}) }).toObject(); expect(schema).to.deep.equal({ type: "object", properties: { - builtin: {type: "number"}, + builtin: {type: "number"} }, patternProperties: { "^S_": {type: "string"}, - "^I_": {type: "integer", multipleOf: 1.0}, + "^I_": {type: "integer", multipleOf: 1.0} }, - additionalProperties: {type: "string"}, + additionalProperties: {type: "string"} }); const validate = new Ajv().compile(schema); @@ -737,7 +737,7 @@ describe("JsonSchema", () => { const validate = new Ajv().compile(schema); expect(schema).to.deep.equal({ - type: "array", + type: "array" }); expect(validate([1, 2, 3, 4, 5])).to.equal(true); @@ -753,8 +753,8 @@ describe("JsonSchema", () => { const schema = JsonSchema.from({ type: Array, items: JsonSchema.from({ - type: "number", - }), + type: "number" + }) }).toObject(); const validate = new Ajv().compile(schema); @@ -762,8 +762,8 @@ describe("JsonSchema", () => { expect(schema).to.deep.equal({ type: "array", items: { - type: "number", - }, + type: "number" + } }); expect(validate([1, 2, 3, 4, 5])).to.equal(true); @@ -775,8 +775,8 @@ describe("JsonSchema", () => { const schema = JsonSchema.from({ type: "array", contains: { - type: "number", - }, + type: "number" + } }).toObject(); const validate = new Ajv().compile(schema); @@ -784,8 +784,8 @@ describe("JsonSchema", () => { expect(schema).to.deep.equal({ type: "array", contains: { - type: "number", - }, + type: "number" + } }); expect(validate(["life", "universe", "everything", 42])).to.equal(true); @@ -800,20 +800,20 @@ describe("JsonSchema", () => { type: "array", items: [ { - type: "number", + type: "number" }, { - type: "string", + type: "string" }, { type: "string", - enum: ["Street", "Avenue", "Boulevard"], + enum: ["Street", "Avenue", "Boulevard"] }, { type: "string", - enum: ["NW", "NE", "SW", "SE"], - }, - ], + enum: ["NW", "NE", "SW", "SE"] + } + ] }).toObject(); const validate = new Ajv().compile(schema); @@ -822,20 +822,20 @@ describe("JsonSchema", () => { type: "array", items: [ { - type: "number", + type: "number" }, { - type: "string", + type: "string" }, { type: "string", - enum: ["Street", "Avenue", "Boulevard"], + enum: ["Street", "Avenue", "Boulevard"] }, { type: "string", - enum: ["NW", "NE", "SW", "SE"], - }, - ], + enum: ["NW", "NE", "SW", "SE"] + } + ] }); expect(validate([1600, "Pennsylvania", "Avenue", "NW"])).to.equal(true); @@ -849,21 +849,21 @@ describe("JsonSchema", () => { type: "array", items: [ { - type: "number", + type: "number" }, { - type: "string", + type: "string" }, { type: "string", - enum: ["Street", "Avenue", "Boulevard"], + enum: ["Street", "Avenue", "Boulevard"] }, { type: "string", - enum: ["NW", "NE", "SW", "SE"], - }, + enum: ["NW", "NE", "SW", "SE"] + } ], - additionalItems: false, + additionalItems: false }).toObject(); const validate = new Ajv().compile(schema); @@ -872,21 +872,21 @@ describe("JsonSchema", () => { type: "array", items: [ { - type: "number", + type: "number" }, { - type: "string", + type: "string" }, { type: "string", - enum: ["Street", "Avenue", "Boulevard"], + enum: ["Street", "Avenue", "Boulevard"] }, { type: "string", - enum: ["NW", "NE", "SW", "SE"], - }, + enum: ["NW", "NE", "SW", "SE"] + } ], - additionalItems: false, + additionalItems: false }); expect(validate([1600, "Pennsylvania", "Avenue", "NW"])).to.equal(true); @@ -898,21 +898,21 @@ describe("JsonSchema", () => { type: "array", items: [ { - type: "number", + type: "number" }, { - type: "string", + type: "string" }, { type: "string", - enum: ["Street", "Avenue", "Boulevard"], + enum: ["Street", "Avenue", "Boulevard"] }, { type: "string", - enum: ["NW", "NE", "SW", "SE"], - }, + enum: ["NW", "NE", "SW", "SE"] + } ], - additionalItems: {type: "string"}, + additionalItems: {type: "string"} }).toObject(); const validate = new Ajv().compile(schema); @@ -921,21 +921,21 @@ describe("JsonSchema", () => { type: "array", items: [ { - type: "number", + type: "number" }, { - type: "string", + type: "string" }, { type: "string", - enum: ["Street", "Avenue", "Boulevard"], + enum: ["Street", "Avenue", "Boulevard"] }, { type: "string", - enum: ["NW", "NE", "SW", "SE"], - }, + enum: ["NW", "NE", "SW", "SE"] + } ], - additionalItems: {type: "string"}, + additionalItems: {type: "string"} }); expect(validate([1600, "Pennsylvania", "Avenue", "NW"])).to.equal(true); @@ -948,7 +948,7 @@ describe("JsonSchema", () => { const schema = JsonSchema.from({ type: "array", minItems: 2, - maxItems: 3, + maxItems: 3 }).toObject(); const validate = new Ajv().compile(schema); @@ -965,7 +965,7 @@ describe("JsonSchema", () => { it("should create a new jsonSchema", () => { const schema = JsonSchema.from({ type: "array", - uniqueItems: true, + uniqueItems: true }).toObject(); const validate = new Ajv().compile(schema); @@ -984,7 +984,7 @@ describe("JsonSchema", () => { const validate = new Ajv().compile(schema); expect(schema).to.deep.equal({ - type: "boolean", + type: "boolean" }); expect(validate(true)).to.equal(true); @@ -998,7 +998,7 @@ describe("JsonSchema", () => { const schema = JsonSchema.from({type: null}).toObject(); expect(schema).to.deep.equal({ - type: "null", + type: "null" }); const validate = new Ajv().compile(schema); @@ -1019,14 +1019,14 @@ describe("JsonSchema", () => { title: "Match anything", description: "This is a schema that matches anything.", default: "Default value", - examples: ["Anything", 4035], + examples: ["Anything", 4035] }).toObject(); expect(schema).to.deep.equal({ title: "Match anything", description: "This is a schema that matches anything.", default: "Default value", - examples: ["Anything", 4035], + examples: ["Anything", 4035] }); }); }); @@ -1036,12 +1036,12 @@ describe("JsonSchema", () => { it("should create a new jsonSchema", () => { const schema = JsonSchema.from({ type: "string", - enum: ["red", "amber", "green", "green"], + enum: ["red", "amber", "green", "green"] }).toObject(); expect(schema).to.deep.equal({ type: "string", - enum: ["red", "amber", "green"], + enum: ["red", "amber", "green"] }); const validate = new Ajv().compile(schema); @@ -1051,11 +1051,11 @@ describe("JsonSchema", () => { }); it("should create a new jsonSchema (without type)", () => { const schema = JsonSchema.from({ - enum: ["red", "amber", "green", null, 42], + enum: ["red", "amber", "green", null, 42] }).toObject(); expect(schema).to.deep.equal({ - enum: ["red", "amber", "green", null, 42], + enum: ["red", "amber", "green", null, 42] }); const validate = new Ajv().compile(schema); @@ -1073,17 +1073,17 @@ describe("JsonSchema", () => { const schema = JsonSchema.from({ properties: { country: { - const: "United States of America", - }, - }, + const: "United States of America" + } + } }).toObject(); expect(schema).to.deep.equal({ properties: { country: { - const: "United States of America", - }, - }, + const: "United States of America" + } + } }); const validate = new Ajv().compile(schema); @@ -1114,7 +1114,7 @@ describe("JsonSchema", () => { exclusiveMinimum: 7, maxLength: 8, minLength: 9, - title: "title", + title: "title" }).toObject(); expect(result).to.deep.equal({ @@ -1136,7 +1136,7 @@ describe("JsonSchema", () => { exclusiveMinimum: 7, maxLength: 8, minLength: 9, - title: "title", + title: "title" }); }); }); @@ -1148,15 +1148,15 @@ describe("JsonSchema", () => { const schema = JsonSchema.from({ anyOf: [ {type: "string", maxLength: 5}, - {type: "number", minimum: 0}, - ], + {type: "number", minimum: 0} + ] }).toObject(); expect(schema).to.deep.equal({ anyOf: [ {type: "string", maxLength: 5}, - {type: "number", minimum: 0}, - ], + {type: "number", minimum: 0} + ] }); const validate = new Ajv().compile(schema); @@ -1173,15 +1173,15 @@ describe("JsonSchema", () => { const schema = JsonSchema.from({ allOf: [ {type: "string", maxLength: 5}, - {type: "number", minimum: 0}, - ], + {type: "number", minimum: 0} + ] }).toObject(); expect(schema).to.deep.equal({ allOf: [ {type: "string", maxLength: 5}, - {type: "number", minimum: 0}, - ], + {type: "number", minimum: 0} + ] }); const validate = new Ajv().compile(schema); @@ -1196,8 +1196,8 @@ describe("JsonSchema", () => { const schema = JsonSchema.from({ oneOf: [ {type: "number", multipleOf: 5}, - {type: "number", multipleOf: 3}, - ], + {type: "number", multipleOf: 3} + ] }).toObject(); const validate = new Ajv().compile(schema); @@ -1226,7 +1226,7 @@ describe("JsonSchema", () => { const result = JsonSchema.from({type: Array}).toObject(); expect(JsonSchema.from({type: Array}).isCollection).to.equal(true); expect(result).to.deep.equal({ - type: "array", + type: "array" }); }); @@ -1234,7 +1234,7 @@ describe("JsonSchema", () => { const result = JsonSchema.from({type: Map}).toObject(); expect(result).to.deep.equal({ - type: "object", + type: "object" }); }); @@ -1243,18 +1243,18 @@ describe("JsonSchema", () => { expect(result).to.deep.equal({ type: "array", - uniqueItems: true, + uniqueItems: true }); }); }); describe("Class", () => { it("should create a new jsonSchema", () => { const result = JsonSchema.from({ - type: class Test {}, + type: class Test {} }).toObject(); expect(result).to.deep.equal({ - type: "object", + type: "object" }); }); }); @@ -1267,28 +1267,28 @@ describe("JsonSchema", () => { type: "object", properties: { name: { - type: "string", + type: "string" }, owner: { - $ref: "#/definitions/User", - }, - }, + $ref: "#/definitions/User" + } + } }, User: { type: "object", properties: { id: { - type: "string", + type: "string" }, posts: { type: "array", items: { - $ref: "#/definitions/Post", - }, - }, - }, - }, - }, + $ref: "#/definitions/Post" + } + } + } + } + } }).toObject(); const validate = new Ajv().compile(schema); @@ -1300,28 +1300,28 @@ describe("JsonSchema", () => { type: "object", properties: { name: { - type: "string", + type: "string" }, owner: { - $ref: "#/definitions/User", - }, - }, + $ref: "#/definitions/User" + } + } }, User: { type: "object", properties: { id: { - type: "string", + type: "string" }, posts: { type: "array", items: { - $ref: "#/definitions/Post", - }, - }, - }, - }, - }, + $ref: "#/definitions/Post" + } + } + } + } + } }); expect( @@ -1331,10 +1331,10 @@ describe("JsonSchema", () => { id: "user-id", posts: [ { - id: "post-id", - }, - ], - }, + id: "post-id" + } + ] + } }) ); }); @@ -1345,10 +1345,10 @@ describe("JsonSchema", () => { type: "object", properties: { prop: { - type: "string", - }, + type: "string" + } }, - required: ["prop"], + required: ["prop"] }) .addAlias("prop", "aliasProp") .toObject(); @@ -1357,10 +1357,10 @@ describe("JsonSchema", () => { type: "object", properties: { aliasProp: { - type: "string", - }, + type: "string" + } }, - required: ["aliasProp"], + required: ["aliasProp"] }); }); @@ -1369,10 +1369,10 @@ describe("JsonSchema", () => { type: "object", properties: { prop: { - type: "string", - }, + type: "string" + } }, - required: ["prop"], + required: ["prop"] }) .addAlias("prop", "aliasProp") .removeAlias("prop2") @@ -1382,10 +1382,10 @@ describe("JsonSchema", () => { type: "object", properties: { prop: { - type: "string", - }, + type: "string" + } }, - required: ["prop"], + required: ["prop"] }); }); }); @@ -1394,14 +1394,14 @@ describe("JsonSchema", () => { const result = JsonSchema.from({type: [String, Number]}).toObject(); expect(result).to.deep.equal({ - type: ["string", "number"], + type: ["string", "number"] }); }); it("should create a new jsonSchema (2)", () => { const result = JsonSchema.from({type: ["string", "null"]}).toObject(); expect(result).to.deep.equal({ - type: ["string", "null"], + type: ["string", "null"] }); }); }); @@ -1411,7 +1411,7 @@ describe("JsonSchema", () => { const result = JsonSchema.from({type: Object}).any().toObject(); expect(result).to.deep.equal({ - type: ["integer", "number", "string", "boolean", "array", "object", "null"], + type: ["integer", "number", "string", "boolean", "array", "object", "null"] }); }); }); diff --git a/packages/schema/src/domain/SpecTypes.ts b/packages/schema/src/domain/SpecTypes.ts index 730f1bc4197..b4bbf4ce2d3 100644 --- a/packages/schema/src/domain/SpecTypes.ts +++ b/packages/schema/src/domain/SpecTypes.ts @@ -1,5 +1,5 @@ export enum SpecTypes { JSON = "jsonschema", SWAGGER = "swagger2", - OPENAPI = "openapi3", + OPENAPI = "openapi3" } diff --git a/packages/schema/src/utils/generics.ts b/packages/schema/src/utils/generics.ts index a36e38d2a47..40ca4cb1556 100644 --- a/packages/schema/src/utils/generics.ts +++ b/packages/schema/src/utils/generics.ts @@ -46,7 +46,7 @@ export function mapGenericsOptions(options: Partial { diff --git a/packages/schema/src/utils/getJsonPathParameters.spec.ts b/packages/schema/src/utils/getJsonPathParameters.spec.ts index 398cb94c875..8262649ade5 100644 --- a/packages/schema/src/utils/getJsonPathParameters.spec.ts +++ b/packages/schema/src/utils/getJsonPathParameters.spec.ts @@ -11,9 +11,9 @@ describe("getJsonPathParameters", () => { in: "path", name: "path1", required: true, - type: "string", - }, - ], + type: "string" + } + ] }, { path: "/rest/get/{path1}/{path2}", @@ -22,16 +22,16 @@ describe("getJsonPathParameters", () => { in: "path", name: "path1", required: true, - type: "string", + type: "string" }, { in: "path", name: "path2", required: true, - type: "string", - }, - ], - }, + type: "string" + } + ] + } ]); }); it("should return params and path(2)", () => { @@ -43,32 +43,32 @@ describe("getJsonPathParameters", () => { in: "path", name: "path1", required: true, - type: "string", + type: "string" }, { in: "path", name: "path2", required: true, - type: "string", - }, - ], - }, + type: "string" + } + ] + } ]); }); it("should return params and path(3)", () => { expect(getJsonPathParameters("/rest/", "/get/path1/path2")).to.deep.eq([ { path: "/rest/get/path1/path2", - parameters: [], - }, + parameters: [] + } ]); }); it("should return params and path(4)", () => { expect(getJsonPathParameters("/rest/calendar/", "/")).to.deep.eq([ { path: "/rest/calendar", - parameters: [], - }, + parameters: [] + } ]); }); it("should return params and path /file/:filename.json", () => { @@ -80,10 +80,10 @@ describe("getJsonPathParameters", () => { in: "path", name: "filename", required: true, - type: "string", - }, - ], - }, + type: "string" + } + ] + } ]); }); it("should return params and path /category/:category([a-zA-Z/_-]+).json", () => { @@ -95,18 +95,18 @@ describe("getJsonPathParameters", () => { in: "path", name: "category", required: true, - type: "string", - }, - ], - }, + type: "string" + } + ] + } ]); }); it("should return params and path regexp", () => { expect(getJsonPathParameters("/rest/", /\*json$/)).to.deep.eq([ { parameters: [], - path: "/rest/*json$", - }, + path: "/rest/*json$" + } ]); }); }); diff --git a/packages/schema/src/utils/getJsonPathParameters.ts b/packages/schema/src/utils/getJsonPathParameters.ts index 9b714284554..335bf3ef801 100644 --- a/packages/schema/src/utils/getJsonPathParameters.ts +++ b/packages/schema/src/utils/getJsonPathParameters.ts @@ -4,7 +4,7 @@ function getVariable(subpath: string) { return { name, - postfix: splited.length ? `.${splited.join(".")}` : "", + postfix: splited.length ? `.${splited.join(".")}` : "" }; } @@ -37,7 +37,7 @@ export function getJsonPathParameters(base: string, path: string | RegExp | (str paths.push({ path: current, - parameters: [].concat(params as any), + parameters: [].concat(params as any) }); } @@ -48,13 +48,13 @@ export function getJsonPathParameters(base: string, path: string | RegExp | (str in: "path", name, type: "string", - required: true, + required: true }); if (optional && isOptional) { paths.push({ path: current, - parameters: [].concat(params as any), + parameters: [].concat(params as any) }); } } else { @@ -67,7 +67,7 @@ export function getJsonPathParameters(base: string, path: string | RegExp | (str : [ { path: current, - parameters: [].concat(params as any), - }, + parameters: [].concat(params as any) + } ]; } diff --git a/packages/schema/src/utils/getJsonSchema.spec.ts b/packages/schema/src/utils/getJsonSchema.spec.ts index 39a8ce323da..30e1c3ff976 100644 --- a/packages/schema/src/utils/getJsonSchema.spec.ts +++ b/packages/schema/src/utils/getJsonSchema.spec.ts @@ -27,28 +27,28 @@ describe("getJsonSchema", () => { properties: { prop1: { minLength: 1, - type: "string", + type: "string" }, prop2: { type: "array", items: { - type: "string", - }, + type: "string" + } }, prop3: { type: "array", uniqueItems: true, items: { - type: "string", - }, + type: "string" + } }, prop4: { type: "object", additionalProperties: { - type: "string", - }, - }, - }, + type: "string" + } + } + } }); }); it("should declare all schema correctly (alias)", () => { @@ -68,9 +68,9 @@ describe("getJsonSchema", () => { properties: { prop_1: { minLength: 1, - type: "string", - }, - }, + type: "string" + } + } }); }); it("should declare prop with a nested model", () => { @@ -97,37 +97,37 @@ describe("getJsonSchema", () => { type: "object", properties: { id: { - type: "string", + type: "string" }, prop1: { - type: "string", - }, - }, + type: "string" + } + } }); expect(getJsonSchema(Model)).to.deep.equal({ type: "object", properties: { id: { - type: "string", + type: "string" }, nested: { - $ref: "#/definitions/NestedModel", - }, + $ref: "#/definitions/NestedModel" + } }, definitions: { NestedModel: { type: "object", properties: { id: { - type: "string", + type: "string" }, prop1: { - type: "string", - }, - }, - }, - }, + type: "string" + } + } + } + } }); }); it("should declare prop with a nested model with named model", () => { @@ -154,37 +154,37 @@ describe("getJsonSchema", () => { type: "object", properties: { id: { - type: "string", + type: "string" }, prop1: { - type: "string", - }, - }, + type: "string" + } + } }); expect(getJsonSchema(Model)).to.deep.equal({ type: "object", properties: { id: { - type: "string", + type: "string" }, nested: { - $ref: "#/definitions/Nested", - }, + $ref: "#/definitions/Nested" + } }, definitions: { Nested: { type: "object", properties: { id: { - type: "string", + type: "string" }, prop1: { - type: "string", - }, - }, - }, - }, + type: "string" + } + } + } + } }); }); it("should declare prop with a nested of nested model (Array)", () => { @@ -218,79 +218,79 @@ describe("getJsonSchema", () => { type: "object", properties: { id: { - type: "string", + type: "string" }, prop1: { - type: "string", - }, - }, + type: "string" + } + } }); expect(getJsonSchema(NestedModel)).to.deep.equal({ type: "object", properties: { id: { - type: "string", + type: "string" }, children: { type: "array", items: { - $ref: "#/definitions/ChildModel", - }, - }, + $ref: "#/definitions/ChildModel" + } + } }, definitions: { ChildModel: { type: "object", properties: { id: { - type: "string", + type: "string" }, prop1: { - type: "string", - }, - }, - }, - }, + type: "string" + } + } + } + } }); expect(getJsonSchema(Model)).to.deep.equal({ type: "object", properties: { id: { - type: "string", + type: "string" }, nested: { - $ref: "#/definitions/NestedModel", - }, + $ref: "#/definitions/NestedModel" + } }, definitions: { NestedModel: { type: "object", properties: { id: { - type: "string", + type: "string" }, children: { type: "array", items: { - $ref: "#/definitions/ChildModel", - }, - }, - }, + $ref: "#/definitions/ChildModel" + } + } + } }, ChildModel: { type: "object", properties: { id: { - type: "string", + type: "string" }, prop1: { - type: "string", - }, - }, - }, - }, + type: "string" + } + } + } + } }); }); it("should declare prop with a nested of nested model (Set)", () => { @@ -324,81 +324,81 @@ describe("getJsonSchema", () => { type: "object", properties: { id: { - type: "string", + type: "string" }, prop1: { - type: "string", - }, - }, + type: "string" + } + } }); expect(getJsonSchema(NestedModel)).to.deep.equal({ type: "object", properties: { id: { - type: "string", + type: "string" }, children: { type: "array", uniqueItems: true, items: { - $ref: "#/definitions/ChildModel", - }, - }, + $ref: "#/definitions/ChildModel" + } + } }, definitions: { ChildModel: { type: "object", properties: { id: { - type: "string", + type: "string" }, prop1: { - type: "string", - }, - }, - }, - }, + type: "string" + } + } + } + } }); expect(getJsonSchema(Model)).to.deep.equal({ type: "object", properties: { id: { - type: "string", + type: "string" }, nested: { - $ref: "#/definitions/NestedModel", - }, + $ref: "#/definitions/NestedModel" + } }, definitions: { NestedModel: { type: "object", properties: { id: { - type: "string", + type: "string" }, children: { type: "array", uniqueItems: true, items: { - $ref: "#/definitions/ChildModel", - }, - }, - }, + $ref: "#/definitions/ChildModel" + } + } + } }, ChildModel: { type: "object", properties: { id: { - type: "string", + type: "string" }, prop1: { - type: "string", - }, - }, - }, - }, + type: "string" + } + } + } + } }); }); it("should declare prop with a nested of nested model (Map)", () => { @@ -432,79 +432,79 @@ describe("getJsonSchema", () => { type: "object", properties: { id: { - type: "string", + type: "string" }, prop1: { - type: "string", - }, - }, + type: "string" + } + } }); expect(getJsonSchema(NestedModel)).to.deep.equal({ type: "object", properties: { id: { - type: "string", + type: "string" }, children: { type: "object", additionalProperties: { - $ref: "#/definitions/ChildModel", - }, - }, + $ref: "#/definitions/ChildModel" + } + } }, definitions: { ChildModel: { type: "object", properties: { id: { - type: "string", + type: "string" }, prop1: { - type: "string", - }, - }, - }, - }, + type: "string" + } + } + } + } }); expect(getJsonSchema(Model)).to.deep.equal({ type: "object", properties: { id: { - type: "string", + type: "string" }, nested: { - $ref: "#/definitions/NestedModel", - }, + $ref: "#/definitions/NestedModel" + } }, definitions: { NestedModel: { type: "object", properties: { id: { - type: "string", + type: "string" }, children: { type: "object", additionalProperties: { - $ref: "#/definitions/ChildModel", - }, - }, - }, + $ref: "#/definitions/ChildModel" + } + } + } }, ChildModel: { type: "object", properties: { id: { - type: "string", + type: "string" }, prop1: { - type: "string", - }, - }, - }, - }, + type: "string" + } + } + } + } }); }); it("should accept circular ref", () => { @@ -518,38 +518,38 @@ describe("getJsonSchema", () => { Post: { properties: { id: { - type: "string", + type: "string" }, owner: { - $ref: "#/definitions/User", - }, + $ref: "#/definitions/User" + } }, - type: "object", + type: "object" }, User: { properties: { name: { - type: "string", + type: "string" }, posts: { items: { - $ref: "#/definitions/Post", + $ref: "#/definitions/Post" }, - type: "array", - }, + type: "array" + } }, - type: "object", - }, + type: "object" + } }, properties: { id: { - type: "string", + type: "string" }, owner: { - $ref: "#/definitions/User", - }, + $ref: "#/definitions/User" + } }, - type: "object", + type: "object" }); }); it("should return the json schema for an inherited model", () => { @@ -574,18 +574,18 @@ describe("getJsonSchema", () => { type: "object", properties: { id: { - type: "string", + type: "string" }, email: { type: "string", minLength: 0, - format: "email", + format: "email" }, name: { - type: "string", - }, + type: "string" + } }, - required: ["email"], + required: ["email"] }); }); it("should return the json schema for an inherited model and generics", () => { @@ -625,11 +625,11 @@ describe("getJsonSchema", () => { Role: { properties: { level: { - type: "string", - }, + type: "string" + } }, - type: "object", - }, + type: "object" + } }, properties: { payload: { @@ -637,23 +637,23 @@ describe("getJsonSchema", () => { email: { format: "email", minLength: 0, - type: "string", + type: "string" }, id: { - type: "string", + type: "string" }, name: { - type: "string", + type: "string" }, role: { - $ref: "#/definitions/Role", - }, + $ref: "#/definitions/Role" + } }, required: ["email"], - type: "object", - }, + type: "object" + } }, - type: "object", + type: "object" }); }); it("should return the json schema with hosted schemes", () => { @@ -693,11 +693,11 @@ describe("getJsonSchema", () => { Role: { properties: { level: { - type: "string", - }, + type: "string" + } }, - type: "object", - }, + type: "object" + } }, properties: { payload: { @@ -705,23 +705,23 @@ describe("getJsonSchema", () => { email: { format: "email", minLength: 0, - type: "string", + type: "string" }, id: { - type: "string", + type: "string" }, name: { - type: "string", + type: "string" }, role: { - $ref: "http://example.com/schema/Role", - }, + $ref: "http://example.com/schema/Role" + } }, required: ["email"], - type: "object", - }, + type: "object" + } }, - type: "object", + type: "object" }); }); }); diff --git a/packages/schema/src/utils/getJsonSchema.ts b/packages/schema/src/utils/getJsonSchema.ts index 6785770209e..b8ce76c506e 100644 --- a/packages/schema/src/utils/getJsonSchema.ts +++ b/packages/schema/src/utils/getJsonSchema.ts @@ -34,7 +34,7 @@ export function getJsonSchema(model: Type | JsonEntityStore, options: JsonS ...options, root: true, spec: options.spec || SpecTypes.JSON, - schemas: {}, + schemas: {} }; const entity = model instanceof JsonEntityStore ? model : JsonEntityStore.from(model); diff --git a/packages/schema/src/utils/getSpec.spec.ts b/packages/schema/src/utils/getSpec.spec.ts index 3231f882ae9..bd1b125d915 100644 --- a/packages/schema/src/utils/getSpec.spec.ts +++ b/packages/schema/src/utils/getSpec.spec.ts @@ -8,7 +8,7 @@ import {getSpec} from "./getSpec"; const validate = async (spec: any, version = SpecTypes.SWAGGER) => { const file = __dirname + "/spec.json"; spec = { - ...spec, + ...spec }; try { if (version === SpecTypes.OPENAPI) { @@ -22,13 +22,13 @@ const validate = async (spec: any, version = SpecTypes.SWAGGER) => { description: "Description", termsOfService: "termsOfService", contact: { - email: "apiteam@swagger.io", + email: "apiteam@swagger.io" }, license: { name: "Apache 2.0", - url: "http://www.apache.org/licenses/LICENSE-2.0.html", + url: "http://www.apache.org/licenses/LICENSE-2.0.html" }, - version: "1.0.0", + version: "1.0.0" }; writeJsonSync(file, spec, {encoding: "utf8"}); @@ -56,7 +56,7 @@ describe("getSpec()", () => { // THEN const spec = getSpec(Controller, { - spec: SpecTypes.SWAGGER, + spec: SpecTypes.SWAGGER }); expect(await validate(spec)).to.eq(true); }); @@ -75,8 +75,8 @@ describe("getSpec()", () => { definitions: {}, tags: [ { - name: "Controller", - }, + name: "Controller" + } ], paths: { "/": { @@ -85,11 +85,11 @@ describe("getSpec()", () => { parameters: [], responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["Controller"], - }, + tags: ["Controller"] + } }, "/{id}": { get: { @@ -99,18 +99,18 @@ describe("getSpec()", () => { in: "path", name: "id", required: true, - type: "string", - }, + type: "string" + } ], responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["Controller"], - }, - }, - }, + tags: ["Controller"] + } + } + } }); }); it("should declare all schema correctly with expression", async () => { @@ -128,8 +128,8 @@ describe("getSpec()", () => { definitions: {}, tags: [ { - name: "Controller", - }, + name: "Controller" + } ], paths: { "/": { @@ -139,10 +139,10 @@ describe("getSpec()", () => { tags: ["Controller"], responses: { "200": { - description: "Success", - }, - }, - }, + description: "Success" + } + } + } }, "/{id}": { get: { @@ -153,17 +153,17 @@ describe("getSpec()", () => { in: "path", name: "id", required: true, - type: "string", - }, + type: "string" + } ], responses: { "200": { - description: "Success", - }, - }, - }, - }, - }, + description: "Success" + } + } + } + } + } }); }); }); @@ -182,8 +182,8 @@ describe("getSpec()", () => { definitions: {}, tags: [ { - name: "Controller", - }, + name: "Controller" + } ], paths: { "/{id}": { @@ -195,23 +195,23 @@ describe("getSpec()", () => { in: "path", name: "id", required: true, - type: "string", + type: "string" }, { in: "query", name: "basic", required: false, - type: "string", - }, + type: "string" + } ], responses: { "200": { - description: "Success", - }, - }, - }, - }, - }, + description: "Success" + } + } + } + } + } }); }); it("should declare all schema correctly (query - swagger2 - model)", async () => { @@ -236,8 +236,8 @@ describe("getSpec()", () => { definitions: {}, tags: [ { - name: "Controller", - }, + name: "Controller" + } ], paths: { "/{id}": { @@ -249,29 +249,29 @@ describe("getSpec()", () => { in: "path", name: "id", required: true, - type: "string", + type: "string" }, { in: "query", name: "id", required: false, - type: "string", + type: "string" }, { in: "query", name: "name", required: false, - type: "string", - }, + type: "string" + } ], responses: { "200": { - description: "Success", - }, - }, - }, - }, - }, + description: "Success" + } + } + } + } + } }); }); it("should declare all schema correctly (query - openapi3 - model)", async () => { @@ -298,15 +298,15 @@ describe("getSpec()", () => { QueryModel: { properties: { id: { - type: "string", + type: "string" }, name: { - type: "string", - }, + type: "string" + } }, - type: "object", - }, - }, + type: "object" + } + } }, paths: { "/{id}": { @@ -317,30 +317,30 @@ describe("getSpec()", () => { in: "path", name: "id", required: true, - type: "string", + type: "string" }, { in: "query", required: false, schema: { - $ref: "#/components/schemas/QueryModel", - }, - }, + $ref: "#/components/schemas/QueryModel" + } + } ], responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["Controller"], - }, - }, + tags: ["Controller"] + } + } }, tags: [ { - name: "Controller", - }, - ], + name: "Controller" + } + ] }); }); it("should declare all schema correctly (query - swagger2 - array string)", async () => { @@ -357,8 +357,8 @@ describe("getSpec()", () => { definitions: {}, tags: [ { - name: "Controller", - }, + name: "Controller" + } ], paths: { "/{id}": { @@ -370,27 +370,27 @@ describe("getSpec()", () => { in: "path", name: "id", required: true, - type: "string", + type: "string" }, { collectionFormat: "multi", in: "query", items: { - type: "string", + type: "string" }, name: "basic", required: false, - type: "array", - }, + type: "array" + } ], responses: { "200": { - description: "Success", - }, - }, - }, - }, - }, + description: "Success" + } + } + } + } + } }); }); it("should declare all schema correctly (query - openapi3 - array string)", async () => { @@ -405,7 +405,7 @@ describe("getSpec()", () => { expect(spec).to.deep.equal({ components: { - schemas: {}, + schemas: {} }, paths: { "/{id}": { @@ -416,7 +416,7 @@ describe("getSpec()", () => { in: "path", name: "id", required: true, - type: "string", + type: "string" }, { in: "query", @@ -424,26 +424,26 @@ describe("getSpec()", () => { required: false, schema: { items: { - type: "object", + type: "object" }, - type: "array", - }, - }, + type: "array" + } + } ], responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["Controller"], - }, - }, + tags: ["Controller"] + } + } }, tags: [ { - name: "Controller", - }, - ], + name: "Controller" + } + ] }); }); it("should declare all schema correctly (query - swagger2 - Map)", async () => { @@ -460,8 +460,8 @@ describe("getSpec()", () => { definitions: {}, tags: [ { - name: "Controller", - }, + name: "Controller" + } ], paths: { "/{id}": { @@ -473,7 +473,7 @@ describe("getSpec()", () => { in: "path", name: "id", required: true, - type: "string", + type: "string" }, { in: "query", @@ -481,18 +481,18 @@ describe("getSpec()", () => { required: false, type: "object", additionalProperties: { - type: "string", - }, - }, + type: "string" + } + } ], responses: { "200": { - description: "Success", - }, - }, - }, - }, - }, + description: "Success" + } + } + } + } + } }); }); it("should declare all schema correctly (query - openapi3 - Map)", async () => { @@ -507,7 +507,7 @@ describe("getSpec()", () => { expect(spec).to.deep.equal({ components: { - schemas: {}, + schemas: {} }, paths: { "/{id}": { @@ -518,7 +518,7 @@ describe("getSpec()", () => { in: "path", name: "id", required: true, - type: "string", + type: "string" }, { in: "query", @@ -526,26 +526,26 @@ describe("getSpec()", () => { required: false, schema: { additionalProperties: { - type: "string", + type: "string" }, - type: "object", - }, - }, + type: "object" + } + } ], responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["Controller"], - }, - }, + tags: ["Controller"] + } + } }, tags: [ { - name: "Controller", - }, - ], + name: "Controller" + } + ] }); }); }); @@ -571,15 +571,15 @@ describe("getSpec()", () => { type: "object", properties: { prop: { - type: "string", - }, - }, - }, + type: "string" + } + } + } }, tags: [ { - name: "Controller", - }, + name: "Controller" + } ], paths: { "/": { @@ -592,19 +592,19 @@ describe("getSpec()", () => { name: "body", required: true, schema: { - $ref: "#/definitions/MyModel", - }, - }, + $ref: "#/definitions/MyModel" + } + } ], responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["Controller"], - }, - }, - }, + tags: ["Controller"] + } + } + } }); }); it("should declare all schema correctly (model - openapi3)", async () => { @@ -628,17 +628,17 @@ describe("getSpec()", () => { MyModel: { properties: { prop: { - type: "string", - }, + type: "string" + } }, - type: "object", - }, - }, + type: "object" + } + } }, tags: [ { - name: "Controller", - }, + name: "Controller" + } ], paths: { "/": { @@ -649,21 +649,21 @@ describe("getSpec()", () => { content: { "application/json": { schema: { - $ref: "#/components/schemas/MyModel", - }, - }, + $ref: "#/components/schemas/MyModel" + } + } }, - required: true, + required: true }, tags: ["Controller"], responses: { "200": { - description: "Success", - }, - }, - }, - }, - }, + description: "Success" + } + } + } + } + } }); }); it("should declare all schema correctly (Array - model - swagger2)", async () => { @@ -688,16 +688,16 @@ describe("getSpec()", () => { Product: { properties: { title: { - type: "string", - }, + type: "string" + } }, - type: "object", - }, + type: "object" + } }, tags: [ { - name: "Controller", - }, + name: "Controller" + } ], paths: { "/": { @@ -711,20 +711,20 @@ describe("getSpec()", () => { schema: { type: "array", items: { - $ref: "#/definitions/Product", - }, - }, - }, + $ref: "#/definitions/Product" + } + } + } ], responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["Controller"], - }, - }, - }, + tags: ["Controller"] + } + } + } }); }); it("should declare all schema correctly (Map - model - swagger2)", async () => { @@ -749,16 +749,16 @@ describe("getSpec()", () => { Product: { properties: { title: { - type: "string", - }, + type: "string" + } }, - type: "object", - }, + type: "object" + } }, tags: [ { - name: "Controller", - }, + name: "Controller" + } ], paths: { "/": { @@ -771,21 +771,21 @@ describe("getSpec()", () => { required: false, schema: { additionalProperties: { - $ref: "#/definitions/Product", + $ref: "#/definitions/Product" }, - type: "object", - }, - }, + type: "object" + } + } ], tags: ["Controller"], responses: { "200": { - description: "Success", - }, - }, - }, - }, - }, + description: "Success" + } + } + } + } + } }); }); it("should declare all schema correctly (inline - swagger2)", async () => { @@ -802,8 +802,8 @@ describe("getSpec()", () => { definitions: {}, tags: [ { - name: "Controller", - }, + name: "Controller" + } ], paths: { "/": { @@ -820,26 +820,26 @@ describe("getSpec()", () => { properties: { num: { minimum: 0, - type: "number", + type: "number" }, test: { minimum: 0, - type: "number", - }, + type: "number" + } }, required: ["num", "test"], - type: "object", - }, - }, + type: "object" + } + } ], responses: { "200": { - description: "Success", - }, - }, - }, - }, - }, + description: "Success" + } + } + } + } + } }); }); it("should declare all schema correctly (Array - inline - swagger2)", async () => { @@ -859,8 +859,8 @@ describe("getSpec()", () => { definitions: {}, tags: [ { - name: "Controller", - }, + name: "Controller" + } ], paths: { "/": { @@ -879,27 +879,27 @@ describe("getSpec()", () => { type: "array", items: { minimum: 0, - type: "number", - }, + type: "number" + } }, test: { minimum: 0, - type: "number", - }, + type: "number" + } }, required: ["num", "test"], - type: "object", - }, - }, + type: "object" + } + } ], responses: { "200": { - description: "Success", - }, - }, - }, - }, - }, + description: "Success" + } + } + } + } + } }); }); it("should declare all schema correctly (inline - openapi3)", async () => { @@ -917,12 +917,12 @@ describe("getSpec()", () => { expect(await validate(spec, SpecTypes.OPENAPI)).to.eq(true); expect(spec).to.deep.equal({ components: { - schemas: {}, + schemas: {} }, tags: [ { - name: "Controller", - }, + name: "Controller" + } ], paths: { "/": { @@ -937,31 +937,31 @@ describe("getSpec()", () => { num: { items: { minimum: 0, - type: "number", + type: "number" }, - type: "array", + type: "array" }, test: { minimum: 0, - type: "number", - }, + type: "number" + } }, required: ["num", "test"], - type: "object", - }, - }, + type: "object" + } + } }, - required: true, + required: true }, responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["Controller"], - }, - }, - }, + tags: ["Controller"] + } + } + } }); }); it("should declare all schema correctly (generics - openapi3)", () => { @@ -1008,27 +1008,27 @@ describe("getSpec()", () => { Product: { properties: { title: { - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }, Submission: { properties: { _id: { - type: "string", + type: "string" }, data: { - $ref: "#/definitions/Product", - }, + $ref: "#/definitions/Product" + } }, - type: "object", - }, + type: "object" + } }, tags: [ { - name: "Controller1", - }, + name: "Controller1" + } ], paths: { "/": { @@ -1041,45 +1041,45 @@ describe("getSpec()", () => { name: "body", required: false, schema: { - $ref: "#/definitions/Submission", - }, - }, + $ref: "#/definitions/Submission" + } + } ], responses: { "200": { - description: "Success", - }, - }, - }, - }, - }, + description: "Success" + } + } + } + } + } }); expect(spec2).to.deep.equal({ definitions: { Article: { properties: { id: { - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }, Submission: { properties: { _id: { - type: "string", + type: "string" }, data: { - $ref: "#/definitions/Article", - }, + $ref: "#/definitions/Article" + } }, - type: "object", - }, + type: "object" + } }, tags: [ { - name: "Controller2", - }, + name: "Controller2" + } ], paths: { "/": { @@ -1092,18 +1092,18 @@ describe("getSpec()", () => { name: "body", required: false, schema: { - $ref: "#/definitions/Submission", - }, - }, + $ref: "#/definitions/Submission" + } + } ], responses: { "200": { - description: "Success", - }, - }, - }, - }, - }, + description: "Success" + } + } + } + } + } }); }); }); @@ -1128,8 +1128,8 @@ describe("getSpec()", () => { tags: [ { name: "AliasController", - description: "Class description", - }, + description: "Class description" + } ], paths: { "/": { @@ -1141,13 +1141,13 @@ describe("getSpec()", () => { "200": { description: "description", schema: { - type: "string", - }, - }, - }, - }, - }, - }, + type: "string" + } + } + } + } + } + } }); }); it("should declare all schema correctly (openapi3)", async () => { @@ -1163,12 +1163,12 @@ describe("getSpec()", () => { expect(spec).to.deep.equal({ components: { - schemas: {}, + schemas: {} }, tags: [ { - name: "Controller", - }, + name: "Controller" + } ], paths: { "/": { @@ -1181,16 +1181,16 @@ describe("getSpec()", () => { content: { "*/*": { schema: { - type: "string", - }, - }, + type: "string" + } + } }, - description: "description", - }, - }, - }, - }, - }, + description: "description" + } + } + } + } + } }); }); it("should declare an Array of string (swagger2)", async () => { @@ -1208,8 +1208,8 @@ describe("getSpec()", () => { definitions: {}, tags: [ { - name: "Controller", - }, + name: "Controller" + } ], paths: { "/": { @@ -1223,15 +1223,15 @@ describe("getSpec()", () => { description: "description", schema: { items: { - type: "string", + type: "string" }, - type: "array", - }, - }, - }, - }, - }, - }, + type: "array" + } + } + } + } + } + } }); }); it("should declare an Array of string (openapi3)", async () => { @@ -1247,12 +1247,12 @@ describe("getSpec()", () => { expect(spec).to.deep.equal({ components: { - schemas: {}, + schemas: {} }, tags: [ { - name: "Controller", - }, + name: "Controller" + } ], paths: { "/": { @@ -1266,18 +1266,18 @@ describe("getSpec()", () => { "text/json": { schema: { items: { - type: "string", + type: "string" }, - type: "array", - }, - }, + type: "array" + } + } }, - description: "description", - }, - }, - }, - }, - }, + description: "description" + } + } + } + } + } }); }); it("should declare an Generic of Model (swagger2)", async () => { @@ -1312,16 +1312,16 @@ describe("getSpec()", () => { Product: { properties: { title: { - type: "string", - }, + type: "string" + } }, - type: "object", - }, + type: "object" + } }, tags: [ { - name: "Controller", - }, + name: "Controller" + } ], paths: { "/": { @@ -1337,21 +1337,21 @@ describe("getSpec()", () => { properties: { data: { items: { - $ref: "#/definitions/Product", + $ref: "#/definitions/Product" }, - type: "array", + type: "array" }, totalCount: { - type: "number", - }, + type: "number" + } }, - type: "object", - }, - }, - }, - }, - }, - }, + type: "object" + } + } + } + } + } + } }); }); it("should declare an Generic of Model (openspec3)", async () => { @@ -1391,15 +1391,15 @@ describe("getSpec()", () => { properties: { data: { items: { - $ref: "T", + $ref: "T" }, - type: "array", + type: "array" }, totalCount: { - type: "number", - }, + type: "number" + } }, - type: "object", + type: "object" }); // THEN @@ -1411,17 +1411,17 @@ describe("getSpec()", () => { Product: { properties: { title: { - type: "string", - }, + type: "string" + } }, - type: "object", - }, - }, + type: "object" + } + } }, tags: [ { - name: "Controller", - }, + name: "Controller" + } ], paths: { "/": { @@ -1439,30 +1439,30 @@ describe("getSpec()", () => { items: { properties: { data: { - $ref: "#/components/schemas/Product", + $ref: "#/components/schemas/Product" }, _id: { - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }, - type: "array", + type: "array" }, totalCount: { - type: "number", - }, + type: "number" + } }, - type: "object", - }, - }, + type: "object" + } + } }, - description: "description", - }, - }, - }, - }, - }, + description: "description" + } + } + } + } + } }); }); it("should declare a nested Generics of Model (swagger2)", () => { @@ -1520,16 +1520,16 @@ describe("getSpec()", () => { Product: { properties: { title: { - type: "string", - }, + type: "string" + } }, - type: "object", - }, + type: "object" + } }, tags: [ { - name: "Controller", - }, + name: "Controller" + } ], paths: { "/": { @@ -1546,41 +1546,41 @@ describe("getSpec()", () => { data: { properties: { _id: { - type: "string", + type: "string" }, data: { - $ref: "#/definitions/Product", - }, + $ref: "#/definitions/Product" + } }, - type: "object", + type: "object" }, totalCount: { - type: "number", - }, + type: "number" + } }, - type: "object", - }, - }, - }, - }, - }, - }, + type: "object" + } + } + } + } + } + } }); expect(spec2).to.deep.equal({ definitions: { Article: { properties: { id: { - type: "string", - }, + type: "string" + } }, - type: "object", - }, + type: "object" + } }, tags: [ { - name: "Controller2", - }, + name: "Controller2" + } ], paths: { "/": { @@ -1597,25 +1597,25 @@ describe("getSpec()", () => { data: { properties: { _id: { - type: "string", + type: "string" }, data: { - $ref: "#/definitions/Article", - }, + $ref: "#/definitions/Article" + } }, - type: "object", + type: "object" }, totalCount: { - type: "number", - }, + type: "number" + } }, - type: "object", - }, - }, - }, - }, - }, - }, + type: "object" + } + } + } + } + } + } }); }); it("should declare a nested Generics of Model (openspec3)", async () => { @@ -1660,17 +1660,17 @@ describe("getSpec()", () => { Product: { properties: { title: { - type: "string", - }, + type: "string" + } }, - type: "object", - }, - }, + type: "object" + } + } }, tags: [ { - name: "Controller", - }, + name: "Controller" + } ], paths: { "/": { @@ -1689,29 +1689,29 @@ describe("getSpec()", () => { type: "object", properties: { _id: { - type: "string", + type: "string" }, data: { - $ref: "#/components/schemas/Product", - }, - }, + $ref: "#/components/schemas/Product" + } + } }, - type: "array", + type: "array" }, totalCount: { - type: "number", - }, + type: "number" + } }, - type: "object", - }, - }, + type: "object" + } + } }, - description: "description", - }, - }, - }, - }, - }, + description: "description" + } + } + } + } + } }); }); }); diff --git a/packages/schema/src/utils/getSpec.ts b/packages/schema/src/utils/getSpec.ts index cacdf4ada36..f3ad4561c7e 100644 --- a/packages/schema/src/utils/getSpec.ts +++ b/packages/schema/src/utils/getSpec.ts @@ -59,7 +59,7 @@ export function getSpec(model: Type, options: SpecSerializerOptions = {}) { operationIdFormatter: options.operationIdFormatter || operationIdFormatter(options.operationIdPattern), ...options, root: false, - spec: options.spec, + spec: options.spec }; return get(model, options, () => { @@ -68,7 +68,7 @@ export function getSpec(model: Type, options: SpecSerializerOptions = {}) { const ctrlPath = store.path; const defaultTags = cleanObject({ name: store.schema.getName(), - description: store.schema.get("description"), + description: store.schema.get("description") }); const specJson: any = {paths}; @@ -89,7 +89,7 @@ export function getSpec(model: Type, options: SpecSerializerOptions = {}) { operationStore.parent.schema.get("name") || operationStore.parent.targetName, operationStore.propertyName, path - ), + ) }); } }); @@ -99,7 +99,7 @@ export function getSpec(model: Type, options: SpecSerializerOptions = {}) { if (spec === SpecTypes.OPENAPI) { specJson.components = { - schemas, + schemas }; } else { specJson.definitions = schemas; diff --git a/packages/schema/src/utils/mapHeaders.spec.ts b/packages/schema/src/utils/mapHeaders.spec.ts index e2859c22a0c..82c844ee37a 100644 --- a/packages/schema/src/utils/mapHeaders.spec.ts +++ b/packages/schema/src/utils/mapHeaders.spec.ts @@ -5,54 +5,54 @@ describe("mapHeaders", () => { it("should map headers", () => { expect( mapHeaders({ - key: "value", + key: "value" }) ).to.deep.equal({ key: { example: "value", - type: "string", - }, + type: "string" + } }); expect( mapHeaders({ - key: 1, + key: 1 }) ).to.deep.equal({ key: { example: 1, - type: "number", - }, + type: "number" + } }); expect( mapHeaders({ key: { description: "test", - value: 1, - }, + value: 1 + } }) ).to.deep.equal({ key: { description: "test", example: 1, - type: "number", - }, + type: "number" + } }); expect( mapHeaders({ key: { description: "test", - example: 1, - }, + example: 1 + } }) ).to.deep.equal({ key: { description: "test", example: 1, - type: "number", - }, + type: "number" + } }); }); }); diff --git a/packages/schema/src/utils/mapHeaders.ts b/packages/schema/src/utils/mapHeaders.ts index e7cab842e29..c0c8cbbe2d2 100644 --- a/packages/schema/src/utils/mapHeaders.ts +++ b/packages/schema/src/utils/mapHeaders.ts @@ -12,7 +12,7 @@ export function mapHeaders(headers: JsonHeaders): {[key: string]: JsonHeader} { let type = typeof value; let options: any = { - example: value, + example: value }; if (type === "object") { diff --git a/packages/schema/src/utils/mergeOperation.ts b/packages/schema/src/utils/mergeOperation.ts index fb4b118bb81..136c6354e2b 100644 --- a/packages/schema/src/utils/mergeOperation.ts +++ b/packages/schema/src/utils/mergeOperation.ts @@ -17,8 +17,8 @@ export function mergeOperation(obj: any, operation: any, {rootPath, operationId, operationId: operation.operationId || operationId(path), ...operation, tags: operationTags.map(({name}: any) => name), - parameters, - }, + parameters + } }; tags.push(...operationTags); diff --git a/packages/schema/src/utils/serializeJsonSchema.ts b/packages/schema/src/utils/serializeJsonSchema.ts index 1d1152e0155..a4f6c562fc7 100644 --- a/packages/schema/src/utils/serializeJsonSchema.ts +++ b/packages/schema/src/utils/serializeJsonSchema.ts @@ -33,7 +33,7 @@ export function createRef(value: any, options: JsonSchemaOptions = {}) { return serializeAny(store.schema, { ...options, ...popGenerics(value), - root: false, + root: false }); } @@ -43,7 +43,7 @@ export function createRef(value: any, options: JsonSchemaOptions = {}) { store.schema, mapGenericsOptions({ ...options, - root: false, + root: false }) ); } @@ -51,7 +51,7 @@ export function createRef(value: any, options: JsonSchemaOptions = {}) { const {host = `#/${options.spec === "openapi3" ? "components/schemas" : "definitions"}`} = options; return { - $ref: `${host}/${name}`, + $ref: `${host}/${name}` }; } @@ -144,13 +144,13 @@ export function serializeGenerics(obj: any, options: GenericsContext) { if (generics && obj.$ref) { if (generics.has(obj.$ref)) { const model = { - class: generics.get(obj.$ref), + class: generics.get(obj.$ref) }; if (options.nestedGenerics.length === 0) { return createRef(model, { ...options, - generics: undefined, + generics: undefined }); } @@ -159,7 +159,7 @@ export function serializeGenerics(obj: any, options: GenericsContext) { return serializeJsonSchema(store.schema, { ...options, ...popGenerics(options), - root: false, + root: false }); } } @@ -194,7 +194,7 @@ export function serializeJsonSchema(schema: JsonSchema, options: JsonSchemaOptio ...options, useAlias, schemas, - root: false, + root: false }); } else { value = serializeAny(value, { @@ -203,7 +203,7 @@ export function serializeJsonSchema(schema: JsonSchema, options: JsonSchemaOptio schemas, root: false, genericTypes, - genericLabels: schema.genericLabels, + genericLabels: schema.genericLabels }); } diff --git a/packages/schema/src/utils/toJsonMapCollection.spec.ts b/packages/schema/src/utils/toJsonMapCollection.spec.ts index 7a608a7b75b..98058c1bdb0 100644 --- a/packages/schema/src/utils/toJsonMapCollection.spec.ts +++ b/packages/schema/src/utils/toJsonMapCollection.spec.ts @@ -6,13 +6,13 @@ describe("toJsonMapCollection", () => { it("should transform object to JsonMapCollection", () => { const result = toJsonMapCollection({ test: { - schema: "schema", - }, + schema: "schema" + } }); expect(result).to.deep.eq( new JsonMap({ - test: new JsonMap({schema: "schema"}), + test: new JsonMap({schema: "schema"}) }) ); }); diff --git a/packages/seq/src/SeqModule.ts b/packages/seq/src/SeqModule.ts index 2fd16b8cd08..4b94feaaa5a 100644 --- a/packages/seq/src/SeqModule.ts +++ b/packages/seq/src/SeqModule.ts @@ -5,7 +5,7 @@ import {ISeqSettings} from "./interfaces/ISeqSettings"; @Module({}) export class SeqModule implements AfterRoutesInit { @Constant("seq", { - url: "http://localhost:5341", + url: "http://localhost:5341" }) private config: ISeqSettings; @@ -18,7 +18,7 @@ export class SeqModule implements AfterRoutesInit { type: "seq", levels: ["info", "debug", "trace", "fatal", "error", "warn"], url: this.config.url, - apiKey: this.config.apiKey, + apiKey: this.config.apiKey }); } } diff --git a/packages/seq/src/appenders/SeqAppender.ts b/packages/seq/src/appenders/SeqAppender.ts index b85c362cae9..9f56a6b1e84 100644 --- a/packages/seq/src/appenders/SeqAppender.ts +++ b/packages/seq/src/appenders/SeqAppender.ts @@ -41,9 +41,9 @@ export class SeqAppender extends BaseAppender { createStream({ serverUrl: this.config.url, apiKey: this.config.apiKey, - level: $log.level, - }), - ], + level: $log.level + }) + ] }); } } diff --git a/packages/socketio/src/SocketIOModule.spec.ts b/packages/socketio/src/SocketIOModule.spec.ts index 8b467e7ea00..a743bc16444 100644 --- a/packages/socketio/src/SocketIOModule.spec.ts +++ b/packages/socketio/src/SocketIOModule.spec.ts @@ -34,7 +34,7 @@ describe("SocketIOModule", () => { {token: HttpServer, use: httpServer}, {token: HttpsServer, use: httpsServer}, {token: SocketIOServer, use: socketIOServer}, - {token: SocketIOService, use: socketIOService}, + {token: SocketIOService, use: socketIOService} ]); getWebsocketServicesStub.returns([{provider: "provider"}]); @@ -43,11 +43,11 @@ describe("SocketIOModule", () => { expect(socketIOServer.attach).to.have.been.calledWithExactly(httpServer, { adapter: "adapter", - config: "config", + config: "config" }); expect(socketIOServer.attach).to.have.been.calledWithExactly(httpsServer, { adapter: "adapter", - config: "config", + config: "config" }); expect(getWebsocketServicesStub).to.have.been.calledWithExactly(); @@ -84,7 +84,7 @@ describe("SocketIOModule", () => { {token: HttpServer, use: httpServer}, {token: HttpsServer, use: httpsServer}, {token: SocketIOServer, use: socketIOServer}, - {token: SocketIOService, use: socketIOService}, + {token: SocketIOService, use: socketIOService} ]); getWebsocketServicesStub.returns([{provider: "provider"}]); @@ -92,7 +92,7 @@ describe("SocketIOModule", () => { await socketIOModule.$afterListen(); expect(socketIOServer.attach).to.have.been.calledWithExactly(httpsServer, { - config: "config", + config: "config" }); expect(getWebsocketServicesStub).to.have.been.calledWithExactly(); diff --git a/packages/socketio/src/SocketIOModule.ts b/packages/socketio/src/SocketIOModule.ts index 611f9663dc4..5d82c2fa027 100644 --- a/packages/socketio/src/SocketIOModule.ts +++ b/packages/socketio/src/SocketIOModule.ts @@ -72,7 +72,7 @@ export class SocketIOModule implements AfterListen { inputEvent: handler.eventName, outputEvent: (handler.returns && handler.returns.eventName) || "", outputType: (handler.returns && handler.returns.type) || "", - name: `${nameOf(provider.useClass)}.${handler.methodClassName}`, + name: `${nameOf(provider.useClass)}.${handler.methodClassName}` }); }); } @@ -89,8 +89,8 @@ export class SocketIOModule implements AfterListen { inputEvent: "Input event", outputEvent: "Output event", outputType: "Output type", - name: "Class method", - }, + name: "Class method" + } }); this.injector.logger.info("\n" + str.trim()); diff --git a/packages/socketio/src/class/SocketHandlersBuilder.spec.ts b/packages/socketio/src/class/SocketHandlersBuilder.spec.ts index 267326e7b89..d9b552ad7fa 100644 --- a/packages/socketio/src/class/SocketHandlersBuilder.spec.ts +++ b/packages/socketio/src/class/SocketHandlersBuilder.spec.ts @@ -12,13 +12,13 @@ describe("SocketHandlersBuilder", () => { before(() => { this.provider = { store: { - get: Sinon.stub(), + get: Sinon.stub() }, instance: { $onDisconnect: Sinon.stub(), $onConnection: Sinon.stub(), - $onNamespaceInit: Sinon.stub(), - }, + $onNamespaceInit: Sinon.stub() + } }; this.builder = new SocketHandlersBuilder(this.provider, {} as any, {} as any); @@ -26,8 +26,8 @@ describe("SocketHandlersBuilder", () => { namespace: "/", injectNamespaces: [{propertyKey: "key1"}, {propertyKey: "key2", nsp: "/test"}], handlers: { - $onDisconnect: {}, - }, + $onDisconnect: {} + } }; this.nsps = new Map(); @@ -43,22 +43,22 @@ describe("SocketHandlersBuilder", () => { handlers: { $onConnection: { eventName: "connection", - methodClassName: "$onConnection", + methodClassName: "$onConnection" }, $onDisconnect: { eventName: "disconnect", - methodClassName: "$onDisconnect", - }, + methodClassName: "$onDisconnect" + } }, injectNamespaces: [ { - propertyKey: "key1", + propertyKey: "key1" }, { nsp: "/test", - propertyKey: "key2", - }, - ], + propertyKey: "key2" + } + ] }); }); @@ -87,15 +87,15 @@ describe("SocketHandlersBuilder", () => { before(() => { this.provider = { store: { - get: Sinon.stub(), + get: Sinon.stub() }, instance: { - $onConnection: Sinon.stub(), - }, + $onConnection: Sinon.stub() + } }; this.nspStub = {nsp: "nsp"}; this.socketStub = { - on: Sinon.stub(), + on: Sinon.stub() }; this.builder = new SocketHandlersBuilder(this.provider, {} as any, {} as any); @@ -103,9 +103,9 @@ describe("SocketHandlersBuilder", () => { injectNamespace: "nsp", handlers: { $onConnection: { - eventName: "onConnection", - }, - }, + eventName: "onConnection" + } + } }; this.invokeStub = Sinon.stub(this.builder, "invoke"); @@ -130,7 +130,7 @@ describe("SocketHandlersBuilder", () => { {eventName: "onConnection"}, { socket: this.socketStub, - nsp: this.nspStub, + nsp: this.nspStub } ); }); @@ -139,15 +139,15 @@ describe("SocketHandlersBuilder", () => { before(() => { this.provider = { store: { - get: Sinon.stub(), + get: Sinon.stub() }, instance: { - $onDisconnect: Sinon.stub(), - }, + $onDisconnect: Sinon.stub() + } }; this.nspStub = {nsp: "nsp"}; this.socketStub = { - on: Sinon.stub(), + on: Sinon.stub() }; this.builder = new SocketHandlersBuilder(this.provider, {} as any, {} as any); @@ -155,9 +155,9 @@ describe("SocketHandlersBuilder", () => { injectNamespace: "nsp", handlers: { $onDisconnect: { - eventName: "onDisconnect", - }, - }, + eventName: "onDisconnect" + } + } }; this.invokeStub = Sinon.stub(this.builder, "invoke"); @@ -176,7 +176,7 @@ describe("SocketHandlersBuilder", () => { {eventName: "onDisconnect"}, { socket: this.socketStub, - nsp: this.nspStub, + nsp: this.nspStub } ); }); @@ -186,11 +186,11 @@ describe("SocketHandlersBuilder", () => { before(() => { this.provider = { store: { - get: Sinon.stub(), + get: Sinon.stub() }, instance: { - _nspSession: new Map(), - }, + _nspSession: new Map() + } }; this.builder = new SocketHandlersBuilder(this.provider, {} as any, {} as any); @@ -206,11 +206,11 @@ describe("SocketHandlersBuilder", () => { before(() => { this.provider = { store: { - get: Sinon.stub(), + get: Sinon.stub() }, instance: { - _nspSession: new Map(), - }, + _nspSession: new Map() + } }; this.provider.instance._nspSession.set("id", new Map()); @@ -229,17 +229,17 @@ describe("SocketHandlersBuilder", () => { this.metadata = { handlers: { testHandler: { - eventName: "eventName", - }, - }, + eventName: "eventName" + } + } }; this.provider = { store: { - get: Sinon.stub().returns(this.metadata), - }, + get: Sinon.stub().returns(this.metadata) + } }; this.socketStub = { - on: Sinon.stub(), + on: Sinon.stub() }; const builder: any = new SocketHandlersBuilder(this.provider, {} as any, {} as any); this.runQueueStub = Sinon.stub(builder, "runQueue"); @@ -267,19 +267,19 @@ describe("SocketHandlersBuilder", () => { parameters: ["param"], returns: { eventName: "returnEventName", - type: "type", - }, - }, - }, + type: "type" + } + } + } }; this.provider = { store: { - get: Sinon.stub().returns(this.metadata), + get: Sinon.stub().returns(this.metadata) }, instance: { - testHandler: Sinon.stub().returns("response"), - }, + testHandler: Sinon.stub().returns("response") + } }; const builder: any = new SocketHandlersBuilder(this.provider, {} as any, {} as any); @@ -290,7 +290,7 @@ describe("SocketHandlersBuilder", () => { it("should call buildParameters", () => { expect(this.buildParametersStub).to.have.been.calledWithExactly(["param"], { - scope: "scope", + scope: "scope" }); }); @@ -304,11 +304,11 @@ describe("SocketHandlersBuilder", () => { before(() => { this.provider = { store: { - get: Sinon.stub().returns(this.metadata), + get: Sinon.stub().returns(this.metadata) }, instance: { - testHandler: Sinon.stub().returns("response"), - }, + testHandler: Sinon.stub().returns("response") + } }; const builder: any = new SocketHandlersBuilder(this.provider, {} as any, {} as any); @@ -316,8 +316,8 @@ describe("SocketHandlersBuilder", () => { this.result = builder.buildParameters( { 0: { - filter: SocketFilters.ARGS, - }, + filter: SocketFilters.ARGS + } }, {args: ["mapValue"]} ); @@ -332,11 +332,11 @@ describe("SocketHandlersBuilder", () => { before(() => { this.provider = { store: { - get: Sinon.stub().returns(this.metadata), + get: Sinon.stub().returns(this.metadata) }, instance: { - testHandler: Sinon.stub().returns("response"), - }, + testHandler: Sinon.stub().returns("response") + } }; const builder: any = new SocketHandlersBuilder(this.provider, {} as any, {} as any); @@ -345,8 +345,8 @@ describe("SocketHandlersBuilder", () => { { 0: { filter: SocketFilters.ARGS, - mapIndex: 0, - }, + mapIndex: 0 + } }, {args: ["mapValue"]} ); @@ -361,11 +361,11 @@ describe("SocketHandlersBuilder", () => { before(() => { this.provider = { store: { - get: Sinon.stub().returns(this.metadata), + get: Sinon.stub().returns(this.metadata) }, instance: { - testHandler: Sinon.stub().returns("response"), - }, + testHandler: Sinon.stub().returns("response") + } }; const builder: any = new SocketHandlersBuilder(this.provider, {} as any, {} as any); @@ -373,8 +373,8 @@ describe("SocketHandlersBuilder", () => { this.result = builder.buildParameters( { 0: { - filter: SocketFilters.SOCKET, - }, + filter: SocketFilters.SOCKET + } }, {socket: "socket"} ); @@ -389,11 +389,11 @@ describe("SocketHandlersBuilder", () => { before(() => { this.provider = { store: { - get: Sinon.stub().returns(this.metadata), + get: Sinon.stub().returns(this.metadata) }, instance: { - testHandler: Sinon.stub().returns("response"), - }, + testHandler: Sinon.stub().returns("response") + } }; const builder: any = new SocketHandlersBuilder(this.provider, {} as any, {} as any); @@ -401,8 +401,8 @@ describe("SocketHandlersBuilder", () => { this.result = builder.buildParameters( { 0: { - filter: SocketFilters.NSP, - }, + filter: SocketFilters.NSP + } }, {nsp: "nsp"} ); @@ -417,11 +417,11 @@ describe("SocketHandlersBuilder", () => { before(() => { this.provider = { store: { - get: Sinon.stub().returns(this.metadata), + get: Sinon.stub().returns(this.metadata) }, instance: { - testHandler: Sinon.stub().returns("response"), - }, + testHandler: Sinon.stub().returns("response") + } }; const builder: any = new SocketHandlersBuilder(this.provider, {} as any, {} as any); @@ -429,8 +429,8 @@ describe("SocketHandlersBuilder", () => { this.result = builder.buildParameters( { 0: { - filter: SocketFilters.ERR, - }, + filter: SocketFilters.ERR + } }, {error: "error"} ); @@ -445,11 +445,11 @@ describe("SocketHandlersBuilder", () => { before(() => { this.provider = { store: { - get: Sinon.stub().returns(this.metadata), + get: Sinon.stub().returns(this.metadata) }, instance: { - testHandler: Sinon.stub().returns("response"), - }, + testHandler: Sinon.stub().returns("response") + } }; const builder: any = new SocketHandlersBuilder(this.provider, {} as any, {} as any); @@ -457,8 +457,8 @@ describe("SocketHandlersBuilder", () => { this.result = builder.buildParameters( { 0: { - filter: SocketFilters.EVENT_NAME, - }, + filter: SocketFilters.EVENT_NAME + } }, {eventName: "eventName"} ); @@ -476,12 +476,12 @@ describe("SocketHandlersBuilder", () => { this.provider = { store: { - get: Sinon.stub().returns(this.metadata), + get: Sinon.stub().returns(this.metadata) }, instance: { testHandler: Sinon.stub().returns("response"), - _nspSession: map, - }, + _nspSession: map + } }; const builder: any = new SocketHandlersBuilder(this.provider, {} as any, {} as any); @@ -489,8 +489,8 @@ describe("SocketHandlersBuilder", () => { this.result = builder.buildParameters( { 0: { - filter: SocketFilters.SESSION, - }, + filter: SocketFilters.SESSION + } }, {socket: {id: "id"}} ); @@ -506,15 +506,15 @@ describe("SocketHandlersBuilder", () => { describe("when BROADCAST", () => { before(() => { this.nspStub = { - emit: Sinon.stub(), + emit: Sinon.stub() }; (SocketHandlersBuilder as any).bindResponseMiddleware( { returns: { type: SocketReturnsTypes.BROADCAST, - eventName: "eventName", - }, + eventName: "eventName" + } }, {nsp: this.nspStub} )({response: "response"}); @@ -527,16 +527,16 @@ describe("SocketHandlersBuilder", () => { before(() => { this.socketStub = { broadcast: { - emit: Sinon.stub(), - }, + emit: Sinon.stub() + } }; (SocketHandlersBuilder as any).bindResponseMiddleware( { returns: { type: SocketReturnsTypes.BROADCAST_OTHERS, - eventName: "eventName", - }, + eventName: "eventName" + } }, {socket: this.socketStub} )({response: "response"}); @@ -549,15 +549,15 @@ describe("SocketHandlersBuilder", () => { describe("when EMIT", () => { before(() => { this.socketStub = { - emit: Sinon.stub(), + emit: Sinon.stub() }; (SocketHandlersBuilder as any).bindResponseMiddleware( { returns: { type: SocketReturnsTypes.EMIT, - eventName: "eventName", - }, + eventName: "eventName" + } }, {socket: this.socketStub} )({response: "response"}); @@ -574,16 +574,16 @@ describe("SocketHandlersBuilder", () => { store: { get: Sinon.stub().returns({ useBefore: [{target: "target before global"}], - useAfter: [{target: "target after global"}], - }), + useAfter: [{target: "target after global"}] + }) }, - instance: {instance: "instance"}, + instance: {instance: "instance"} }; this.handlerMetadata = { eventName: "eventName", useBefore: [{target: "target before"}], - useAfter: [{target: "target after"}], + useAfter: [{target: "target after"}] }; this.bindResponseMiddlewareStub = Sinon.stub(SocketHandlersBuilder as any, "bindResponseMiddleware"); @@ -614,7 +614,7 @@ describe("SocketHandlersBuilder", () => { eventName: "eventName", args: ["arg1"], socket: "socket", - nsp: "nsp", + nsp: "nsp" }, Sinon.match.instanceOf(Promise) ); @@ -627,7 +627,7 @@ describe("SocketHandlersBuilder", () => { eventName: "eventName", args: ["arg1"], socket: "socket", - nsp: "nsp", + nsp: "nsp" }, Sinon.match.instanceOf(Promise) ); @@ -638,7 +638,7 @@ describe("SocketHandlersBuilder", () => { eventName: "eventName", args: ["arg1"], socket: "socket", - nsp: "nsp", + nsp: "nsp" }); }); @@ -647,7 +647,7 @@ describe("SocketHandlersBuilder", () => { eventName: "eventName", args: ["arg1"], socket: "socket", - nsp: "nsp", + nsp: "nsp" }); }); @@ -658,7 +658,7 @@ describe("SocketHandlersBuilder", () => { eventName: "eventName", args: ["arg1"], socket: "socket", - nsp: "nsp", + nsp: "nsp" }, Sinon.match.instanceOf(Promise) ); @@ -671,7 +671,7 @@ describe("SocketHandlersBuilder", () => { eventName: "eventName", args: ["arg1"], socket: "socket", - nsp: "nsp", + nsp: "nsp" }, Sinon.match.instanceOf(Promise) ); @@ -682,7 +682,7 @@ describe("SocketHandlersBuilder", () => { eventName: "eventName", args: ["arg1"], socket: "socket", - nsp: "nsp", + nsp: "nsp" }); }); }); @@ -696,14 +696,14 @@ describe("SocketHandlersBuilder", () => { this.instance = new Test(); this.provider = { store: { - get: Sinon.stub(), - }, + get: Sinon.stub() + } }; Store.from(Test).set("socketIO", { handlers: { - use: "use", - }, + use: "use" + } }); this.getStub = Sinon.stub(injector as any, "getProvider").returns(false); @@ -751,21 +751,21 @@ describe("SocketHandlersBuilder", () => { const instance = new Test(); const provider = { store: { - get: Sinon.stub(), - }, + get: Sinon.stub() + } }; Store.from(Test).set("socketIO", { type: ProviderType.MIDDLEWARE, handlers: { - use: "use", - }, + use: "use" + } }); // @ts-ignore injector.getProvider.returns({ instance, - type: ProviderType.MIDDLEWARE, + type: ProviderType.MIDDLEWARE }); const scope = {scope: "scope", args: undefined}; @@ -805,22 +805,22 @@ describe("SocketHandlersBuilder", () => { const instance = new Test(); const provider = { store: { - get: Sinon.stub(), - }, + get: Sinon.stub() + } }; Store.from(Test).set("socketIO", { type: ProviderType.MIDDLEWARE, error: true, handlers: { - use: "use", - }, + use: "use" + } }); // @ts-ignore injector.getProvider.returns({ instance, - type: ProviderType.MIDDLEWARE, + type: ProviderType.MIDDLEWARE }); const scope = {scope: "scope", args: undefined}; @@ -843,8 +843,8 @@ describe("SocketHandlersBuilder", () => { before(() => { this.provider = { store: { - get: Sinon.stub(), - }, + get: Sinon.stub() + } }; const parameters: any[] = [ { @@ -852,15 +852,15 @@ describe("SocketHandlersBuilder", () => { useConverter: true, mapIndex: 0, type: String, - collectionType: Array, - }, + collectionType: Array + } ]; const scope: any = { - args: ["any"], + args: ["any"] }; this.converterService = { - deserialize: Sinon.stub().returns("value"), + deserialize: Sinon.stub().returns("value") }; this.builder = new SocketHandlersBuilder(this.provider, this.converterService as any, {} as any); diff --git a/packages/socketio/src/class/SocketHandlersBuilder.ts b/packages/socketio/src/class/SocketHandlersBuilder.ts index 8f3c10fea85..2439e462fd9 100644 --- a/packages/socketio/src/class/SocketHandlersBuilder.ts +++ b/packages/socketio/src/class/SocketHandlersBuilder.ts @@ -63,7 +63,7 @@ export class SocketHandlersBuilder { handlers[hook] = Object.assign(handlers[hook] || {}, { eventName, - methodClassName: hook, + methodClassName: hook }); this.socketProviderMetadata.handlers = handlers; @@ -146,7 +146,7 @@ export class SocketHandlersBuilder { args, socket, nsp, - eventName: handlerMetadata.eventName, + eventName: handlerMetadata.eventName }; promise = promise.then(() => this.deserialize(handlerMetadata, scope)); diff --git a/packages/socketio/src/decorators/args.spec.ts b/packages/socketio/src/decorators/args.spec.ts index e1ba9b5b55a..9675b7bac28 100644 --- a/packages/socketio/src/decorators/args.spec.ts +++ b/packages/socketio/src/decorators/args.spec.ts @@ -18,11 +18,11 @@ describe("Args", () => { parameters: { "0": { filter: "args", - useConverter: false, - }, - }, - }, - }, + useConverter: false + } + } + } + } }); }); }); @@ -45,11 +45,11 @@ describe("Args", () => { filter: "args", mapIndex: 1, type: undefined, - useConverter: true, - }, - }, - }, - }, + useConverter: true + } + } + } + } }); }); }); diff --git a/packages/socketio/src/decorators/args.ts b/packages/socketio/src/decorators/args.ts index 03957c33047..d8dacd092f7 100644 --- a/packages/socketio/src/decorators/args.ts +++ b/packages/socketio/src/decorators/args.ts @@ -34,7 +34,7 @@ export function Args(mapIndex?: number, useType?: any): any { const type = Metadata.getParamTypes(target, propertyKey)[index]; const param = { filter: SocketFilters.ARGS, - useConverter: false, + useConverter: false }; if (mapIndex !== undefined) { @@ -42,7 +42,7 @@ export function Args(mapIndex?: number, useType?: any): any { mapIndex, useConverter: true, type: useType || type, - collectionType: isCollection(type) ? type : undefined, + collectionType: isCollection(type) ? type : undefined }); } @@ -50,10 +50,10 @@ export function Args(mapIndex?: number, useType?: any): any { handlers: { [propertyKey]: { parameters: { - [index]: param, - }, - }, - }, + [index]: param + } + } + } }); }; } diff --git a/packages/socketio/src/decorators/broadcast.spec.ts b/packages/socketio/src/decorators/broadcast.spec.ts index 2ce72e860b6..6f63ff1d078 100644 --- a/packages/socketio/src/decorators/broadcast.spec.ts +++ b/packages/socketio/src/decorators/broadcast.spec.ts @@ -16,10 +16,10 @@ describe("Broadcast", () => { test: { returns: { eventName: "eventName", - type: "broadcast", - }, - }, - }, + type: "broadcast" + } + } + } }); }); }); diff --git a/packages/socketio/src/decorators/broadcastOthers.spec.ts b/packages/socketio/src/decorators/broadcastOthers.spec.ts index ee37a191f7c..571e6e0d84d 100644 --- a/packages/socketio/src/decorators/broadcastOthers.spec.ts +++ b/packages/socketio/src/decorators/broadcastOthers.spec.ts @@ -16,10 +16,10 @@ describe("BroadcastOthers", () => { test: { returns: { eventName: "eventName", - type: "broadcastOthers", - }, - }, - }, + type: "broadcastOthers" + } + } + } }); }); }); diff --git a/packages/socketio/src/decorators/emit.spec.ts b/packages/socketio/src/decorators/emit.spec.ts index 785afd9ed12..90dab0ec374 100644 --- a/packages/socketio/src/decorators/emit.spec.ts +++ b/packages/socketio/src/decorators/emit.spec.ts @@ -16,10 +16,10 @@ describe("Emit", () => { test: { returns: { eventName: "eventName", - type: "emit", - }, - }, - }, + type: "emit" + } + } + } }); }); }); diff --git a/packages/socketio/src/decorators/input.spec.ts b/packages/socketio/src/decorators/input.spec.ts index 87bdf53269a..469b5486263 100644 --- a/packages/socketio/src/decorators/input.spec.ts +++ b/packages/socketio/src/decorators/input.spec.ts @@ -15,9 +15,9 @@ describe("Input", () => { handlers: { test: { eventName: "eventName", - methodClassName: "test", - }, - }, + methodClassName: "test" + } + } }); }); }); diff --git a/packages/socketio/src/decorators/input.ts b/packages/socketio/src/decorators/input.ts index bac109d8937..24ab3061e7c 100644 --- a/packages/socketio/src/decorators/input.ts +++ b/packages/socketio/src/decorators/input.ts @@ -25,9 +25,9 @@ export function Input(eventName: string) { handlers: { [propertyKey]: { eventName, - methodClassName: propertyKey, - }, - }, + methodClassName: propertyKey + } + } }); }; } diff --git a/packages/socketio/src/decorators/inputAndBroadcast.spec.ts b/packages/socketio/src/decorators/inputAndBroadcast.spec.ts index 969aee23493..02c9f71dc23 100644 --- a/packages/socketio/src/decorators/inputAndBroadcast.spec.ts +++ b/packages/socketio/src/decorators/inputAndBroadcast.spec.ts @@ -18,10 +18,10 @@ describe("InputAndBroadcast", () => { methodClassName: "test", returns: { eventName: "eventName", - type: "broadcast", - }, - }, - }, + type: "broadcast" + } + } + } }); }); }); diff --git a/packages/socketio/src/decorators/inputAndBroadcastOthers.spec.ts b/packages/socketio/src/decorators/inputAndBroadcastOthers.spec.ts index 787429b10a5..67df70deb77 100644 --- a/packages/socketio/src/decorators/inputAndBroadcastOthers.spec.ts +++ b/packages/socketio/src/decorators/inputAndBroadcastOthers.spec.ts @@ -18,10 +18,10 @@ describe("InputAndBroadcastOthers", () => { methodClassName: "test", returns: { eventName: "eventName", - type: "broadcastOthers", - }, - }, - }, + type: "broadcastOthers" + } + } + } }); }); }); diff --git a/packages/socketio/src/decorators/inputAndEmit.spec.ts b/packages/socketio/src/decorators/inputAndEmit.spec.ts index 3fecf9887e9..5084563b5c3 100644 --- a/packages/socketio/src/decorators/inputAndEmit.spec.ts +++ b/packages/socketio/src/decorators/inputAndEmit.spec.ts @@ -18,10 +18,10 @@ describe("InputAndEmit", () => { methodClassName: "test", returns: { eventName: "eventName", - type: "emit", - }, - }, - }, + type: "emit" + } + } + } }); }); }); diff --git a/packages/socketio/src/decorators/nsp.spec.ts b/packages/socketio/src/decorators/nsp.spec.ts index 91f672052f6..3a49c545d54 100644 --- a/packages/socketio/src/decorators/nsp.spec.ts +++ b/packages/socketio/src/decorators/nsp.spec.ts @@ -18,11 +18,11 @@ describe("Nsp", () => { parameters: { "0": { filter: "nsp", - mapIndex: undefined, - }, - }, - }, - }, + mapIndex: undefined + } + } + } + } }); }); }); @@ -37,7 +37,7 @@ describe("Nsp", () => { it("should set metadata", () => { expect(this.store.get("socketIO")).to.deep.eq({ - injectNamespaces: [{propertyKey: "test"}], + injectNamespaces: [{propertyKey: "test"}] }); }); }); @@ -54,7 +54,7 @@ describe("Nsp", () => { it("should set metadata", () => { expect(this.store.get("socketIO")).to.deep.eq({ - injectNamespaces: [{propertyKey: "property", nsp: "/test"}], + injectNamespaces: [{propertyKey: "property", nsp: "/test"}] }); }); }); diff --git a/packages/socketio/src/decorators/nsp.ts b/packages/socketio/src/decorators/nsp.ts index 710f3a10b1c..6a77d54bb43 100644 --- a/packages/socketio/src/decorators/nsp.ts +++ b/packages/socketio/src/decorators/nsp.ts @@ -75,14 +75,14 @@ export function Namespace(target: any, propertyKey?: string, index?: number): an return (target: any, propertyKey: string) => { Store.from(target).merge("socketIO", { - injectNamespaces: [{propertyKey, nsp}], + injectNamespaces: [{propertyKey, nsp}] }); }; } if (index === undefined) { Store.from(target).merge("socketIO", { - injectNamespaces: [{propertyKey}], + injectNamespaces: [{propertyKey}] }); return; diff --git a/packages/socketio/src/decorators/socket.spec.ts b/packages/socketio/src/decorators/socket.spec.ts index 235aa01e548..289b0f0e499 100644 --- a/packages/socketio/src/decorators/socket.spec.ts +++ b/packages/socketio/src/decorators/socket.spec.ts @@ -17,11 +17,11 @@ describe("Socket", () => { parameters: { "0": { filter: "socket", - mapIndex: undefined, - }, - }, - }, - }, + mapIndex: undefined + } + } + } + } }); }); }); diff --git a/packages/socketio/src/decorators/socketErr.spec.ts b/packages/socketio/src/decorators/socketErr.spec.ts index 3f0802bd5ec..7368e1fb8e1 100644 --- a/packages/socketio/src/decorators/socketErr.spec.ts +++ b/packages/socketio/src/decorators/socketErr.spec.ts @@ -17,11 +17,11 @@ describe("@SocketErr", () => { parameters: { "0": { filter: "error", - mapIndex: undefined, - }, - }, - }, - }, + mapIndex: undefined + } + } + } + } }); }); }); diff --git a/packages/socketio/src/decorators/socketEventName.spec.ts b/packages/socketio/src/decorators/socketEventName.spec.ts index 1f6a7c54c18..fd72cf984ba 100644 --- a/packages/socketio/src/decorators/socketEventName.spec.ts +++ b/packages/socketio/src/decorators/socketEventName.spec.ts @@ -17,11 +17,11 @@ describe("@SocketEventName", () => { parameters: { "0": { filter: "eventName", - mapIndex: undefined, - }, - }, - }, - }, + mapIndex: undefined + } + } + } + } }); }); }); diff --git a/packages/socketio/src/decorators/socketFilter.ts b/packages/socketio/src/decorators/socketFilter.ts index f84d7ad33da..500231cf4d5 100644 --- a/packages/socketio/src/decorators/socketFilter.ts +++ b/packages/socketio/src/decorators/socketFilter.ts @@ -16,10 +16,10 @@ export function SocketFilter(filter: SocketFilters, mapIndex?: number) { parameters: { [index]: { filter, - mapIndex, - }, - }, - }, - }, + mapIndex + } + } + } + } }); } diff --git a/packages/socketio/src/decorators/socketMiddleware.spec.ts b/packages/socketio/src/decorators/socketMiddleware.spec.ts index 65b6b60681d..6e72a45bd03 100644 --- a/packages/socketio/src/decorators/socketMiddleware.spec.ts +++ b/packages/socketio/src/decorators/socketMiddleware.spec.ts @@ -24,9 +24,9 @@ describe("@SocketMiddleware", () => { type: SocketProviderTypes.MIDDLEWARE, handlers: { use: { - methodClassName: "use", - }, - }, + methodClassName: "use" + } + } }); }); diff --git a/packages/socketio/src/decorators/socketMiddleware.ts b/packages/socketio/src/decorators/socketMiddleware.ts index dcbc48c31ca..47a561f72cd 100644 --- a/packages/socketio/src/decorators/socketMiddleware.ts +++ b/packages/socketio/src/decorators/socketMiddleware.ts @@ -61,9 +61,9 @@ export function SocketMiddleware(): Function { type: SocketProviderTypes.MIDDLEWARE, handlers: { use: { - methodClassName: "use", - }, - }, + methodClassName: "use" + } + } }); return Middleware()(target); diff --git a/packages/socketio/src/decorators/socketMiddlewareError.spec.ts b/packages/socketio/src/decorators/socketMiddlewareError.spec.ts index b85ba853ad4..8795950ddef 100644 --- a/packages/socketio/src/decorators/socketMiddlewareError.spec.ts +++ b/packages/socketio/src/decorators/socketMiddlewareError.spec.ts @@ -28,9 +28,9 @@ describe("@SocketMiddlewareError", () => { error: true, handlers: { use: { - methodClassName: "use", - }, - }, + methodClassName: "use" + } + } }); expect(common.Middleware).to.have.been.calledWithExactly(); diff --git a/packages/socketio/src/decorators/socketMiddlewareError.ts b/packages/socketio/src/decorators/socketMiddlewareError.ts index a8f63093818..b07e6bf9343 100644 --- a/packages/socketio/src/decorators/socketMiddlewareError.ts +++ b/packages/socketio/src/decorators/socketMiddlewareError.ts @@ -59,9 +59,9 @@ export function SocketMiddlewareError(): Function { handlers: { use: { - methodClassName: "use", - }, - }, + methodClassName: "use" + } + } }); return Middleware()(target); diff --git a/packages/socketio/src/decorators/socketReturns.ts b/packages/socketio/src/decorators/socketReturns.ts index 42956a2f973..ffccd05d028 100644 --- a/packages/socketio/src/decorators/socketReturns.ts +++ b/packages/socketio/src/decorators/socketReturns.ts @@ -15,10 +15,10 @@ export function SocketReturns(eventName: string, type: SocketReturnsTypes) { [propertyKey]: { returns: { eventName, - type, - }, - }, - }, + type + } + } + } }); }; } diff --git a/packages/socketio/src/decorators/socketService.spec.ts b/packages/socketio/src/decorators/socketService.spec.ts index b807fe87342..e4f1f517ad1 100644 --- a/packages/socketio/src/decorators/socketService.spec.ts +++ b/packages/socketio/src/decorators/socketService.spec.ts @@ -4,7 +4,7 @@ import * as Sinon from "sinon"; const registerSocketService: any = Sinon.stub(); const {SocketService} = require("proxyquire")("../../src/decorators/socketService", { - "../registries/SocketServiceRegistry": {registerSocketService}, + "../registries/SocketServiceRegistry": {registerSocketService} }); describe("SocketService", () => { @@ -22,7 +22,7 @@ describe("SocketService", () => { it("should set metadata", () => { expect(this.store.get("socketIO")).to.deep.eq({ namespace: "/namespace", - type: "service", + type: "service" }); }); @@ -44,7 +44,7 @@ describe("SocketService", () => { it("should set metadata", () => { expect(this.store.get("socketIO")).to.deep.eq({ namespace: "/", - type: "service", + type: "service" }); }); it("should call socketServiceRegistry", () => { diff --git a/packages/socketio/src/decorators/socketSession.spec.ts b/packages/socketio/src/decorators/socketSession.spec.ts index 369c4b7fc76..97abcffbc11 100644 --- a/packages/socketio/src/decorators/socketSession.spec.ts +++ b/packages/socketio/src/decorators/socketSession.spec.ts @@ -17,11 +17,11 @@ describe("SocketSession", () => { parameters: { "0": { filter: "session", - mapIndex: undefined, - }, - }, - }, - }, + mapIndex: undefined + } + } + } + } }); }); }); diff --git a/packages/socketio/src/decorators/socketUseAfter.spec.ts b/packages/socketio/src/decorators/socketUseAfter.spec.ts index 094b2603734..14133c5faaa 100644 --- a/packages/socketio/src/decorators/socketUseAfter.spec.ts +++ b/packages/socketio/src/decorators/socketUseAfter.spec.ts @@ -13,7 +13,7 @@ describe("@SocketUseAfter", () => { it("should store metadata", () => { expect(Store.from(Test).get("socketIO")).to.deep.eq({ - useAfter: [this.middleware], + useAfter: [this.middleware] }); }); }); @@ -30,9 +30,9 @@ describe("@SocketUseAfter", () => { expect(Store.from(Test).get("socketIO")).to.deep.eq({ handlers: { test: { - useAfter: [this.middleware], - }, - }, + useAfter: [this.middleware] + } + } }); }); }); diff --git a/packages/socketio/src/decorators/socketUseAfter.ts b/packages/socketio/src/decorators/socketUseAfter.ts index cbe83eb5642..8193a52bd35 100644 --- a/packages/socketio/src/decorators/socketUseAfter.ts +++ b/packages/socketio/src/decorators/socketUseAfter.ts @@ -56,13 +56,13 @@ export function SocketUseAfter(...middlewares: Type[]) { Store.from(target).merge("socketIO", { handlers: { [propertyKey]: { - useAfter: middlewares, - }, - }, + useAfter: middlewares + } + } }); } else { Store.from(target).merge("socketIO", { - useAfter: middlewares, + useAfter: middlewares }); } }; diff --git a/packages/socketio/src/decorators/socketUseBefore.spec.ts b/packages/socketio/src/decorators/socketUseBefore.spec.ts index f9a79d3624c..c2910c10d3d 100644 --- a/packages/socketio/src/decorators/socketUseBefore.spec.ts +++ b/packages/socketio/src/decorators/socketUseBefore.spec.ts @@ -13,7 +13,7 @@ describe("@SocketUseBefore", () => { it("should store metadata", () => { expect(Store.from(Test).get("socketIO")).to.deep.eq({ - useBefore: [this.middleware], + useBefore: [this.middleware] }); }); }); @@ -30,9 +30,9 @@ describe("@SocketUseBefore", () => { expect(Store.from(Test).get("socketIO")).to.deep.eq({ handlers: { test: { - useBefore: [this.middleware], - }, - }, + useBefore: [this.middleware] + } + } }); }); }); diff --git a/packages/socketio/src/decorators/socketUseBefore.ts b/packages/socketio/src/decorators/socketUseBefore.ts index 6458e31e43d..a34fdbb3810 100644 --- a/packages/socketio/src/decorators/socketUseBefore.ts +++ b/packages/socketio/src/decorators/socketUseBefore.ts @@ -60,13 +60,13 @@ export function SocketUseBefore(...middlewares: Type[]) { Store.from(target).merge("socketIO", { handlers: { [propertyKey]: { - useBefore: middlewares, - }, - }, + useBefore: middlewares + } + } }); } else { Store.from(target).merge("socketIO", { - useBefore: middlewares, + useBefore: middlewares }); } }; diff --git a/packages/socketio/src/interfaces/ISocketProviderMetadata.ts b/packages/socketio/src/interfaces/ISocketProviderMetadata.ts index d09a8a33923..9a384094dbe 100644 --- a/packages/socketio/src/interfaces/ISocketProviderMetadata.ts +++ b/packages/socketio/src/interfaces/ISocketProviderMetadata.ts @@ -5,7 +5,7 @@ import {ISocketHandlerMetadata} from "./ISocketHandlerMetadata"; */ export enum SocketProviderTypes { SERVICE = "service", - MIDDLEWARE = "middleware", + MIDDLEWARE = "middleware" } /** diff --git a/packages/socketio/src/interfaces/SocketFilters.ts b/packages/socketio/src/interfaces/SocketFilters.ts index 979b4d9bf20..9a96557580e 100644 --- a/packages/socketio/src/interfaces/SocketFilters.ts +++ b/packages/socketio/src/interfaces/SocketFilters.ts @@ -7,5 +7,5 @@ export enum SocketFilters { EVENT_NAME = "eventName", NSP = "nsp", SESSION = "session", - ERR = "error", + ERR = "error" } diff --git a/packages/socketio/src/interfaces/SocketReturnsTypes.ts b/packages/socketio/src/interfaces/SocketReturnsTypes.ts index 41570995f89..661f32bb152 100644 --- a/packages/socketio/src/interfaces/SocketReturnsTypes.ts +++ b/packages/socketio/src/interfaces/SocketReturnsTypes.ts @@ -4,5 +4,5 @@ export enum SocketReturnsTypes { BROADCAST = "broadcast", BROADCAST_OTHERS = "broadcastOthers", - EMIT = "emit", + EMIT = "emit" } diff --git a/packages/socketio/src/registries/SocketServiceRegistry.ts b/packages/socketio/src/registries/SocketServiceRegistry.ts index ba20497ea39..c9eaa41d100 100644 --- a/packages/socketio/src/registries/SocketServiceRegistry.ts +++ b/packages/socketio/src/registries/SocketServiceRegistry.ts @@ -11,7 +11,7 @@ export const PROVIDER_TYPE_SOCKET_SERVICE = "socketService"; */ // tslint:disable-next-line: variable-name export const SocketServiceRegistry: TypedProvidersRegistry = GlobalProviders.createRegistry(PROVIDER_TYPE_SOCKET_SERVICE, Provider, { - injectable: true, + injectable: true }); /** * Add a new service in the `ProviderRegistry`. This service will be built when `InjectorService` will be loaded. diff --git a/packages/socketio/src/services/SocketIOService.spec.ts b/packages/socketio/src/services/SocketIOService.spec.ts index fb4edf5055b..8736380b650 100644 --- a/packages/socketio/src/services/SocketIOService.spec.ts +++ b/packages/socketio/src/services/SocketIOService.spec.ts @@ -14,17 +14,17 @@ describe("SocketIOService", () => { before( PlatformTest.inject([InjectorService], (injector: InjectorService) => { namespace = { - on: Sinon.stub(), + on: Sinon.stub() }; ioStub = { - of: Sinon.stub().returns(namespace), + of: Sinon.stub().returns(namespace) }; instance = { onConnection: Sinon.stub(), - onDisconnect: Sinon.stub(), + onDisconnect: Sinon.stub() }; socket = { - on: Sinon.stub(), + on: Sinon.stub() }; const service = new SocketIOService(injector, ioStub, {} as any); diff --git a/packages/socketio/test/app/Server.ts b/packages/socketio/test/app/Server.ts index 11f72f45193..3c5b242f984 100644 --- a/packages/socketio/test/app/Server.ts +++ b/packages/socketio/test/app/Server.ts @@ -16,16 +16,16 @@ const rootDir = resolve(__dirname); httpsPort: false, logger: { level: "info", - logRequest: true, + logRequest: true }, mount: { - "/": [SocketPageCtrl], + "/": [SocketPageCtrl] }, statics: { - "/": "${rootDir}/views", + "/": "${rootDir}/views" }, - socketIO: {}, + socketIO: {} }) export class Server { @Inject() @@ -40,7 +40,7 @@ export class Server { .use(bodyParser.json()) .use( bodyParser.urlencoded({ - extended: true, + extended: true }) ) .use(cookieParser()) diff --git a/packages/swagger/src/SwaggerModule.spec.ts b/packages/swagger/src/SwaggerModule.spec.ts index 45adb7eb2ac..847a28fa363 100644 --- a/packages/swagger/src/SwaggerModule.spec.ts +++ b/packages/swagger/src/SwaggerModule.spec.ts @@ -40,7 +40,7 @@ describe("SwaggerModule", () => { showExplorer: true, cssPath: "cssPath", jsPath: "jsPath", - hidden: false, + hidden: false }, { path: "/doc2", @@ -50,8 +50,8 @@ describe("SwaggerModule", () => { showExplorer: false, cssPath: "cssPath", jsPath: "jsPath", - hidden: true, - }, + hidden: true + } ]; expressGet = Sinon.stub(app, "get"); @@ -79,15 +79,15 @@ describe("SwaggerModule", () => { expect(createRouterStub.getCall(0)).to.have.been.calledWithExactly(config[0], [ { url: "/doc1/swagger.json", - name: "doc1", - }, + name: "doc1" + } ]); expect(createRouterStub.getCall(1)).to.have.been.calledWithExactly(config[1], [ { url: "/doc1/swagger.json", - name: "doc1", - }, + name: "doc1" + } ]); }); @@ -120,7 +120,7 @@ describe("SwaggerModule", () => { showExplorer: true, cssPath: "cssPath", jsPath: "jsPath", - hidden: false, + hidden: false }, { path: "/doc2", @@ -130,8 +130,8 @@ describe("SwaggerModule", () => { showExplorer: false, cssPath: "cssPath", jsPath: "jsPath", - hidden: true, - }, + hidden: true + } ]; settingsService.get.returns(config); swaggerModule.swaggerService.getOpenAPISpec.returns({spec: "spec"}); @@ -169,7 +169,7 @@ describe("SwaggerModule", () => { showExplorer: true, cssPath: "cssPath", jsPath: "jsPath", - hidden: false, + hidden: false }, { path: "/doc2", @@ -179,13 +179,13 @@ describe("SwaggerModule", () => { showExplorer: false, cssPath: "cssPath", jsPath: "jsPath", - hidden: true, - }, + hidden: true + } ]; settingsService.getHttpPort.returns({ address: "0.0.0.0", - port: 8080, + port: 8080 }); settingsService.get.withArgs("swagger").returns(config); @@ -208,7 +208,7 @@ describe("SwaggerModule", () => { showExplorer: true, cssPath: "cssPath", jsPath: "jsPath", - hidden: false, + hidden: false }, { path: "/doc2", @@ -218,13 +218,13 @@ describe("SwaggerModule", () => { showExplorer: false, cssPath: "cssPath", jsPath: "jsPath", - hidden: true, - }, + hidden: true + } ]; settingsService.getHttpsPort.returns({ address: "0.0.0.0", - port: 8081, + port: 8081 }); settingsService.get.withArgs("swagger").returns(config); @@ -288,7 +288,7 @@ describe("SwaggerModule", () => { showExplorer: false, cssPath: "cssPath", jsPath: "jsPath", - hidden: true, + hidden: true }; swaggerModule.swaggerService.getOpenAPISpec.returns({spec: "spec"}); @@ -296,7 +296,7 @@ describe("SwaggerModule", () => { const req = {}; const res = { status: sandbox.stub().returnsThis(), - json: sandbox.stub().returnsThis(), + json: sandbox.stub().returnsThis() }; // WHEN swaggerModule.middlewareSwaggerJson(config)(req, res); diff --git a/packages/swagger/src/class/OpenApiEndpointBuilder.spec.ts b/packages/swagger/src/class/OpenApiEndpointBuilder.spec.ts index 41b89bce032..90b53396d3b 100644 --- a/packages/swagger/src/class/OpenApiEndpointBuilder.spec.ts +++ b/packages/swagger/src/class/OpenApiEndpointBuilder.spec.ts @@ -18,7 +18,7 @@ describe("OpenApiParamsBuilder", () => { "/test", { path: "/", - method: "get", + method: "get" }, (s: any) => s ); @@ -28,7 +28,7 @@ describe("OpenApiParamsBuilder", () => { describe("getTagName()", () => { const store = { - get: Sinon.stub(), + get: Sinon.stub() }; before(() => { Sinon.stub(Store, "from"); @@ -89,7 +89,7 @@ describe("OpenApiParamsBuilder", () => { it("should return the response when the type is missing", () => { const endpoint = new EndpointMetadata({ target: Test, - propertyKey: "test", + propertyKey: "test" }); const builder = new OpenApiEndpointBuilder( @@ -97,7 +97,7 @@ describe("OpenApiParamsBuilder", () => { "/test", { path: "/", - method: "get", + method: "get" }, (s: any) => s ); @@ -111,9 +111,9 @@ describe("OpenApiParamsBuilder", () => { headers: { header: { type: "string", - value: "application/json", - }, - }, + value: "application/json" + } + } } as any); expect(result).to.deep.eq({ @@ -121,9 +121,9 @@ describe("OpenApiParamsBuilder", () => { examples: "examples", headers: { header: { - type: "string", - }, - }, + type: "string" + } + } }); }); it("should return the response when the type is given (200)", () => { @@ -134,10 +134,10 @@ describe("OpenApiParamsBuilder", () => { const endpoint = new EndpointMetadata({ target: Test, - propertyKey: "test", + propertyKey: "test" }); endpoint.responses.set(200, { - type: MyModel, + type: MyModel } as any); const builder = new OpenApiEndpointBuilder( @@ -145,7 +145,7 @@ describe("OpenApiParamsBuilder", () => { "/test", { path: "/", - method: "get", + method: "get" }, (s: any) => s ); @@ -157,9 +157,9 @@ describe("OpenApiParamsBuilder", () => { headers: { header: { type: "string", - value: "application/json", - }, - }, + value: "application/json" + } + } } as any); expect(result).to.deep.eq({ @@ -167,12 +167,12 @@ describe("OpenApiParamsBuilder", () => { examples: "examples", headers: { header: { - type: "string", - }, + type: "string" + } }, schema: { - $ref: "#/definitions/MyModel", - }, + $ref: "#/definitions/MyModel" + } }); }); it("should return the response when the type is given (400)", () => { @@ -183,14 +183,14 @@ describe("OpenApiParamsBuilder", () => { const endpoint = new EndpointMetadata({ target: Test, - propertyKey: "test", + propertyKey: "test" }); endpoint.responses.set(400, { - type: NotFound, + type: NotFound } as any); endpoint.responses.set(200, { type: undefined, - description: "Success", + description: "Success" } as any); const builder = new OpenApiEndpointBuilder( @@ -198,7 +198,7 @@ describe("OpenApiParamsBuilder", () => { "/test", { path: "/", - method: "get", + method: "get" }, (s: any) => s ); @@ -210,9 +210,9 @@ describe("OpenApiParamsBuilder", () => { headers: { header: { type: "string", - value: "application/json", - }, - }, + value: "application/json" + } + } } as any); expect(result).to.deep.eq({ @@ -220,12 +220,12 @@ describe("OpenApiParamsBuilder", () => { examples: "examples", headers: { header: { - type: "string", - }, + type: "string" + } }, schema: { - $ref: "#/definitions/NotFound", - }, + $ref: "#/definitions/NotFound" + } }); // @ts-ignore @@ -235,9 +235,9 @@ describe("OpenApiParamsBuilder", () => { headers: { header: { type: "string", - value: "application/json", - }, - }, + value: "application/json" + } + } } as any); expect(result2).to.deep.eq({ @@ -245,9 +245,9 @@ describe("OpenApiParamsBuilder", () => { examples: "examples", headers: { header: { - type: "string", - }, - }, + type: "string" + } + } }); }); }); diff --git a/packages/swagger/src/class/OpenApiEndpointBuilder.ts b/packages/swagger/src/class/OpenApiEndpointBuilder.ts index b4220c0c22e..aaa6a58f2af 100644 --- a/packages/swagger/src/class/OpenApiEndpointBuilder.ts +++ b/packages/swagger/src/class/OpenApiEndpointBuilder.ts @@ -85,7 +85,7 @@ export class OpenApiEndpointBuilder extends OpenApiModelSchemaBuilder { consumes, responses: this.createResponses(builder.responses), security, - produces, + produces }, this.endpoint.get("operation") || {} ); @@ -113,7 +113,7 @@ export class OpenApiEndpointBuilder extends OpenApiModelSchemaBuilder { private createResponse(code: string | number, options: any): Response { const {type, collectionType, code: _, headers, ...obj} = { ...options, - ...this.endpoint.statusResponse(code), + ...this.endpoint.statusResponse(code) } as any; const response = deepClone(obj); @@ -124,7 +124,7 @@ export class OpenApiEndpointBuilder extends OpenApiModelSchemaBuilder { response.schema = this.createSchema({ schema: this.endpoint.get("schema"), type: isPromise(type) || isArrayOrArrayClass(type) || type === Object ? undefined! : type, - collectionType, + collectionType }); } @@ -133,8 +133,8 @@ export class OpenApiEndpointBuilder extends OpenApiModelSchemaBuilder { return { ...obj, [key]: { - ...schema, - }, + ...schema + } }; }, {}); } diff --git a/packages/swagger/src/class/OpenApiModelSchemaBuilder.spec.ts b/packages/swagger/src/class/OpenApiModelSchemaBuilder.spec.ts index 5f512d459a8..6b71d6c2dfe 100644 --- a/packages/swagger/src/class/OpenApiModelSchemaBuilder.spec.ts +++ b/packages/swagger/src/class/OpenApiModelSchemaBuilder.spec.ts @@ -28,61 +28,61 @@ describe("OpenApiModelSchemaBuilder", () => { required: ["test"], properties: { Name: { - type: "string", + type: "string" }, ageModel: { - $ref: "#/definitions/SwaAgeModel", + $ref: "#/definitions/SwaAgeModel" }, nameModel: { - $ref: "#/definitions/SwaNameModel", + $ref: "#/definitions/SwaNameModel" }, foo: { - $ref: "#/definitions/SwaFoo", + $ref: "#/definitions/SwaFoo" }, dateStart: { - type: "string", + type: "string" }, foos: { description: "SwaFoo2.foos description", examples: ["TODO"], items: { - $ref: "#/definitions/SwaFoo", + $ref: "#/definitions/SwaFoo" }, title: "SwaFoo2.foos", - type: "array", + type: "array" }, arrayOfString: { type: "array", items: { - type: "string", - }, + type: "string" + } }, test: { description: "Description test", title: "Test", - type: "string", + type: "string" }, theMap: { type: "object", additionalProperties: { - $ref: "#/definitions/SwaFoo", + $ref: "#/definitions/SwaFoo" }, description: "SwaFoo2.theMap description", - title: "SwaFoo2.theMap", + title: "SwaFoo2.theMap" }, theSet: { type: "object", additionalProperties: { - $ref: "#/definitions/SwaFoo", + $ref: "#/definitions/SwaFoo" }, description: "SwaFoo2.theSet description", - title: "SwaFoo2.theSet", + title: "SwaFoo2.theSet" }, mapOfString: { type: "object", additionalProperties: { - type: "string", - }, + type: "string" + } }, mapAny: { type: "object", @@ -90,53 +90,53 @@ describe("OpenApiModelSchemaBuilder", () => { nullable: true, oneOf: [ { - type: "integer", + type: "integer" }, { - type: "number", + type: "number" }, { - type: "string", + type: "string" }, { - type: "boolean", + type: "boolean" }, { - type: "array", + type: "array" }, { - type: "object", - }, - ], - }, + type: "object" + } + ] + } }, anyValue: { nullable: true, oneOf: [ { - type: "integer", + type: "integer" }, { - type: "number", + type: "number" }, { - type: "string", + type: "string" }, { - type: "boolean", + type: "boolean" }, { - type: "array", + type: "array" }, { - type: "object", - }, - ], + type: "object" + } + ] }, uint: { - type: "number", - }, - }, + type: "number" + } + } }); expect(schemaBuilder.definitions).to.deep.eq({ SwaFoo: { @@ -144,70 +144,70 @@ describe("OpenApiModelSchemaBuilder", () => { foo: { description: "Description.foo", title: "SwaFoo.foo", - type: "object", + type: "object" }, test: { description: "Description.test", title: "SwaFoo.test", - type: "object", - }, + type: "object" + } }, - type: "object", + type: "object" }, SwaFoo2: { description: "Description Class", required: ["test"], properties: { Name: { - type: "string", + type: "string" }, ageModel: { - $ref: "#/definitions/SwaAgeModel", + $ref: "#/definitions/SwaAgeModel" }, nameModel: { - $ref: "#/definitions/SwaNameModel", + $ref: "#/definitions/SwaNameModel" }, foo: { - $ref: "#/definitions/SwaFoo", + $ref: "#/definitions/SwaFoo" }, dateStart: { - type: "string", + type: "string" }, foos: { description: "SwaFoo2.foos description", examples: ["TODO"], items: { - $ref: "#/definitions/SwaFoo", + $ref: "#/definitions/SwaFoo" }, title: "SwaFoo2.foos", - type: "array", + type: "array" }, arrayOfString: { type: "array", items: { - type: "string", - }, + type: "string" + } }, test: { description: "Description test", title: "Test", - type: "string", + type: "string" }, theMap: { type: "object", additionalProperties: { - $ref: "#/definitions/SwaFoo", + $ref: "#/definitions/SwaFoo" }, description: "SwaFoo2.theMap description", - title: "SwaFoo2.theMap", + title: "SwaFoo2.theMap" }, theSet: { type: "object", additionalProperties: { - $ref: "#/definitions/SwaFoo", + $ref: "#/definitions/SwaFoo" }, description: "SwaFoo2.theSet description", - title: "SwaFoo2.theSet", + title: "SwaFoo2.theSet" }, mapAny: { @@ -216,92 +216,92 @@ describe("OpenApiModelSchemaBuilder", () => { nullable: true, oneOf: [ { - type: "integer", + type: "integer" }, { - type: "number", + type: "number" }, { - type: "string", + type: "string" }, { - type: "boolean", + type: "boolean" }, { - type: "array", + type: "array" }, { - type: "object", - }, - ], - }, + type: "object" + } + ] + } }, anyValue: { nullable: true, oneOf: [ { - type: "integer", + type: "integer" }, { - type: "number", + type: "number" }, { - type: "string", + type: "string" }, { - type: "boolean", + type: "boolean" }, { - type: "array", + type: "array" }, { - type: "object", - }, - ], + type: "object" + } + ] }, mapOfString: { type: "object", additionalProperties: { - type: "string", - }, + type: "string" + } }, uint: { - type: "number", - }, + type: "number" + } }, title: "SwaFoo2", - type: "object", + type: "object" }, SwaAgeModel: { properties: { age: { description: "The age", title: "age", - type: "number", + type: "number" }, id: { description: "Unique identifier.", title: "id", - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }, SwaNameModel: { properties: { name: { description: "The name", title: "name", - type: "string", + type: "string" }, id: { description: "Unique identifier.", title: "id", - type: "string", - }, + type: "string" + } }, - type: "object", - }, + type: "object" + } }); }); }); @@ -312,14 +312,14 @@ describe("OpenApiModelSchemaBuilder", () => { expect(schemaBuilder.schema).to.deep.eq({ properties: { childPropertyB: { - type: "string", + type: "string" }, parentProperty: { - type: "string", - }, + type: "string" + } }, required: ["parentProperty", "childPropertyB"], - type: "object", + type: "object" }); }); }); @@ -342,14 +342,14 @@ describe("OpenApiModelSchemaBuilder", () => { description: "description", properties: { name: { - type: "string", + type: "string" }, test2: { - type: "string", - }, + type: "string" + } }, required: ["test2"], - type: "object", + type: "object" }); }); }); @@ -367,21 +367,21 @@ describe("OpenApiModelSchemaBuilder", () => { expect(builder.schema).to.deep.equal({ properties: { test: { - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }); expect(builder.definitions).to.deep.equal({ Model: { properties: { test: { - type: "string", - }, + type: "string" + } }, - type: "object", - }, + type: "object" + } }); }); }); @@ -397,21 +397,21 @@ describe("OpenApiModelSchemaBuilder", () => { expect(builder.schema).to.deep.equal({ properties: { test: { - type: "object", - }, + type: "object" + } }, - type: "object", + type: "object" }); expect(builder.definitions).to.deep.equal({ Model: { properties: { test: { - type: "object", - }, + type: "object" + } }, - type: "object", - }, + type: "object" + } }); }); }); @@ -432,24 +432,24 @@ describe("OpenApiModelSchemaBuilder", () => { properties: { test: { items: { - type: "string", + type: "string" }, - type: "array", - }, + type: "array" + } }, - type: "object", - }, + type: "object" + } }); expect(builder.schema).to.deep.equal({ properties: { test: { items: { - type: "string", + type: "string" }, - type: "array", - }, + type: "array" + } }, - type: "object", + type: "object" }); }); }); @@ -471,34 +471,34 @@ describe("OpenApiModelSchemaBuilder", () => { properties: { test: { items: { - $ref: "#/definitions/Items", + $ref: "#/definitions/Items" }, - type: "array", - }, + type: "array" + } }, - type: "object", + type: "object" }); expect(builder.definitions).to.deep.equal({ Items: { properties: { value: { - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }, Model: { properties: { test: { items: { - $ref: "#/definitions/Items", + $ref: "#/definitions/Items" }, - type: "array", - }, + type: "array" + } }, - type: "object", - }, + type: "object" + } }); }); }); diff --git a/packages/swagger/src/class/OpenApiModelSchemaBuilder.ts b/packages/swagger/src/class/OpenApiModelSchemaBuilder.ts index 932f3e633bd..de61b5458bd 100644 --- a/packages/swagger/src/class/OpenApiModelSchemaBuilder.ts +++ b/packages/swagger/src/class/OpenApiModelSchemaBuilder.ts @@ -51,7 +51,7 @@ export class OpenApiModelSchemaBuilder { schema.properties![String(propertyKey)] = this.createSchema({ schema: property.store.get("schema"), type: property.type, - collectionType: property.collectionType, + collectionType: property.collectionType }); }); @@ -69,7 +69,7 @@ export class OpenApiModelSchemaBuilder { protected createSchema({ schema = {}, type, - collectionType, + collectionType }: { schema: Partial | any; type: Type; @@ -88,7 +88,7 @@ export class OpenApiModelSchemaBuilder { this._definitions = { ...this._definitions, - ...builder.definitions, + ...builder.definitions }; } @@ -99,7 +99,7 @@ export class OpenApiModelSchemaBuilder { if (!schema.items) { if (isClass(type)) { schema.items = { - $ref: `#/definitions/${typeName}`, + $ref: `#/definitions/${typeName}` }; } else { schema.items = swaggerApplyType({}, (isObject(schema.additionalProperties) && schema.additionalProperties.type) || type); @@ -113,7 +113,7 @@ export class OpenApiModelSchemaBuilder { if (isClass(type)) { schema.additionalProperties = { - $ref: `#/definitions/${typeName}`, + $ref: `#/definitions/${typeName}` }; return schema; diff --git a/packages/swagger/src/class/OpenApiParamsBuilder.spec.ts b/packages/swagger/src/class/OpenApiParamsBuilder.spec.ts index 90ce5451be8..de66c5e638a 100644 --- a/packages/swagger/src/class/OpenApiParamsBuilder.spec.ts +++ b/packages/swagger/src/class/OpenApiParamsBuilder.spec.ts @@ -29,8 +29,8 @@ describe("OpenApiParamsBuilder", () => { in: "formData", name: "expression", required: false, - type: "string", - }, + type: "string" + } ]); }); }); @@ -52,9 +52,9 @@ describe("OpenApiParamsBuilder", () => { name: "body", required: false, schema: { - $ref: "#/definitions/CtrlTestPayload", - }, - }, + $ref: "#/definitions/CtrlTestPayload" + } + } ]); }); }); @@ -101,23 +101,23 @@ describe("OpenApiParamsBuilder", () => { expression: "expression1", required: true, store: { - get: storeGet, - }, + get: storeGet + } }, { paramType: ParamTypes.PATH, store: { - get: storeGet, - }, + get: storeGet + } }, { paramType: ParamTypes.QUERY, expression: "expression2", required: false, store: { - get: storeGet, - }, - }, + get: storeGet + } + } ]; this.getParamsStub = Sinon.stub(ParamMetadata, "getParams").returns(this.params); @@ -145,15 +145,15 @@ describe("OpenApiParamsBuilder", () => { name: "expression1", required: true, test: "test", - type: "string", + type: "string" }, { in: "query", name: "expression2", required: false, test: "test", - type: "string", - }, + type: "string" + } ]); }); }); @@ -175,17 +175,17 @@ describe("OpenApiParamsBuilder", () => { required: true, type: String, store: { - get: storeGet, - }, + get: storeGet + } }, { paramType: ParamTypes.QUERY, expression: "expression2", required: false, store: { - get: storeGet, - }, - }, + get: storeGet + } + } ]; this.getParamsStub = Sinon.stub(ParamMetadata, "getParams").returns(this.params); @@ -195,14 +195,14 @@ describe("OpenApiParamsBuilder", () => { in: "path", type: "string", name: "expression1", - required: true, + required: true }, { in: "path", type: "string", name: "test", - required: true, - }, + required: true + } ]); this.result = this.builder.getInPathParams(); @@ -218,14 +218,14 @@ describe("OpenApiParamsBuilder", () => { name: "expression1", required: true, test: "test", - type: "string", + type: "string" }, { in: "path", name: "test", required: true, - type: "string", - }, + type: "string" + } ]); }); }); @@ -247,17 +247,17 @@ describe("OpenApiParamsBuilder", () => { required: true, type: String, store: { - get: storeGet, - }, + get: storeGet + } }, { paramType: ParamTypes.FORM_DATA, expression: "expression2.0", required: false, store: { - get: storeGet, - }, - }, + get: storeGet + } + } ]; this.getParamsStub = Sinon.stub(ParamMetadata, "getParams").returns(this.params); @@ -277,15 +277,15 @@ describe("OpenApiParamsBuilder", () => { name: "expression1", required: true, test: "test", - type: "string", + type: "string" }, { in: "formData", name: "expression2", required: false, test: "test", - type: "file", - }, + type: "file" + } ]); }); }); @@ -308,11 +308,11 @@ describe("OpenApiParamsBuilder", () => { Model: { properties: { prop: { - type: "string", - }, + type: "string" + } }, - type: "object", - }, + type: "object" + } }); expect(builder.parameters).to.deep.equal([ @@ -322,9 +322,9 @@ describe("OpenApiParamsBuilder", () => { name: "body", required: true, schema: { - $ref: "#/definitions/Model", - }, - }, + $ref: "#/definitions/Model" + } + } ]); }); }); @@ -347,8 +347,8 @@ describe("OpenApiParamsBuilder", () => { type: String, typeName: "Test", store: { - get: storeGet, - }, + get: storeGet + } }, { paramType: ParamTypes.BODY, @@ -357,9 +357,9 @@ describe("OpenApiParamsBuilder", () => { type: Number, typeName: "Test", store: { - get: storeGet, - }, - }, + get: storeGet + } + } ]; this.getParamsStub = Sinon.stub(ParamMetadata, "getParams").returns(this.params); @@ -379,8 +379,8 @@ describe("OpenApiParamsBuilder", () => { name: "body", required: true, schema: { - $ref: "#/definitions/CtrlTestPayload", - }, + $ref: "#/definitions/CtrlTestPayload" + } }); }); @@ -390,16 +390,16 @@ describe("OpenApiParamsBuilder", () => { properties: { test: { test: "test", - type: "string", + type: "string" }, test2: { test: "test", - type: "number", - }, + type: "number" + } }, required: ["test"], - type: "object", - }, + type: "object" + } }); }); }); @@ -427,19 +427,19 @@ describe("OpenApiParamsBuilder", () => { properties: { t2: { properties: { - t3: {}, + t3: {} }, required: ["t3"], - type: "object", - }, + type: "object" + } }, required: ["t2"], - type: "object", - }, + type: "object" + } }, required: ["t1"], - type: "object", - }, + type: "object" + } }); }); }); @@ -460,10 +460,10 @@ describe("OpenApiParamsBuilder", () => { currentProperty: {}, schema: { properties: { - event: {}, + event: {} }, - type: "object", - }, + type: "object" + } }); }); }); @@ -483,7 +483,7 @@ describe("OpenApiParamsBuilder", () => { it("should create a schema", () => { expect(this.result).to.deep.eq({ currentProperty: {}, - schema: {}, + schema: {} }); }); }); @@ -502,8 +502,8 @@ describe("OpenApiParamsBuilder", () => { isClass: false, isCollection: false, store: { - get: () => {}, - }, + get: () => {} + } }); }); after(() => { @@ -518,16 +518,16 @@ describe("OpenApiParamsBuilder", () => { t2: { properties: { t3: { - type: "string", - }, + type: "string" + } }, - type: "object", - }, + type: "object" + } }, - type: "object", - }, + type: "object" + } }, - type: "object", + type: "object" }); }); }); @@ -563,10 +563,10 @@ describe("OpenApiParamsBuilder", () => { schema: { type: "array", items: { - type: "string", - }, - }, - }, + type: "string" + } + } + } ]); }); }); @@ -586,8 +586,8 @@ describe("OpenApiParamsBuilder", () => { isCollection: false, typeName: "Test", store: { - get: () => Test, - }, + get: () => Test + } }); }); after(() => { @@ -598,10 +598,10 @@ describe("OpenApiParamsBuilder", () => { expect(this.result).to.deep.eq({ properties: { event: { - $ref: "#/definitions/Test", - }, + $ref: "#/definitions/Test" + } }, - type: "object", + type: "object" }); }); }); @@ -619,7 +619,7 @@ describe("OpenApiParamsBuilder", () => { type: String, isClass: false, isCollection: false, - isArray: false, + isArray: false }); }); after(() => { @@ -628,8 +628,8 @@ describe("OpenApiParamsBuilder", () => { it("should return the right schema", () => { expect(this.result).to.deep.equal([ { - type: "string", - }, + type: "string" + } ]); }); }); @@ -645,7 +645,7 @@ describe("OpenApiParamsBuilder", () => { type: String, isClass: false, isCollection: true, - isArray: true, + isArray: true }); }); after(() => { @@ -657,9 +657,9 @@ describe("OpenApiParamsBuilder", () => { type: "array", collectionFormat: "multi", items: { - type: "string", - }, - }, + type: "string" + } + } ]); }); }); @@ -683,16 +683,16 @@ describe("OpenApiParamsBuilder", () => { type: String, isClass: false, isCollection: true, - isArray: false, + isArray: false }); expect(result).to.deep.equal([ { type: "object", additionalProperties: { - type: "string", - }, - }, + type: "string" + } + } ]); }); }); @@ -713,9 +713,9 @@ describe("OpenApiParamsBuilder", () => { name: "body", required: false, schema: { - $ref: "#/definitions/SwaFoo2", - }, - }, + $ref: "#/definitions/SwaFoo2" + } + } ]); expect(builder.definitions).to.deep.eq({ @@ -724,66 +724,66 @@ describe("OpenApiParamsBuilder", () => { age: { description: "The age", title: "age", - type: "number", + type: "number" }, id: { description: "Unique identifier.", title: "id", - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }, SwaFoo: { properties: { foo: { description: "Description.foo", title: "SwaFoo.foo", - type: "object", + type: "object" }, test: { description: "Description.test", title: "SwaFoo.test", - type: "object", - }, + type: "object" + } }, - type: "object", + type: "object" }, SwaFoo2: { description: "Description Class", properties: { Name: { - type: "string", + type: "string" }, ageModel: { - $ref: "#/definitions/SwaAgeModel", + $ref: "#/definitions/SwaAgeModel" }, arrayOfString: { items: { - type: "string", + type: "string" }, - type: "array", + type: "array" }, dateStart: { - type: "string", + type: "string" }, foo: { - $ref: "#/definitions/SwaFoo", + $ref: "#/definitions/SwaFoo" }, foos: { description: "SwaFoo2.foos description", examples: ["TODO"], items: { - $ref: "#/definitions/SwaFoo", + $ref: "#/definitions/SwaFoo" }, title: "SwaFoo2.foos", - type: "array", + type: "array" }, mapOfString: { type: "object", additionalProperties: { - type: "string", - }, + type: "string" + } }, mapAny: { type: "object", @@ -791,96 +791,96 @@ describe("OpenApiParamsBuilder", () => { nullable: true, oneOf: [ { - type: "integer", + type: "integer" }, { - type: "number", + type: "number" }, { - type: "string", + type: "string" }, { - type: "boolean", + type: "boolean" }, { - type: "array", + type: "array" }, { - type: "object", - }, - ], - }, + type: "object" + } + ] + } }, anyValue: { nullable: true, oneOf: [ { - type: "integer", + type: "integer" }, { - type: "number", + type: "number" }, { - type: "string", + type: "string" }, { - type: "boolean", + type: "boolean" }, { - type: "array", + type: "array" }, { - type: "object", - }, - ], + type: "object" + } + ] }, nameModel: { - $ref: "#/definitions/SwaNameModel", + $ref: "#/definitions/SwaNameModel" }, test: { description: "Description test", title: "Test", - type: "string", + type: "string" }, theMap: { type: "object", additionalProperties: { - $ref: "#/definitions/SwaFoo", + $ref: "#/definitions/SwaFoo" }, description: "SwaFoo2.theMap description", - title: "SwaFoo2.theMap", + title: "SwaFoo2.theMap" }, theSet: { type: "object", additionalProperties: { - $ref: "#/definitions/SwaFoo", + $ref: "#/definitions/SwaFoo" }, description: "SwaFoo2.theSet description", - title: "SwaFoo2.theSet", + title: "SwaFoo2.theSet" }, uint: { - type: "number", - }, + type: "number" + } }, required: ["test"], title: "SwaFoo2", - type: "object", + type: "object" }, SwaNameModel: { properties: { id: { description: "Unique identifier.", title: "id", - type: "string", + type: "string" }, name: { description: "The name", title: "name", - type: "string", - }, + type: "string" + } }, - type: "object", - }, + type: "object" + } }); }); it("should create query params", () => { @@ -905,21 +905,21 @@ describe("OpenApiParamsBuilder", () => { in: "query", name: "name", required: true, - type: "string", + type: "string" }, { in: "query", minLength: 1, name: "start", required: false, - type: "string", + type: "string" }, { in: "query", name: "id", required: false, - type: "string", - }, + type: "string" + } ]); }); }); diff --git a/packages/swagger/src/class/OpenApiParamsBuilder.ts b/packages/swagger/src/class/OpenApiParamsBuilder.ts index b569cb2d66c..b2b6ad1fef4 100644 --- a/packages/swagger/src/class/OpenApiParamsBuilder.ts +++ b/packages/swagger/src/class/OpenApiParamsBuilder.ts @@ -11,7 +11,7 @@ function serializeModelToParameter(model: ParamMetadata) { return { name: [model.expression, key].filter(Boolean).join("."), required: (schema.required || []).includes(key), - ...item, + ...item }; }); } @@ -91,7 +91,7 @@ export class OpenApiParamsBuilder extends OpenApiModelSchemaBuilder { super.createSchema({ schema: param.store.get("schema"), type: param.type, - collectionType: param.collectionType, + collectionType: param.collectionType }) ); @@ -112,9 +112,9 @@ export class OpenApiParamsBuilder extends OpenApiModelSchemaBuilder { type: "array", collectionFormat: "multi", items: { - type, - }, - }, + type + } + } ] as any[]; } @@ -122,9 +122,9 @@ export class OpenApiParamsBuilder extends OpenApiModelSchemaBuilder { { type: "object", additionalProperties: { - type, - }, - }, + type + } + } ]; } @@ -134,8 +134,8 @@ export class OpenApiParamsBuilder extends OpenApiModelSchemaBuilder { return [ { - type, - }, + type + } ]; } @@ -151,7 +151,7 @@ export class OpenApiParamsBuilder extends OpenApiModelSchemaBuilder { in: "header", name: param.expression, type: swaggerType(param.type), - required: param.required, + required: param.required }); }); } @@ -172,7 +172,7 @@ export class OpenApiParamsBuilder extends OpenApiModelSchemaBuilder { in: "formData", name, required: param.required, - type, + type }); }); } @@ -194,7 +194,7 @@ export class OpenApiParamsBuilder extends OpenApiModelSchemaBuilder { this._definitions = { ...this._definitions, - ...builder.definitions, + ...builder.definitions }; if (param.required) { @@ -208,8 +208,8 @@ export class OpenApiParamsBuilder extends OpenApiModelSchemaBuilder { schema: this.createSchema({ schema: param.store.get("schema"), type: param.type, - collectionType: param.collectionType, - }), + collectionType: param.collectionType + }) }); } @@ -234,8 +234,8 @@ export class OpenApiParamsBuilder extends OpenApiModelSchemaBuilder { required, description: "", schema: { - $ref: `#/definitions/${model}`, - }, + $ref: `#/definitions/${model}` + } }; } @@ -258,7 +258,7 @@ export class OpenApiParamsBuilder extends OpenApiModelSchemaBuilder { const param = pathParams.get(pathParam.name); pathParam = Object.assign({}, pathParam, param.store.get("baseParameter") || {}, { - type: swaggerType(param.type), + type: swaggerType(param.type) }); } @@ -288,9 +288,9 @@ export class OpenApiParamsBuilder extends OpenApiModelSchemaBuilder { in: "query", name: param.expression, required: Boolean(param.required), - ...item, + ...item }; - }), + }) ]; }, []); } diff --git a/packages/swagger/src/constants/httpStatusMessages.ts b/packages/swagger/src/constants/httpStatusMessages.ts index a7fc0f75a98..6a1be2c7b36 100644 --- a/packages/swagger/src/constants/httpStatusMessages.ts +++ b/packages/swagger/src/constants/httpStatusMessages.ts @@ -58,5 +58,5 @@ export const HTTP_STATUS_MESSAGES: {[key: string]: string} = { "508": "Loop Detected", "509": "Unassigned", "510": "Not Extended", - "511": "Network Authentication Required", + "511": "Network Authentication Required" }; diff --git a/packages/swagger/src/decorators/example.spec.ts b/packages/swagger/src/decorators/example.spec.ts index 055f79473ce..a0053dca0ae 100644 --- a/packages/swagger/src/decorators/example.spec.ts +++ b/packages/swagger/src/decorators/example.spec.ts @@ -17,10 +17,10 @@ describe("@Example", () => { properties: { method: { examples: ["Examples"], - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }); }); it("should declare description on property (with obj)", () => { @@ -38,13 +38,13 @@ describe("@Example", () => { method: { examples: [ { - id: "id", - }, + id: "id" + } ], - type: "object", - }, + type: "object" + } }, - type: "object", + type: "object" }); }); it("should declare description on property (with two params on class)", () => { @@ -60,14 +60,14 @@ describe("@Example", () => { expect(getJsonSchema(Model)).to.deep.equal({ definitions: {}, example: { - method: "description", + method: "description" }, properties: { method: { - type: "string", - }, + type: "string" + } }, - type: "object", + type: "object" }); }); }); diff --git a/packages/swagger/src/decorators/operation.spec.ts b/packages/swagger/src/decorators/operation.spec.ts index 1572a262085..fb5a6b685cb 100644 --- a/packages/swagger/src/decorators/operation.spec.ts +++ b/packages/swagger/src/decorators/operation.spec.ts @@ -12,14 +12,14 @@ describe("Operation()", () => { it("should set the operation", () => { // WHEN Operation({ - security: [{auth: ["scope"]}], + security: [{auth: ["scope"]}] })(prototypeOf(Test), "test", descriptorOf(Test, "test")); // THEN const store = Store.fromMethod(Test, "test"); expect(store.get("operation")).to.deep.eq({ - security: [{auth: ["scope"]}], + security: [{auth: ["scope"]}] }); }); }); @@ -32,14 +32,14 @@ describe("Operation()", () => { it("should set the operation", () => { // WHEN Operation({ - security: [{auth: ["scope"]}], + security: [{auth: ["scope"]}] })(Test); // THEN const store = Store.fromMethod(Test, "test"); expect(store.get("operation")).to.deep.eq({ - security: [{auth: ["scope"]}], + security: [{auth: ["scope"]}] }); }); }); @@ -54,7 +54,7 @@ describe("Operation()", () => { let actualError; try { Operation({ - security: [{auth: ["scope"]}], + security: [{auth: ["scope"]}] })(prototypeOf(Test), "test"); } catch (er) { actualError = er; diff --git a/packages/swagger/src/decorators/responses.spec.ts b/packages/swagger/src/decorators/responses.spec.ts index 0a5c4bdc84d..99728860d54 100644 --- a/packages/swagger/src/decorators/responses.spec.ts +++ b/packages/swagger/src/decorators/responses.spec.ts @@ -12,7 +12,7 @@ describe("Responses()", () => { it("should set the responses", () => { // WHEN Responses(400, { - description: "Bad Request", + description: "Bad Request" })(prototypeOf(Test), "test", descriptorOf(Test, "test")); // THEN @@ -20,8 +20,8 @@ describe("Responses()", () => { expect(store.get("responses")).to.deep.eq({ "400": { - description: "Bad Request", - }, + description: "Bad Request" + } }); }); }); @@ -34,7 +34,7 @@ describe("Responses()", () => { it("should set the responses", () => { // WHEN Responses(400, { - description: "Bad Request", + description: "Bad Request" })(Test); // THEN @@ -42,8 +42,8 @@ describe("Responses()", () => { expect(store.get("responses")).to.deep.eq({ "400": { - description: "Bad Request", - }, + description: "Bad Request" + } }); }); }); @@ -58,7 +58,7 @@ describe("Responses()", () => { let actualError; try { Responses(400, { - description: "Bad Request", + description: "Bad Request" })(prototypeOf(Test), "test"); } catch (er) { actualError = er; diff --git a/packages/swagger/src/decorators/returns.spec.ts b/packages/swagger/src/decorators/returns.spec.ts index 4f3fad3f857..7926f72d2f9 100644 --- a/packages/swagger/src/decorators/returns.spec.ts +++ b/packages/swagger/src/decorators/returns.spec.ts @@ -10,7 +10,7 @@ describe("Returns()", () => { it("should set the responses", () => { class Ctrl { @Returns(400, { - description: "Bad Request", + description: "Bad Request" }) test() {} } @@ -19,7 +19,7 @@ describe("Returns()", () => { expect(endpoint.responses.get(400)).to.deep.eq({ code: 400, - description: "Bad Request", + description: "Bad Request" }); }); }); @@ -37,7 +37,7 @@ describe("Returns()", () => { expect(endpoint.responses.get(200)).to.deep.eq({ code: 200, description: "", - type: Test, + type: Test }); }); }); @@ -46,7 +46,7 @@ describe("Returns()", () => { it("should set the responses", () => { class Ctrl { @Returns(Test, { - description: "Success", + description: "Success" }) test() {} } @@ -56,7 +56,7 @@ describe("Returns()", () => { expect(endpoint.response).to.deep.eq({ code: 200, description: "Success", - type: Test, + type: Test }); }); }); @@ -74,7 +74,7 @@ describe("Returns()", () => { expect(endpoint.response).to.deep.eq({ code: 200, description: "", - type: Test, + type: Test }); }); }); @@ -88,9 +88,9 @@ describe("Returns()", () => { type: Test, headers: { "Content-Type": { - type: "string", - }, - }, + type: "string" + } + } }) test() {} } @@ -103,9 +103,9 @@ describe("Returns()", () => { type: Test, headers: { "Content-Type": { - type: "string", - }, - }, + type: "string" + } + } }); }); }); diff --git a/packages/swagger/src/decorators/returnsArray.spec.ts b/packages/swagger/src/decorators/returnsArray.spec.ts index 7368b9826ff..01cedb957dd 100644 --- a/packages/swagger/src/decorators/returnsArray.spec.ts +++ b/packages/swagger/src/decorators/returnsArray.spec.ts @@ -9,7 +9,7 @@ describe("ReturnsArray()", () => { it("should set the responses", () => { class Ctrl { @ReturnsArray(Test, { - description: "Success", + description: "Success" }) test() {} } @@ -20,7 +20,7 @@ describe("ReturnsArray()", () => { code: 200, description: "Success", type: Test, - collectionType: Array, + collectionType: Array }); }); }); @@ -39,7 +39,7 @@ describe("ReturnsArray()", () => { code: 200, description: "", type: Test, - collectionType: Array, + collectionType: Array }); }); }); @@ -53,9 +53,9 @@ describe("ReturnsArray()", () => { type: Test, headers: { "Content-Type": { - type: "string", - }, - }, + type: "string" + } + } }) test() {} } @@ -69,9 +69,9 @@ describe("ReturnsArray()", () => { collectionType: Array, headers: { "Content-Type": { - type: "string", - }, - }, + type: "string" + } + } }); }); }); diff --git a/packages/swagger/src/decorators/security.spec.ts b/packages/swagger/src/decorators/security.spec.ts index 1817c92d064..4fbbb9ee506 100644 --- a/packages/swagger/src/decorators/security.spec.ts +++ b/packages/swagger/src/decorators/security.spec.ts @@ -16,8 +16,8 @@ describe("Security()", () => { it("should set the security", () => { expect(this.store.get("operation").security).to.deep.eq([ { - securityDefinitionName: ["scope1", "scope2"], - }, + securityDefinitionName: ["scope1", "scope2"] + } ]); }); }); diff --git a/packages/swagger/src/middlewares/indexMiddleware.spec.ts b/packages/swagger/src/middlewares/indexMiddleware.spec.ts index 8a9820cf9e1..01da51597e9 100644 --- a/packages/swagger/src/middlewares/indexMiddleware.spec.ts +++ b/packages/swagger/src/middlewares/indexMiddleware.spec.ts @@ -15,7 +15,7 @@ describe("indexMiddleware and redirect", () => { showExplorer: false, cssPath: "/path.css", jsPath: "/path.js", - urls: [], + urls: [] }; indexMiddleware(viewPath, conf)(req as any, res as any); @@ -27,7 +27,7 @@ describe("indexMiddleware and redirect", () => { showExplorer: false, swaggerOptions: {}, url: "/doc/swagger.json", - urls: [], + urls: [] }); }); }); diff --git a/packages/swagger/src/middlewares/indexMiddleware.ts b/packages/swagger/src/middlewares/indexMiddleware.ts index abd48fb46cb..c720378bcb9 100644 --- a/packages/swagger/src/middlewares/indexMiddleware.ts +++ b/packages/swagger/src/middlewares/indexMiddleware.ts @@ -11,7 +11,7 @@ export function indexMiddleware(viewPath: string, conf: SwaggerSettings & {urls: showExplorer, cssPath, jsPath, - swaggerOptions: options, + swaggerOptions: options }); }; } diff --git a/packages/swagger/src/services/SwaggerService.spec.ts b/packages/swagger/src/services/SwaggerService.spec.ts index aa022fd1db2..395e95363c8 100644 --- a/packages/swagger/src/services/SwaggerService.spec.ts +++ b/packages/swagger/src/services/SwaggerService.spec.ts @@ -27,7 +27,7 @@ describe("SwaggerService", () => { describe("when specPath is given", () => { it("should return default spec", () => { const result = swaggerService.getDefaultSpec({ - specPath: __dirname + "/data/spec.json", + specPath: __dirname + "/data/spec.json" }); expect(result).to.deep.equals(require("./data/spec.expected.json")); @@ -38,8 +38,8 @@ describe("SwaggerService", () => { it("should return default spec", () => { const result = swaggerService.getDefaultSpec({ spec: { - produces: ["application/json", "application/octet-stream", "application/xml"], - }, + produces: ["application/json", "application/octet-stream", "application/xml"] + } }); expect(result).to.deep.equals({ @@ -50,11 +50,11 @@ describe("SwaggerService", () => { license: undefined, termsOfService: "", title: "Api documentation", - version: "1.0.0", + version: "1.0.0" }, produces: ["application/json", "application/octet-stream", "application/xml"], consumes: ["application/json"], - securityDefinitions: {}, + securityDefinitions: {} }); }); }); @@ -70,11 +70,11 @@ describe("SwaggerService", () => { license: undefined, termsOfService: "", title: "Api documentation", - version: "1.0.0", + version: "1.0.0" }, produces: ["application/json"], securityDefinitions: {}, - swagger: "2.0", + swagger: "2.0" }); }); }); @@ -92,11 +92,11 @@ describe("SwaggerService", () => { license: undefined, termsOfService: "", title: "Api documentation", - version: "1.0.0", + version: "1.0.0" }, produces: ["application/json"], securityDefinitions: {}, - swagger: "2.0", + swagger: "2.0" }); }); }); @@ -114,7 +114,7 @@ describe("SwaggerService", () => { it("should return an array with tags", () => { // GIVEN const store = { - get: Sinon.stub(), + get: Sinon.stub() }; stub(Store.from).returns(store); @@ -142,7 +142,7 @@ describe("SwaggerService", () => { it("should return an array with tags", () => { // GIVEN const store = { - get: Sinon.stub(), + get: Sinon.stub() }; stub(Store.from).returns(store); diff --git a/packages/swagger/src/services/SwaggerService.ts b/packages/swagger/src/services/SwaggerService.ts index d6bffbeb0b1..de97fc11bb1 100644 --- a/packages/swagger/src/services/SwaggerService.ts +++ b/packages/swagger/src/services/SwaggerService.ts @@ -43,7 +43,7 @@ export class SwaggerService { { tags, paths, - definitions, + definitions }, getReducers() ); @@ -59,7 +59,7 @@ export class SwaggerService { conf.spec || ({ info: {}, - securityDefinitions: {}, + securityDefinitions: {} } as any); const specPath = conf.specPath; @@ -84,11 +84,11 @@ export class SwaggerService { description, termsOfService, contact, - license, + license }, consumes: this.configuration.acceptMimes.concat(spec.consumes || []), produces: spec.produces || ["application/json"], - securityDefinitions: spec.securityDefinitions || {}, + securityDefinitions: spec.securityDefinitions || {} }, specPathContent, getReducers() @@ -163,7 +163,7 @@ export class SwaggerService { return Object.assign( { name: ctrlStore.get("name") || nameOf(clazz), - description: ctrlStore.get("description"), + description: ctrlStore.get("description") }, ctrlStore.get("tag") || {} ); diff --git a/packages/swagger/src/utils/index.spec.ts b/packages/swagger/src/utils/index.spec.ts index 1d71b351e57..738c855e8c8 100644 --- a/packages/swagger/src/utils/index.spec.ts +++ b/packages/swagger/src/utils/index.spec.ts @@ -11,9 +11,9 @@ describe("parseSwaggerPath()", () => { in: "path", name: "path1", required: true, - type: "string", - }, - ], + type: "string" + } + ] }, { path: "/rest/get/{path1}/{path2}", @@ -22,16 +22,16 @@ describe("parseSwaggerPath()", () => { in: "path", name: "path1", required: true, - type: "string", + type: "string" }, { in: "path", name: "path2", required: true, - type: "string", - }, - ], - }, + type: "string" + } + ] + } ]); }); @@ -44,16 +44,16 @@ describe("parseSwaggerPath()", () => { in: "path", name: "path1", required: true, - type: "string", + type: "string" }, { in: "path", name: "path2", required: true, - type: "string", - }, - ], - }, + type: "string" + } + ] + } ]); }); @@ -61,8 +61,8 @@ describe("parseSwaggerPath()", () => { expect(parseSwaggerPath("/rest/", "/get/path1/path2")).to.deep.eq([ { path: "/rest/get/path1/path2", - pathParams: [], - }, + pathParams: [] + } ]); }); @@ -70,8 +70,8 @@ describe("parseSwaggerPath()", () => { expect(parseSwaggerPath("/rest/calendar/", "/")).to.deep.eq([ { path: "/rest/calendar", - pathParams: [], - }, + pathParams: [] + } ]); }); it("should return params and path /file/:filename.json", () => { @@ -83,10 +83,10 @@ describe("parseSwaggerPath()", () => { in: "path", name: "filename", required: true, - type: "string", - }, - ], - }, + type: "string" + } + ] + } ]); }); @@ -99,10 +99,10 @@ describe("parseSwaggerPath()", () => { in: "path", name: "category", required: true, - type: "string", - }, - ], - }, + type: "string" + } + ] + } ]); }); }); diff --git a/packages/swagger/src/utils/index.ts b/packages/swagger/src/utils/index.ts index 9ca09067411..d67a0c297ec 100644 --- a/packages/swagger/src/utils/index.ts +++ b/packages/swagger/src/utils/index.ts @@ -7,7 +7,7 @@ function getVariable(subpath: string) { return { name, - postfix: splited.length ? `.${splited.join(".")}` : "", + postfix: splited.length ? `.${splited.join(".")}` : "" }; } @@ -37,7 +37,7 @@ export function parseSwaggerPath(base: string, path: PathParamsType = ""): {path paths.push({ path: current, - pathParams: [].concat(params as any), + pathParams: [].concat(params as any) }); } @@ -48,13 +48,13 @@ export function parseSwaggerPath(base: string, path: PathParamsType = ""): {path in: "path", name, type: "string", - required: true, + required: true }); if (optional && isOptional) { paths.push({ path: current, - pathParams: [].concat(params as any), + pathParams: [].concat(params as any) }); } } else { @@ -67,8 +67,8 @@ export function parseSwaggerPath(base: string, path: PathParamsType = ""): {path : [ { path: current, - pathParams: [].concat(params as any), - }, + pathParams: [].concat(params as any) + } ]; } @@ -159,6 +159,6 @@ export function getReducers(): {[key: string]: (collection: any[], value: any) = } return collection; - }, + } }; } diff --git a/packages/swagger/test/helpers/Server.ts b/packages/swagger/test/helpers/Server.ts index 57d3646d055..b061631782c 100644 --- a/packages/swagger/test/helpers/Server.ts +++ b/packages/swagger/test/helpers/Server.ts @@ -16,14 +16,14 @@ const rootDir = Path.resolve(__dirname); httpsPort: false, logger: { level: "info", - logRequest: true, + logRequest: true }, swagger: [ { path: "/api-doc", - showExplorer: true, - }, - ], + showExplorer: true + } + ] }) export class Server { @Inject() @@ -34,7 +34,7 @@ export class Server { .use(bodyParser.json()) .use( bodyParser.urlencoded({ - extended: true, + extended: true }) ) .use(cookieParser()) diff --git a/packages/swagger/test/swagger.errors.spec.ts b/packages/swagger/test/swagger.errors.spec.ts index 6e99bbddcf4..9682f6a53f7 100644 --- a/packages/swagger/test/swagger.errors.spec.ts +++ b/packages/swagger/test/swagger.errors.spec.ts @@ -28,7 +28,7 @@ class ErrorsController { @Returns(500, {type: TestModel500}) public async exampleControllerMethod() { return { - exampleItem: 1, + exampleItem: 1 }; } } @@ -38,8 +38,8 @@ describe("ErrorsParams", () => { beforeEach( PlatformTest.bootstrap(Server, { mount: { - "/rest": [ErrorsController], - }, + "/rest": [ErrorsController] + } }) ); beforeEach(() => { @@ -55,36 +55,36 @@ describe("ErrorsParams", () => { TestModel200: { properties: { exampleItem: { - type: "number", - }, + type: "number" + } }, required: ["exampleItem"], - type: "object", + type: "object" }, TestModel400: { properties: { error: { - type: "boolean", - }, + type: "boolean" + } }, required: ["error"], - type: "object", + type: "object" }, TestModel500: { properties: { error: { - type: "boolean", - }, + type: "boolean" + } }, required: ["error"], - type: "object", - }, + type: "object" + } }, info: { description: "", termsOfService: "", title: "Api documentation", - version: "1.0.0", + version: "1.0.0" }, paths: { "/rest/scenarios": { @@ -94,34 +94,34 @@ describe("ErrorsParams", () => { "200": { description: "Success", schema: { - $ref: "#/definitions/TestModel200", - }, + $ref: "#/definitions/TestModel200" + } }, "400": { description: "Bad Request", schema: { - $ref: "#/definitions/TestModel400", - }, + $ref: "#/definitions/TestModel400" + } }, "500": { description: "Internal Server Error", schema: { - $ref: "#/definitions/TestModel500", - }, - }, + $ref: "#/definitions/TestModel500" + } + } }, - tags: ["ErrorsController"], - }, - }, + tags: ["ErrorsController"] + } + } }, produces: ["application/json"], securityDefinitions: {}, swagger: "2.0", tags: [ { - name: "ErrorsController", - }, - ], + name: "ErrorsController" + } + ] }); await request.get("/rest/scenarios/4?name=name&duration=1&locale=fr-FR"); diff --git a/packages/swagger/test/swagger.integration.spec.ts b/packages/swagger/test/swagger.integration.spec.ts index a19853d8680..65aaea5717f 100644 --- a/packages/swagger/test/swagger.integration.spec.ts +++ b/packages/swagger/test/swagger.integration.spec.ts @@ -30,7 +30,7 @@ class BackAdminCtrl { @Controller({ path: "/calendars", - children: [AdminCtrl, EventCtrl], + children: [AdminCtrl, EventCtrl] }) class CalendarsController { @Get("/:id") @@ -51,8 +51,8 @@ describe("Swagger integration", () => { beforeEach( PlatformTest.bootstrap(Server, { mount: { - "/rest": [CalendarsController], - }, + "/rest": [CalendarsController] + } }) ); beforeEach(() => { @@ -67,43 +67,43 @@ describe("Swagger integration", () => { expect(result.body).to.deep.eq([ { id: 1, - name: "name", + name: "name" }, { id: 2, - name: "name", - }, + name: "name" + } ]); expect(response.body).to.deep.eq({ swagger: "2.0", tags: [ { - name: "CalendarsController", + name: "CalendarsController" }, { - name: "EventCtrl", - }, + name: "EventCtrl" + } ], consumes: ["application/json"], definitions: { Calendar: { properties: { id: { - type: "string", + type: "string" }, name: { - type: "string", - }, + type: "string" + } }, required: ["name"], - type: "object", - }, + type: "object" + } }, info: { description: "", termsOfService: "", title: "Api documentation", - version: "1.0.0", + version: "1.0.0" }, paths: { "/rest/calendars": { @@ -114,14 +114,14 @@ describe("Swagger integration", () => { description: "Success", schema: { items: { - $ref: "#/definitions/Calendar", + $ref: "#/definitions/Calendar" }, - type: "array", - }, - }, + type: "array" + } + } }, - tags: ["CalendarsController"], - }, + tags: ["CalendarsController"] + } }, "/rest/calendars/events": { get: { @@ -129,11 +129,11 @@ describe("Swagger integration", () => { operationId: "EventCtrl.get", responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["EventCtrl"], - }, + tags: ["EventCtrl"] + } }, "/rest/calendars/{id}": { get: { @@ -143,23 +143,23 @@ describe("Swagger integration", () => { in: "path", name: "id", required: true, - type: "string", - }, + type: "string" + } ], responses: { "200": { description: "Success", schema: { - $ref: "#/definitions/Calendar", - }, - }, + $ref: "#/definitions/Calendar" + } + } }, - tags: ["CalendarsController"], - }, - }, + tags: ["CalendarsController"] + } + } }, produces: ["application/json"], - securityDefinitions: {}, + securityDefinitions: {} }); }); }); diff --git a/packages/swagger/test/swagger.query.spec.ts b/packages/swagger/test/swagger.query.spec.ts index 0762dd83500..00f1c75d13b 100644 --- a/packages/swagger/test/swagger.query.spec.ts +++ b/packages/swagger/test/swagger.query.spec.ts @@ -32,8 +32,8 @@ describe("QueryParams", () => { beforeEach( PlatformTest.bootstrap(Server, { mount: { - "/rest": [QueryParamsSwaggerController], - }, + "/rest": [QueryParamsSwaggerController] + } }) ); beforeEach(() => { @@ -50,7 +50,7 @@ describe("QueryParams", () => { description: "", termsOfService: "", title: "Api documentation", - version: "1.0.0", + version: "1.0.0" }, paths: { "/rest/scenarios/1": { @@ -61,16 +61,16 @@ describe("QueryParams", () => { in: "query", name: "id", required: false, - type: "string", - }, + type: "string" + } ], responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["QueryParamsSwaggerController"], - }, + tags: ["QueryParamsSwaggerController"] + } }, "/rest/scenarios/2": { get: { @@ -80,20 +80,20 @@ describe("QueryParams", () => { collectionFormat: "multi", in: "query", items: { - type: "string", + type: "string" }, name: "ids", required: false, - type: "array", - }, + type: "array" + } ], responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["QueryParamsSwaggerController"], - }, + tags: ["QueryParamsSwaggerController"] + } }, "/rest/scenarios/3": { get: { @@ -101,21 +101,21 @@ describe("QueryParams", () => { parameters: [ { additionalProperties: { - type: "string", + type: "string" }, in: "query", name: "ids", required: false, - type: "object", - }, + type: "object" + } ], responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["QueryParamsSwaggerController"], - }, + tags: ["QueryParamsSwaggerController"] + } }, "/rest/scenarios/4": { get: { @@ -126,38 +126,38 @@ describe("QueryParams", () => { minLength: 1, name: "name", required: true, - type: "string", + type: "string" }, { in: "query", name: "duration", required: false, - type: "number", + type: "number" }, { in: "query", name: "locale", required: false, - type: "string", - }, + type: "string" + } ], responses: { "200": { - description: "Success", - }, + description: "Success" + } }, - tags: ["QueryParamsSwaggerController"], - }, - }, + tags: ["QueryParamsSwaggerController"] + } + } }, produces: ["application/json"], securityDefinitions: {}, swagger: "2.0", tags: [ { - name: "QueryParamsSwaggerController", - }, - ], + name: "QueryParamsSwaggerController" + } + ] }); await request.get("/rest/scenarios/4?name=name&duration=1&locale=fr-FR"); diff --git a/packages/testing-mongoose/src/TestMongooseContext.ts b/packages/testing-mongoose/src/TestMongooseContext.ts index 65b6e3c8749..6f61cf1740f 100644 --- a/packages/testing-mongoose/src/TestMongooseContext.ts +++ b/packages/testing-mongoose/src/TestMongooseContext.ts @@ -14,8 +14,8 @@ export class TestMongooseContext extends PlatformTest { ...options, binary: { ...(options.binary || {}), - downloadDir, - }, + downloadDir + } }); } @@ -30,7 +30,7 @@ export class TestMongooseContext extends PlatformTest { const config = await TestMongooseContext.install(options.mongod); const before = PlatformTest.bootstrap(mod, { ...options, - mongoose: config, + mongoose: config }); await before(); @@ -77,8 +77,8 @@ export class TestMongooseContext extends PlatformTest { useNewUrlParser: true, autoReconnect: true, reconnectTries: Number.MAX_VALUE, - reconnectInterval: 1000, - }, + reconnectInterval: 1000 + } }; } } diff --git a/packages/testing/src/TestContext.ts b/packages/testing/src/TestContext.ts index f539e570822..1265530ee14 100644 --- a/packages/testing/src/TestContext.ts +++ b/packages/testing/src/TestContext.ts @@ -23,7 +23,7 @@ export class TestContext extends PlatformTest { providers = providers.map((p) => { return { token: p.token || p.provide, - use: p.use, + use: p.use }; }); diff --git a/packages/testing/test/TestContext.spec.ts b/packages/testing/test/TestContext.spec.ts index 5a8ca4f3946..1010c83b901 100644 --- a/packages/testing/test/TestContext.spec.ts +++ b/packages/testing/test/TestContext.spec.ts @@ -11,7 +11,7 @@ class FakeServer { injector = new InjectorService(); settings = { - logger: {}, + logger: {} }; async start() { diff --git a/packages/typeorm/src/TypeORMModule.ts b/packages/typeorm/src/TypeORMModule.ts index 6e56194ee57..12428dd27cf 100644 --- a/packages/typeorm/src/TypeORMModule.ts +++ b/packages/typeorm/src/TypeORMModule.ts @@ -30,8 +30,8 @@ registerProvider({ try { return getCustomRepository(type, options.connection || "default"); } catch (er) {} - }, - }, + } + } ], injectable: false, async useAsyncFactory(configuration: Configuration, typeORMService: TypeORMService, injector: InjectorService) { @@ -39,7 +39,7 @@ registerProvider({ { get(type: ContainedType): T { return injector.hasProvider(type) ? injector.get(type as any)! : undefined!; - }, + } }, {fallback: true} ); @@ -48,5 +48,5 @@ registerProvider({ await typeORMModule.init(); return typeORMModule; - }, + } }); diff --git a/packages/typeorm/src/services/TypeORMService.spec.ts b/packages/typeorm/src/services/TypeORMService.spec.ts index ca1d0b56ff0..32f0f99ae42 100644 --- a/packages/typeorm/src/services/TypeORMService.spec.ts +++ b/packages/typeorm/src/services/TypeORMService.spec.ts @@ -21,7 +21,7 @@ describe("TypeORMService", () => { const connection: any = { isConnected: true, connect: Sinon.stub().resolves(), - close: Sinon.stub(), + close: Sinon.stub() }; let called = false; const connectionManager = { @@ -35,7 +35,7 @@ describe("TypeORMService", () => { return false; }), get: Sinon.stub().returns(connection), - connections: [connection], + connections: [connection] }; // @ts-ignore @@ -47,8 +47,8 @@ describe("TypeORMService", () => { logger: { info: Sinon.stub(), error: Sinon.stub(), - debug: Sinon.stub(), - }, + debug: Sinon.stub() + } } as any; // WHEN diff --git a/packages/typeorm/test/helpers/Server.ts b/packages/typeorm/test/helpers/Server.ts index 944bc3e04d7..734ad4353b3 100644 --- a/packages/typeorm/test/helpers/Server.ts +++ b/packages/typeorm/test/helpers/Server.ts @@ -17,8 +17,8 @@ const rootDir = Path.resolve(__dirname); httpsPort: false, logger: { level: "info", - logRequest: true, - }, + logRequest: true + } }) export class Server { @Inject() @@ -29,7 +29,7 @@ export class Server { .use(bodyParser.json()) .use( bodyParser.urlencoded({ - extended: true, + extended: true }) ) .use(cookieParser()) diff --git a/packages/typeorm/test/helpers/connections/ConnectionProvider.ts b/packages/typeorm/test/helpers/connections/ConnectionProvider.ts index c853fbd6ee4..afac2fadd39 100644 --- a/packages/typeorm/test/helpers/connections/ConnectionProvider.ts +++ b/packages/typeorm/test/helpers/connections/ConnectionProvider.ts @@ -23,5 +23,5 @@ registerProvider({ } return {}; - }, + } }); diff --git a/packages/typeorm/test/integration.spec.ts b/packages/typeorm/test/integration.spec.ts index 649ffc5aa08..d669b1a9728 100644 --- a/packages/typeorm/test/integration.spec.ts +++ b/packages/typeorm/test/integration.spec.ts @@ -17,16 +17,16 @@ describe("TypeORM integration", () => { type: "mongodb", url, entities: [User], - useUnifiedTopology: true, + useUnifiedTopology: true }, { name: "db2", type: "mongodb", url, entities: [User], - useUnifiedTopology: true, - }, - ], + useUnifiedTopology: true + } + ] }); await bstrp(); diff --git a/test/helper/FakeRequest.ts b/test/helper/FakeRequest.ts index 13c6cf20b52..b7776c7e91d 100644 --- a/test/helper/FakeRequest.ts +++ b/test/helper/FakeRequest.ts @@ -14,8 +14,8 @@ export class FakeRequest { public cookies: any = { test: "testValue", obj: { - test: "testValue", - }, + test: "testValue" + } }; /** * @@ -24,8 +24,8 @@ export class FakeRequest { public body: any = { test: "testValue", obj: { - test: "testValue", - }, + test: "testValue" + } }; /** * @@ -34,8 +34,8 @@ export class FakeRequest { public query: any = { test: "testValue", obj: { - test: "testValue", - }, + test: "testValue" + } }; /** * @@ -44,19 +44,19 @@ export class FakeRequest { public params: any = { test: "testValue", obj: { - test: "testValue", - }, + test: "testValue" + } }; public session: any = { test: "testValue", obj: { - test: "testValue", - }, + test: "testValue" + } }; public headers: any = { "content-type": "application/json", - accept: "application/json", + accept: "application/json" }; public ctx: RequestContext; @@ -72,13 +72,13 @@ export class FakeRequest { warn: sandbox.stub(), error: sandbox.stub(), trace: sandbox.stub(), - flush: sandbox.stub(), + flush: sandbox.stub() }; this.ctx = new RequestContext({ id: id || "id", url: url || "url", - logger, + logger }); this.ctx.data = data; diff --git a/test/helper/classes.ts b/test/helper/classes.ts index 5cfccb69c0c..5a7bd3c24cd 100644 --- a/test/helper/classes.ts +++ b/test/helper/classes.ts @@ -34,7 +34,7 @@ export class JsonFoo { serialize() { return { test: this.test, - foo: this.foo, + foo: this.foo }; } } diff --git a/test/helper/logger.ts b/test/helper/logger.ts index f982955b0c8..0fc0a54ee4a 100644 --- a/test/helper/logger.ts +++ b/test/helper/logger.ts @@ -44,7 +44,7 @@ export const $logStub: LogStub = { this.error.reset(); this.warn.reset(); this.trace.reset(); - }, + } } as any; $logStub.stub();