Skip to content

Commit

Permalink
style(@nestjs) run prettier, update code style
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Mar 11, 2018
1 parent 2a1cb06 commit 2aa4bb9
Show file tree
Hide file tree
Showing 248 changed files with 2,592 additions and 1,712 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ yarn-error.log

# tests
/test
/integration
/coverage
/.nyc_output
8 changes: 7 additions & 1 deletion examples/12-graphql-apollo/src/cats/cats.resolvers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { Component, UseGuards } from '@nestjs/common';
import { Query, Mutation, Resolver, DelegateProperty, Subscription } from '@nestjs/graphql';
import {
Query,
Mutation,
Resolver,
DelegateProperty,
Subscription,
} from '@nestjs/graphql';
import { PubSub } from 'graphql-subscriptions';

import { Cat } from './interfaces/cat.interface';
Expand Down
2 changes: 1 addition & 1 deletion examples/12-graphql-apollo/src/cats/cats.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Cat } from './interfaces/cat.interface';
export class CatsService {
private readonly cats: Cat[] = [{ id: 1, name: 'Cat', age: 5 }];

create(cat: Cat): Cat{
create(cat: Cat): Cat {
this.cats.push(cat);
return cat;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const SUBSCRIPTION_SERVER = 'SUBSCRIPTION_SERVER';
export const SUBSCRIPTION_SERVER = 'SUBSCRIPTION_SERVER';
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ export const createSubscriptionProviders = (port: number = 3001) => [
provide: SUBSCRIPTION_SERVER,
useFactory: () => {
const server = createServer();
return new Promise(resolve =>
server.listen(port, () => resolve(server)),
);
return new Promise(resolve => server.listen(port, () => resolve(server)));
},
},
];
130 changes: 63 additions & 67 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,101 +1,97 @@
const fs = require('fs');
const path = require('path');
const gulp = require('gulp');
const ts = require('gulp-typescript');
const gulpSequence = require('gulp-sequence');
const sourcemaps = require('gulp-sourcemaps');
const clean = require('gulp-clean');

const packages = {
common: ts.createProject('src/common/tsconfig.json'),
core: ts.createProject('src/core/tsconfig.json'),
microservices: ts.createProject('src/microservices/tsconfig.json'),
websockets: ts.createProject('src/websockets/tsconfig.json'),
testing: ts.createProject('src/testing/tsconfig.json'),
common: ts.createProject('src/common/tsconfig.json'),
core: ts.createProject('src/core/tsconfig.json'),
microservices: ts.createProject('src/microservices/tsconfig.json'),
websockets: ts.createProject('src/websockets/tsconfig.json'),
testing: ts.createProject('src/testing/tsconfig.json'),
};
const modules = Object.keys(packages);
const source = 'src';
const distId = process.argv.indexOf('--dist');
const dist = distId < 0 ? 'node_modules/@nestjs' : process.argv[distId + 1];

gulp.task('default', function() {
modules.forEach(module => {
gulp.watch(
[`${source}/${module}/**/*.ts`, `${source}/${module}/*.ts`],
[module]
);
});
modules.forEach(module => {
gulp.watch(
[`${source}/${module}/**/*.ts`, `${source}/${module}/*.ts`],
[module],
);
});
});

gulp.task('copy:ts', function(){
return gulp.src(['src/**/*.ts'])
.pipe(gulp.dest('./lib'));
gulp.task('copy:ts', function() {
return gulp.src(['src/**/*.ts']).pipe(gulp.dest('./lib'));
});

gulp.task('clean:lib', function(){
return gulp.src([
'lib/**/*.js.map',
'lib/**/*.ts',
'!lib/**/*.d.ts'
], {read: false})
.pipe(clean());
gulp.task('clean:lib', function() {
return gulp
.src(['lib/**/*.js.map', 'lib/**/*.ts', '!lib/**/*.d.ts'], { read: false })
.pipe(clean());
});

modules.forEach(module => {
gulp.task(module, () => {
return packages[module]
.src()
.pipe(packages[module]())
.pipe(gulp.dest(`${dist}/${module}`));
});
gulp.task(module, () => {
return packages[module]
.src()
.pipe(packages[module]())
.pipe(gulp.dest(`${dist}/${module}`));
});
});

modules.forEach(module => {
gulp.task(module + ':dev', () => {
return packages[module]
.src()
.pipe(sourcemaps.init())
.pipe(packages[module]())
.pipe(sourcemaps.mapSources(sourcePath => './' + sourcePath.split('/').pop()))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(`${dist}/${module}`));
});
gulp.task(module + ':dev', () => {
return packages[module]
.src()
.pipe(sourcemaps.init())
.pipe(packages[module]())
.pipe(
sourcemaps.mapSources(sourcePath => './' + sourcePath.split('/').pop()),
)
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(`${dist}/${module}`));
});
});

gulp.task('build', function(cb) {
gulpSequence('common', modules.filter((module) => module !== 'common'), cb);
gulpSequence('common', modules.filter(module => module !== 'common'), cb);
});

gulp.task('build:dev', function(cb) {
gulpSequence(
'common:dev',
modules.filter((module) => module !== 'common').map((module) => module + ':dev'),
'copy:ts',
cb);
gulpSequence(
'common:dev',
modules
.filter(module => module !== 'common')
.map(module => module + ':dev'),
'copy:ts',
cb,
);
});

function getFolders(dir) {
return fs.readdirSync(dir).filter(function(file) {
return fs.statSync(path.join(dir, file)).isDirectory();
});
}
gulp.task('move', function() {
gulp.src(['node_modules/@nestjs/**/*']).pipe(
gulp.dest('examples/01-cats-app/node_modules/@nestjs')
).pipe(
gulp.dest('examples/02-gateways/node_modules/@nestjs')
).pipe(
gulp.dest('examples/03-microservices/node_modules/@nestjs')
).pipe(
gulp.dest('examples/04-injector/node_modules/@nestjs')
).pipe(
gulp.dest('examples/05-sql-typeorm/node_modules/@nestjs')
).pipe(
gulp.dest('examples/06-mongoose/node_modules/@nestjs')
).pipe(
gulp.dest('examples/07-sequelize/node_modules/@nestjs')
).pipe(
gulp.dest('examples/08-passport/node_modules/@nestjs')
).pipe(
gulp.dest('examples/09-babel-example/node_modules/@nestjs')
).pipe(
gulp.dest('examples/11-swagger/node_modules/@nestjs')
).pipe(
gulp.dest('examples/12-graphql-apollo/node_modules/@nestjs')
).pipe(
gulp.dest('examples/15-mvc/node_modules/@nestjs')
);
const getDirs = (base) => getFolders(base)
.map((path) => `${base}/${path}`);

const examplesDirs = getDirs('examples');
const integrationDirs = getDirs('integration');
const directories = examplesDirs.concat(integrationDirs);

let stream = gulp
.src(['node_modules/@nestjs/**/*']);

directories.forEach((dir) => {
stream = stream.pipe(gulp.dest(dir + '/node_modules/@nestjs'));
});
});
44 changes: 22 additions & 22 deletions lib/common/constants.d.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
export declare const metadata: {
MODULES: string;
IMPORTS: string;
COMPONENTS: string;
CONTROLLERS: string;
EXPORTS: string;
MODULES: string;
IMPORTS: string;
COMPONENTS: string;
CONTROLLERS: string;
EXPORTS: string;
};
export declare const SHARED_MODULE_METADATA = "__sharedModule__";
export declare const GLOBAL_MODULE_METADATA = "__globalModule__";
export declare const PATH_METADATA = "path";
export declare const PARAMTYPES_METADATA = "design:paramtypes";
export declare const SELF_DECLARED_DEPS_METADATA = "self:paramtypes";
export declare const METHOD_METADATA = "method";
export declare const ROUTE_ARGS_METADATA = "__routeArguments__";
export declare const CUSTOM_ROUTE_AGRS_METADATA = "__customRouteArgs__";
export declare const EXCEPTION_FILTERS_METADATA = "__exceptionFilters__";
export declare const FILTER_CATCH_EXCEPTIONS = "__filterCatchExceptions__";
export declare const PIPES_METADATA = "__pipes__";
export declare const GUARDS_METADATA = "__guards__";
export declare const RENDER_METADATA = "__renderTemplate__";
export declare const INTERCEPTORS_METADATA = "__interceptors__";
export declare const HTTP_CODE_METADATA = "__httpCode__";
export declare const GATEWAY_MIDDLEWARES = "__gatewayMiddlewares";
export declare const MODULE_PATH = "__module_path__";
export declare const SHARED_MODULE_METADATA = '__sharedModule__';
export declare const GLOBAL_MODULE_METADATA = '__globalModule__';
export declare const PATH_METADATA = 'path';
export declare const PARAMTYPES_METADATA = 'design:paramtypes';
export declare const SELF_DECLARED_DEPS_METADATA = 'self:paramtypes';
export declare const METHOD_METADATA = 'method';
export declare const ROUTE_ARGS_METADATA = '__routeArguments__';
export declare const CUSTOM_ROUTE_AGRS_METADATA = '__customRouteArgs__';
export declare const EXCEPTION_FILTERS_METADATA = '__exceptionFilters__';
export declare const FILTER_CATCH_EXCEPTIONS = '__filterCatchExceptions__';
export declare const PIPES_METADATA = '__pipes__';
export declare const GUARDS_METADATA = '__guards__';
export declare const RENDER_METADATA = '__renderTemplate__';
export declare const INTERCEPTORS_METADATA = '__interceptors__';
export declare const HTTP_CODE_METADATA = '__httpCode__';
export declare const GATEWAY_MIDDLEWARES = '__gatewayMiddlewares';
export declare const MODULE_PATH = '__module_path__';
4 changes: 3 additions & 1 deletion lib/common/decorators/core/bind.decorator.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
* Useful when the language doesn't provide a 'Parameter Decorators' feature
* @param {} ...decorators
*/
export declare function Bind(...decorators: any[]): (target: object, key: any, descriptor: any) => any;
export declare function Bind(
...decorators: any[]
): (target: object, key: any, descriptor: any) => any;
4 changes: 3 additions & 1 deletion lib/common/decorators/core/exception-filters.decorator.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ import { ExceptionFilter } from '../../index';
*
* @param {ExceptionFilter[]} ...filters (instances)
*/
export declare const UseFilters: (...filters: ExceptionFilter[]) => (target: object, key?: any, descriptor?: any) => any;
export declare const UseFilters: (
...filters: ExceptionFilter[]
) => (target: object, key?: any, descriptor?: any) => any;
5 changes: 4 additions & 1 deletion lib/common/decorators/core/reflect-metadata.decorator.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
* Assigns the metadata to the class / function under specified `key`.
* This metadata can be reflected using `Reflector` class.
*/
export declare const ReflectMetadata: (metadataKey: any, metadataValue: any) => (target: object, key?: any, descriptor?: any) => any;
export declare const ReflectMetadata: (
metadataKey: any,
metadataValue: any,
) => (target: object, key?: any, descriptor?: any) => any;
4 changes: 3 additions & 1 deletion lib/common/decorators/core/use-guards.decorator.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@
*
* @param {} ...guards (types)
*/
export declare function UseGuards(...guards: any[]): (target: object, key?: any, descriptor?: any) => any;
export declare function UseGuards(
...guards: any[]
): (target: object, key?: any, descriptor?: any) => any;
4 changes: 3 additions & 1 deletion lib/common/decorators/core/use-interceptors.decorator.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@
*
* @param {} ...interceptors (types)
*/
export declare function UseInterceptors(...interceptors: any[]): (target: object, key?: any, descriptor?: any) => any;
export declare function UseInterceptors(
...interceptors: any[]
): (target: object, key?: any, descriptor?: any) => any;
4 changes: 3 additions & 1 deletion lib/common/decorators/core/use-pipes.decorator.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ import { PipeTransform } from '../../interfaces/index';
*
* @param {PipeTransform[]} ...pipes (instances)
*/
export declare function UsePipes(...pipes: PipeTransform<any>[]): (target: object, key?: any, descriptor?: any) => any;
export declare function UsePipes(
...pipes: PipeTransform<any>[]
): (target: object, key?: any, descriptor?: any) => any;
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ import { PipeTransform } from '../../index';
* Create route params custom decorator
* @param factory
*/
export declare function createRouteParamDecorator(factory: CustomParamFactory): (data?: any, ...pipes: PipeTransform<any>[]) => ParameterDecorator;
export declare function createRouteParamDecorator(
factory: CustomParamFactory,
): (data?: any, ...pipes: PipeTransform<any>[]) => ParameterDecorator;
4 changes: 3 additions & 1 deletion lib/common/decorators/http/request-mapping.decorator.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'reflect-metadata';
import { RequestMappingMetadata } from '../../interfaces/request-mapping-metadata.interface';
export declare const RequestMapping: (metadata?: RequestMappingMetadata) => MethodDecorator;
export declare const RequestMapping: (
metadata?: RequestMappingMetadata,
) => MethodDecorator;
/**
* Routes HTTP POST requests to the specified path.
*/
Expand Down
23 changes: 16 additions & 7 deletions lib/common/decorators/http/route-params.decorator.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import 'reflect-metadata';
import { PipeTransform } from '../../index';
export declare type ParamData = object | string | number;
export interface RouteParamsMetadata {
[prop: number]: {
index: number;
data?: ParamData;
};
[prop: number]: {
index: number;
data?: ParamData;
};
}
export declare const Request: () => ParameterDecorator;
export declare const Response: () => ParameterDecorator;
Expand All @@ -16,12 +16,21 @@ export declare const UploadedFiles: () => ParameterDecorator;
export declare const Headers: (property?: string) => ParameterDecorator;
export declare function Query(): any;
export declare function Query(...pipes: PipeTransform<any>[]): any;
export declare function Query(property: string, ...pipes: PipeTransform<any>[]): any;
export declare function Query(
property: string,
...pipes: PipeTransform<any>[]
): any;
export declare function Body(): any;
export declare function Body(...pipes: PipeTransform<any>[]): any;
export declare function Body(property: string, ...pipes: PipeTransform<any>[]): any;
export declare function Body(
property: string,
...pipes: PipeTransform<any>[]
): any;
export declare function Param(): any;
export declare function Param(...pipes: PipeTransform<any>[]): any;
export declare function Param(property: string, ...pipes: PipeTransform<any>[]): any;
export declare function Param(
property: string,
...pipes: PipeTransform<any>[]
): any;
export declare const Req: () => ParameterDecorator;
export declare const Res: () => ParameterDecorator;
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export declare class InvalidModuleConfigException extends Error {
constructor(property: string);
constructor(property: string);
}
Loading

0 comments on commit 2aa4bb9

Please sign in to comment.