-
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.
fix: add variable router on controller call
- Loading branch information
1 parent
57d72f1
commit dce3fc1
Showing
21 changed files
with
359 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
//import { Service, Container, Module } from "nodefony"; | ||
import { inject, Fetch } from "nodefony"; | ||
import { DefineRoute, DefineController, Controller } from "@nodefony/framework"; | ||
import { ContextType } from "@nodefony/http"; | ||
|
||
class AppController extends Controller { | ||
static override basepath: string = "/app"; | ||
constructor( | ||
context: ContextType, | ||
@inject("Fetch") private fetch: Fetch | ||
) { | ||
super("app", context); | ||
} | ||
|
||
async initialize() { | ||
//console.log("passs initialize"); | ||
//await this.startSession(); | ||
return this; | ||
} | ||
|
||
@DefineRoute("route1", { path: "/", method: "GET" }) | ||
async method1() { | ||
console.log("call method", this.fetch.library); | ||
//await this.startSession(); | ||
return this.renderJson({ foo: "bar" }); | ||
} | ||
|
||
@DefineRoute("route3", { method: "DELETE" }) | ||
method3() { | ||
console.log("call method3", this.route); | ||
} | ||
|
||
@DefineRoute("route2", { path: "/add", requirements: { methods: "POST" } }) | ||
method2() { | ||
console.log("call method2"); | ||
return this.renderJson({ foo: "bar" }); | ||
} | ||
|
||
@DefineRoute("route4", { | ||
path: "/add/{name}", | ||
requirements: { methods: ["GET", "POST"] }, | ||
defaults: { name: "cci" }, | ||
}) | ||
method4(name: string) { | ||
console.log("call method4", name, this.route); | ||
return this.renderJson({ name }); | ||
} | ||
|
||
@DefineRoute("route6", { | ||
path: "/ele/{metier}/{format}/add", | ||
defaults: { format: "cci" }, | ||
}) | ||
method6() { | ||
console.log("other route for app"); | ||
return this.renderJson({ foo: "bar" }); | ||
} | ||
@DefineRoute("route7", { | ||
path: "/ele/{metier}/{format}/{method}/add", | ||
}) | ||
method7(metier: string, format: string, method: string) { | ||
return this.renderJson({ metier, format, method }); | ||
} | ||
|
||
@DefineRoute("route5", { | ||
path: "*", | ||
}) | ||
method5() { | ||
console.log("other route for app"); | ||
} | ||
} | ||
|
||
export default AppController; |
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
62 changes: 0 additions & 62 deletions
62
src/packages/@nodefony/framework/nodefony/controller/testController.ts
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
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.