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
import {JsonController} from "routing-controllers"; | |
import {Get, Post, Put, Patch, Delete} from "routing-controllers"; | |
import {QueryParam, Param, Body} from "routing-controllers"; | |
@JsonController() | |
export class BlogController { | |
@Get("/blogs") | |
getAll(@QueryParam("keyword", { required: true }) keyword: string) { | |
return [ |
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
@JsonController() | |
export class BlogController { | |
@Get("/blogs") | |
getAll() { | |
if (accessAllowed) | |
throw new ForbiddenError("Access is denied"); | |
return [ | |
{ id: 1, name: "Blog " + filter.keyword }, |
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
createExpressServer({ | |
container: (cls: any) => { | |
return MyContainer.get(cls); // here you use your container | |
} | |
}); |
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
createExpressServer({ | |
defaultErrorHandler: false | |
}); |
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
createExpressServer({ | |
controllerDirs: [__dirname + "/controllers"], // loads all controllers from the given directories. supports glob patterns | |
middlewareDirs: [__dirname + "/middlewares"], // loads all middlewares from the given directories. supports glob patterns | |
errorHandlerDirs: [__dirname + "/error-handlers"] // loads all error handlers from the given directories. supports glob patterns | |
}); |
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
import {Request, Response} from "express"; | |
import {JsonController, Get, Post, Put, Patch, Delete} from "routing-controllers"; | |
@JsonController() | |
export class BlogController { | |
@Get("/blogs") | |
getAll() { | |
return [ | |
{ id: 1, name: "Blog 1!" }, |
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
import {Request, Response} from "express"; | |
import {JsonController, Get, Post, Put, Patch, Delete} from "routing-controllers"; | |
@JsonController() | |
export class BlogController { | |
@Get("/blogs") | |
getAll() { | |
return this.createPromise([ | |
{ id: 1, name: "Blog 1!"}, |
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
import {Request, Response} from "express"; | |
import {Controller, Get, Post, Put, Patch, Delete} from "routing-controllers"; | |
@Controller() | |
export class BlogController { | |
@Get("/blogs") | |
getAll() { | |
return "Hello Blogs"; | |
} |
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
import "./BlogController"; | |
const app = createExpressServer(); | |
app.listen(3001); |
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
app.get("/blogs", function(req, res, next) { | |
res.send("Hello Blogs"); | |
next(); | |
}); |
NewerOlder