Skip to content

Commit

Permalink
fix: flow dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ccamensuli committed Jun 13, 2024
1 parent cda9879 commit 7c127d5
Show file tree
Hide file tree
Showing 107 changed files with 19,048 additions and 14,782 deletions.
41 changes: 22 additions & 19 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
import { resolve } from "node:path";
import { Kernel, Module, modules } from "nodefony";
import { controllers } from "@nodefony/framework";
import AppController from "./nodefony/controllers/AppController";
import config from "./nodefony/config/config";
//import http from "@nodefony/http";
//import security from "@nodefony/security";
//import framework from "@nodefony/framework";
//import sequelize from "@nodefony/sequelize";
//import Test from "@nodefony/test";
import AppController from "./nodefony/controllers/AppController";

/**
* The App class extends the Module class and represents an application entry point.
*/
@modules([
"@nodefony/sequelize",
"@nodefony/mongoose",
//"@nodefony/mongoose",
"@nodefony/http",
"@nodefony/framework",
"@nodefony/security",
"@nodefony/test",
//Test,
//"@nodefony/redis",
])
@controllers([AppController])
class App extends Module {
Expand All @@ -36,23 +39,23 @@ class App extends Module {
* @param kernel - An instance of the Kernel class.
* @returns A promise that resolves to the instance of the App class.
*/
// async initialize(kernel: Kernel): Promise<this> {
// if (
// this.kernel?.environment === "production" ||
// this.kernel?.environment === "staging"
// ) {
// //await this.kernel?.addModule(http);
// //await this.kernel?.addModule(security);
// //await this.kernel?.addModule(framework);
// //await this.kernel?.addModule(sequelize);
// } else {
// //await this.kernel?.loadModule("@nodefony/http", false);
// //await this.kernel?.loadModule("@nodefony/security", false);
// //await this.kernel?.loadModule("@nodefony/framework", false);
// //await this.kernel?.loadModule("@nodefony/sequelize", false);
// }
// return this;
// }
async initialize(kernel: Kernel): Promise<this> {
// if (
// this.kernel?.environment === "production" ||
// this.kernel?.environment === "staging"
// ) {
// //await this.kernel?.addModule(http);
// //await this.kernel?.addModule(security);
// //await this.kernel?.addModule(framework);
// //await this.kernel?.addModule(sequelize);
// } else {
// //await this.kernel?.loadModule("@nodefony/http", false);
// //await this.kernel?.loadModule("@nodefony/security", false);
// //await this.kernel?.loadModule("@nodefony/framework", false);
// //await this.kernel?.loadModule("@nodefony/sequelize", false);
// }
return this;
}

/**
* Action of modulewhen kernel emit event onStart.
Expand Down
53 changes: 6 additions & 47 deletions nodefony/controllers/AppController.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { resolve } from "node:path";
import { inject, Fetch, FileClass } from "nodefony";
import { DefineRoute, DefineController, Controller } from "@nodefony/framework";
import { route, controller, Controller } from "@nodefony/framework";
import { ContextType } from "@nodefony/http";

@controller("/app")
class AppController extends Controller {
static override basepath: string = "/app";
constructor(context: ContextType) {
super("app", context);
}
Expand All @@ -14,7 +14,7 @@ class AppController extends Controller {
return this;
}

@DefineRoute("route1", { path: "", method: "GET" })
@route("route-app-twig", { path: "", method: "GET" })
async method1() {
const view = resolve(
this.module?.path as string,
Expand All @@ -27,10 +27,9 @@ class AppController extends Controller {
});
}

@DefineRoute("route4", {
path: "/add/{name}",
requirements: { methods: ["GET", "POST"] },
defaults: { name: "cci" },
@route("route-app-ejs", {
path: "/ejs",
requirements: { methods: ["GET"] },
})
async method4(name: string) {
const view = resolve(
Expand All @@ -45,46 +44,6 @@ class AppController extends Controller {
}
);
}

@DefineRoute("route3", { method: "DELETE" })
async method3() {
return this.renderJson(this.context?.metaData);
}

@DefineRoute("route2", { path: "/add", requirements: { methods: "POST" } })
async method2() {
console.log("call method2");
return this.renderJson({ foo: "bar" });
}

@DefineRoute("route6", {
path: "/ele/{metier}/{format}/add",
defaults: { format: "cci" },
})
async 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) {
const view = resolve(
this.module?.path as string,
"nodefony",
"views",
"index.twig"
);
return this.renderTwigView(view, { metier, format, method });
}

@DefineRoute("route5", {
path: "*",
})
async method5() {
console.log("other route for app");
return this.renderJson(this.route);
}
}

export default AppController;
2 changes: 1 addition & 1 deletion nodefony/views/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</head>

<body>
<h1><%= nodefony.name %></h1>
<h1><%= nodefony.name %> EJS</h1>
<h1><%= name %></h1>
</body>
</html>
2 changes: 1 addition & 1 deletion nodefony/views/index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</head>

<body>
<h1>{{nodefony.name}}</h1>
<h1>{{nodefony.name}} Twig</h1>
{% block body %}{% endblock %}
{% block javascripts %} {% endblock %}
</body>
Expand Down
6 changes: 0 additions & 6 deletions nodemon.json

This file was deleted.

Loading

0 comments on commit 7c127d5

Please sign in to comment.