Skip to content

Commit

Permalink
Merge 8a7e097 into eda82af
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhousley committed Mar 4, 2018
2 parents eda82af + 8a7e097 commit 4b05325
Show file tree
Hide file tree
Showing 53 changed files with 357 additions and 167 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ install:
- npm install
- gulp build
script:
- npm run lint
- npm test
after_success: npm run coverage
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)));
},
},
];
142 changes: 141 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"scripts": {
"test": "nyc --require ts-node/register mocha src/**/*.spec.ts --reporter spec",
"coverage": "nyc report --reporter=text-lcov | coveralls",
"lint": "tslint -p tsconfig.json -c tslint.json",
"prettier": "prettier */**/*.ts --ignore-path ./.prettierignore --write && git status",
"build": "gulp build && gulp move",
"build:lib": "gulp build --dist lib",
Expand Down Expand Up @@ -78,7 +79,8 @@
"prettier": "^1.9.2",
"sinon": "^2.1.0",
"sinon-chai": "^2.8.0",
"ts-node": "^3.2.0"
"ts-node": "^3.2.0",
"tslint": "^5.9.1"
},
"collective": {
"type": "opencollective",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const assignCustomMetadata = (
index: number,
factory: CustomParamFactory,
data?: ParamData,
...pipes: PipeTransform<any>[]
...pipes: PipeTransform<any>[],
) => ({
...args,
[`${paramtype}${CUSTOM_ROUTE_AGRS_METADATA}:${index}`]: {
Expand Down
2 changes: 1 addition & 1 deletion src/common/decorators/http/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ export * from './request-mapping.decorator';
export * from './route-params.decorator';
export * from './http-code.decorator';
export * from './create-route-param-metadata.decorator';
export * from './render.decorator';
export * from './render.decorator';
13 changes: 5 additions & 8 deletions src/common/decorators/http/route-params.decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const assignMetadata = (
paramtype: RouteParamtypes,
index: number,
data?: ParamData,
...pipes: PipeTransform<any>[]
...pipes: PipeTransform<any>[],
) => ({
...args,
[`${paramtype}:${index}`]: {
Expand All @@ -41,7 +41,7 @@ const createRouteParamDecorator = (paramtype: RouteParamtypes) => {

const createPipesRouteParamDecorator = (paramtype: RouteParamtypes) => (
data?,
...pipes: PipeTransform<any>[]
...pipes: PipeTransform<any>[],
): ParameterDecorator => (target, key, index) => {
const args = Reflect.getMetadata(ROUTE_ARGS_METADATA, target, key) || {};
const hasParamData = isNil(data) || isString(data);
Expand Down Expand Up @@ -78,38 +78,35 @@ export const Headers: (
property?: string,
) => ParameterDecorator = createRouteParamDecorator(RouteParamtypes.HEADERS);

export function Query();
export function Query(...pipes: PipeTransform<any>[]);
export function Query(property: string, ...pipes: PipeTransform<any>[]);
export function Query(
property?: string | PipeTransform<any>,
...pipes: PipeTransform<any>[]
...pipes: PipeTransform<any>[],
) {
return createPipesRouteParamDecorator(RouteParamtypes.QUERY)(
property,
...pipes,
);
}

export function Body();
export function Body(...pipes: PipeTransform<any>[]);
export function Body(property: string, ...pipes: PipeTransform<any>[]);
export function Body(
property?: string | PipeTransform<any>,
...pipes: PipeTransform<any>[]
...pipes: PipeTransform<any>[],
) {
return createPipesRouteParamDecorator(RouteParamtypes.BODY)(
property,
...pipes,
);
}

export function Param();
export function Param(...pipes: PipeTransform<any>[]);
export function Param(property: string, ...pipes: PipeTransform<any>[]);
export function Param(
property?: string | PipeTransform<any>,
...pipes: PipeTransform<any>[]
...pipes: PipeTransform<any>[],
) {
return createPipesRouteParamDecorator(RouteParamtypes.PARAM)(
property,
Expand Down
2 changes: 1 addition & 1 deletion src/common/enums/route-paramtypes.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ export enum RouteParamtypes {
HEADERS,
SESSION,
FILE,
FILES
FILES,
}
16 changes: 8 additions & 8 deletions src/common/http/http.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,48 +7,48 @@ import {
import 'rxjs/add/observable/fromPromise';

export class HttpService {
request<T = any>(config: AxiosRequestConfig): Observable<AxiosResponse<T>> {
public request<T = any>(config: AxiosRequestConfig): Observable<AxiosResponse<T>> {
return Observable.fromPromise(axios.request<T>(config));
}
get<T = any>(

public get<T = any>(
url: string,
config?: AxiosRequestConfig,
): Observable<AxiosResponse<T>> {
return Observable.fromPromise(axios.get<T>(url, config));
}

delete(
public delete(
url: string,
config?: AxiosRequestConfig,
): Observable<AxiosResponse<any>> {
return Observable.fromPromise(axios.delete(url, config));
}

head(
public head(
url: string,
config?: AxiosRequestConfig,
): Observable<AxiosResponse<any>> {
return Observable.fromPromise(axios.head(url, config));
}

post(
public post(
url: string,
data?,
config?: AxiosRequestConfig,
): Observable<AxiosResponse<any>> {
return Observable.fromPromise(axios.post(url, data, config));
}

put(
public put(
url: string,
data?,
config?: AxiosRequestConfig,
): Observable<AxiosResponse<any>> {
return Observable.fromPromise(axios.post(url, data, config));
}

patch(
public patch(
url: string,
data?,
config?: AxiosRequestConfig,
Expand Down
2 changes: 1 addition & 1 deletion src/common/http/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './http.module';
export * from './http.service';
export * from './http.service';
Loading

0 comments on commit 4b05325

Please sign in to comment.