Last active
August 25, 2020 19:50
Revisions
-
mackignacio revised this gist
Aug 25, 2020 . 1 changed file with 1 addition and 1 deletion.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 charactersOriginal file line number Diff line number Diff line change @@ -6,6 +6,6 @@ import { Controller } from "@mayajs/core"; route: "/sample", // Name of the route }) export class SampleController { constructor( // Inject services here ) {} } -
mackignacio revised this gist
Aug 25, 2020 . 1 changed file with 1 addition and 1 deletion.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 charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import { Get, Patch, Post, Delete, Put } from "@mayajs/common"; import { Controller } from "@mayajs/core"; @Controller({ model: "./sample.model", // Name of the model for this route route: "/sample", // Name of the route }) export class SampleController { -
mackignacio revised this gist
Aug 25, 2020 . 1 changed file with 2 additions and 3 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 charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,6 @@ import { Controller } from "@mayajs/core"; route: "/sample", // Name of the route }) export class SampleController { constructor() {} } -
mackignacio revised this gist
Aug 25, 2020 . 1 changed file with 5 additions and 51 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 charactersOriginal file line number Diff line number Diff line change @@ -1,58 +1,12 @@ import { Get, Patch, Post, Delete, Put } from "@mayajs/common"; import { Controller } from "@mayajs/core"; @Controller({ model: "./sample.model", // Name of the model route: "/sample", // Name of the route }) export class SampleController { constructor() {} } -
mackignacio renamed this gist
Jul 19, 2020 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
mackignacio created this gist
Jul 19, 2020 .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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,58 @@ import { Get, Patch, Post, Delete, Put } from "@mayajs/common"; import { Request, Response, NextFunction } from "express"; import { SampleServices } from "./sample.service"; import { Controller } from "@mayajs/core"; @Controller({ model: "./sample.model", route: "/sample", }) export class SampleController { // Inject SampleServices constructor(private services: SampleServices) {} // This is a GET request equal to "/sample" @Get({ path: "/", middlewares: [] }) get(req: Request, res: Response, next: NextFunction): void { // Use a function on SampleService this.services.getSamples(); // Do some GET stuff here res.send("This is a GET request"); } // This is a GET request equal to "/sample/:id" @Get({ path: "/:id", middlewares: [] }) getId(req: Request, res: Response, next: NextFunction): void { // Do some GET stuff here res.send("This is a GET with id request"); } // This is a POST request equal to "/sample/:id/:name" @Post({ path: "/:id/:name", middlewares: [] }) post(req: Request, res: Response, next: NextFunction): void { // Do some POST stuff here res.send("This is a POST request"); } // This is a PATCH request equal to "/sample/:id/custom-path" @Patch({ path: "/:id/custom-path", middlewares: [] }) patch(req: Request, res: Response, next: NextFunction): void { // Do some PATCH stuff here res.send("This is a PATCH request"); } // This is a PUT request equal to "/sample/:id" @Put({ path: "/:id", middlewares: [] }) put(req: Request, res: Response, next: NextFunction): void { // Do some PUT stuff here res.send("This is a PUT request"); } // This is a DELETE request equal to "/sample/:id" @Delete({ path: "/:id", middlewares: [] }) delete(req: Request, res: Response, next: NextFunction): void { // Do some DELETE stuff here res.send("This is a DELETE request"); } }