forked from nestjs/nest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(@nestjs) fix typos, extract module compiler, fix broken guards
- Loading branch information
1 parent
59fb9c7
commit 5cfb0bf
Showing
63 changed files
with
500 additions
and
390 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import * as request from 'supertest'; | ||
import { Test } from '@nestjs/testing'; | ||
import { INestApplication } from '@nestjs/common'; | ||
import { ApplicationModule } from './../src/app.module'; | ||
|
||
describe('Hello world (default adapter)', () => { | ||
let server; | ||
let app: INestApplication; | ||
|
||
beforeEach(async () => { | ||
const module = await Test.createTestingModule({ | ||
imports: [ApplicationModule], | ||
}) | ||
.compile(); | ||
|
||
app = module.createNestApplication(); | ||
server = app.getHttpServer(); | ||
await app.init(); | ||
}); | ||
|
||
it(`should execute locally injected pipe`, () => { | ||
return request(server) | ||
.get('/hello/local-pipe/1') | ||
.expect(200) | ||
.expect({ | ||
id: '1', | ||
}); | ||
}); | ||
|
||
afterEach(async () => { | ||
await app.close(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { HelloController } from './hello.controller'; | ||
import { HelloService } from './hello.service'; | ||
import { UsersService } from './users/users.service'; | ||
|
||
@Module({ | ||
controllers: [HelloController], | ||
providers: [HelloService], | ||
providers: [HelloService, UsersService], | ||
}) | ||
export class HelloModule {} |
11 changes: 11 additions & 0 deletions
11
integration/hello-world/src/hello/users/user-by-id.pipe.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { PipeTransform, Injectable, ArgumentMetadata } from '@nestjs/common'; | ||
import { UsersService } from './users.service'; | ||
|
||
@Injectable() | ||
export class UserByIdPipe implements PipeTransform<string> { | ||
constructor(private readonly usersService: UsersService) {} | ||
|
||
transform(value: string, metadata: ArgumentMetadata) { | ||
return this.usersService.findById(value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
|
||
@Injectable() | ||
export class UsersService { | ||
findById(id: string) { | ||
return { id }; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...es/common/interfaces/middlewares/index.ts → ...ges/common/interfaces/middleware/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export * from './middleware-config-proxy.interface'; | ||
export * from './middlewares-consumer.interface'; | ||
export * from './middleware-consumer.interface'; | ||
export * from './middleware-configuration.interface'; | ||
export * from './nest-middleware.interface'; | ||
export * from './middleware.interface'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...res/middleware-configuration.interface.ts → ...are/middleware-configuration.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { Type } from './../type.interface'; | ||
import { Type } from '../type.interface'; | ||
|
||
export interface MiddlewareConfiguration { | ||
middlewares: any; | ||
middleware: any; | ||
forRoutes: (Type<any> | string)[]; | ||
} |
6 changes: 3 additions & 3 deletions
6
...lewares/middlewares-consumer.interface.ts → ...ddleware/middleware-consumer.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import { MiddlewareConfigProxy } from './middleware-config-proxy.interface'; | ||
|
||
export interface MiddlewaresConsumer { | ||
export interface MiddlewareConsumer { | ||
/** | ||
* Takes single middleware class or array of classes | ||
* that subsequently could be attached to the passed either routes or controllers. | ||
* | ||
* @param {any|any[]} middlewares | ||
* @param {any|any[]} middleware | ||
* @returns {MiddlewareConfigProxy} | ||
*/ | ||
apply(middlewares: any | any[]): MiddlewareConfigProxy; | ||
apply(middleware: any | any[]): MiddlewareConfigProxy; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export type MiddlewareFunction = (req?, res?, next?) => any; |
3 changes: 2 additions & 1 deletion
3
.../middlewares/nest-middleware.interface.ts → ...s/middleware/nest-middleware.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export type MiddlewareFunction = (req, res, next) => any | Promise<any>; | ||
import { MiddlewareFunction } from './middleware.interface'; | ||
|
||
export interface NestMiddleware { | ||
resolve(...args): MiddlewareFunction | Promise<MiddlewareFunction>; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { MiddlewaresConsumer } from '../middlewares/middlewares-consumer.interface'; | ||
import { MiddlewareConsumer } from '../middleware/middleware-consumer.interface'; | ||
|
||
export interface NestModule { | ||
configure(consumer: MiddlewaresConsumer): MiddlewaresConsumer | void; | ||
configure(consumer: MiddlewareConsumer): MiddlewareConsumer | void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.