Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
64 changed files
with
2,016 additions
and
153 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
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
13 changes: 7 additions & 6 deletions
13
.../snippets/controllers/raw-req-res-next.ts → .../docs/snippets/controllers/inject-next.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,19 +1,20 @@ | ||
import {Controller, Get, Next, Req, Res} from "@tsed/common"; | ||
import * as Express from "express"; | ||
import {promisify} from "util"; | ||
|
||
@Controller("/calendars") | ||
export class CalendarCtrl { | ||
@Get("/:id") | ||
get( | ||
async get( | ||
@Req() request: Express.Request, | ||
@Res() response: Express.Response, | ||
@Next() next: Express.NextFunction | ||
): void { | ||
) { | ||
setTimeout(() => { | ||
response | ||
.status(200) | ||
.send({id: request.params.id, name: "test"}); | ||
next(); | ||
myExpressMiddleware(request, response, next) | ||
}); | ||
|
||
// But it's also possible to do this | ||
await promisify(myExpressMiddleware)(request, response) | ||
} | ||
} |
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,14 @@ | ||
import {Controller, Get, Req, Res} from "@tsed/common"; | ||
import {IncomingMessage, ServerResponse} from "http"; | ||
|
||
@Controller("/calendars") | ||
export class CalendarCtrl { | ||
@Get("/:id") | ||
get( | ||
@Req() request: IncomingMessage, | ||
@Res() response: ServerResponse | ||
): void { | ||
console.log(request); // IncomingMessage | ||
console.log(response); // ServerResponse | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import {Controller, Get, Req, Res, PlatformRequest, PlatformResponse} from "@tsed/common"; | ||
|
||
@Controller("/calendars") | ||
export class CalendarCtrl { | ||
@Get("/:id") | ||
get( | ||
@Req() request: PlatformRequest, | ||
@Res() response: PlatformResponse | ||
): void { | ||
console.log(request) // PlatformRequest | ||
console.log(response) // PlatformResponse | ||
|
||
response | ||
.status(200) | ||
.body({id: request.params.id, name: "test"}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import {Controller, Get, Req, Res} from "@tsed/common"; | ||
|
||
@Controller("/calendars") | ||
export class CalendarCtrl { | ||
@Get("/:id") | ||
get( | ||
@Req() request: any, | ||
@Res() response: any | ||
): void { | ||
console.log(request) // Express.Request or Koa.Request | ||
console.log(response) // Express.Request or Koa.Request | ||
response | ||
.status(200) | ||
.send({id: request.params.id, name: "test"}); | ||
} | ||
} |
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.