Skip to content

Commit

Permalink
fix; module framework flow dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ccamensuli committed Mar 6, 2024
1 parent f82544c commit ce29e61
Show file tree
Hide file tree
Showing 54 changed files with 4,668 additions and 802 deletions.
18 changes: 10 additions & 8 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
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 http from "@nodefony/http";
//import security from "@nodefony/security";
//import framework from "@nodefony/framework";
//import sequelize from "@nodefony/sequelize";

/**
* The App class extends the Module class and represents an application entry point.
Expand All @@ -15,6 +16,7 @@ import sequelize from "@nodefony/sequelize";
"@nodefony/security",
"@nodefony/framework",
"@nodefony/sequelize",
"@nodefony/test",
])
@controllers([AppController])
class App extends Module {
Expand All @@ -38,10 +40,10 @@ class App extends Module {
// this.kernel?.environment === "production" ||
// this.kernel?.environment === "staging"
// ) {
// //await this.kernel?.use(http);
// //await this.kernel?.use(security);
// //await this.kernel?.use(framework);
// //await this.kernel?.use(sequelize);
// //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);
Expand Down
32 changes: 9 additions & 23 deletions nodefony/controllers/AppController.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,28 @@
import { resolve } from "node:path";

import { inject, Fetch, FileClass } from "nodefony";
import { DefineRoute, DefineController, Controller } from "@nodefony/framework";
import { ContextType } from "@nodefony/http";
import https from "node:https";
//import { twig } from "@nodefony/framework";

class AppController extends Controller {
static override basepath: string = "/app";
constructor(
context: ContextType,
@inject("Fetch") private fetchService: Fetch
) {
constructor(context: ContextType) {
super("app", context);
}

async initialize() {
//await this.startSession();
//let response = await this.fetchService.fetch("https://google.fr");
//TODO add certificat client in serfice for unit test
// const agent = new https.Agent({
// rejectUnauthorized: false,
// });
// const response = await this.fetchService.fetch("https://localhost:5152", {
// agent,
// });
// console.log(response.headers, response.status, response.statusText);
await this.startSession("app");
return this;
}

@DefineRoute("route1", { path: "", method: "GET" })
async method1() {
//await this.startSession();
const view = resolve(
this.module?.path as string,
"nodefony",
"views",
"index.twig"
);
return this.renderTwigView(view, this.metaData).catch((e) => {
return this.renderTwigView(view, this.context?.metaData).catch((e) => {
throw e;
});
}
Expand All @@ -55,14 +39,16 @@ class AppController extends Controller {
"views",
"index.ejs"
);
return this.renderEjsView(view, { name, ...this.metaData }).catch((e) => {
throw e;
});
return this.renderEjsView(view, { name, ...this.context?.metaData }).catch(
(e) => {
throw e;
}
);
}

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

@DefineRoute("route2", { path: "/add", requirements: { methods: "POST" } })
Expand Down
42 changes: 21 additions & 21 deletions nodefony/views/index.ejs
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
<!doctype html>
<html lang="{{nodefony.local|escape}}">
<head>
<html lang="<%= nodefony.locale %>">
<head>
<meta charset="utf-8" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<meta name="generator" content="Nodefony (https://nodefony.net)" />
<meta
name="keywords"
content="web,Framework,realtime,node.js,symfony,javascript,npm,linux"
/>
<meta
name="description"
content="Node.js full-stack web framework Symfony Like"
/>

<meta charset="utf-8">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="generator" content="Nodefony (https://nodefony.net)">
<meta name="keywords" content="web,Framework,realtime,node.js,symfony,javascript,npm,linux">
<meta name="description" content="Node.js full-stack web framework Symfony Like">

<title><%= nodefony.name %></title>

</head>

<body>

<h1><%= nodefony.name %></h1>
<h1><%= name %></h1>


</body>
<title><%= nodefony.name %></title>
</head>

<body>
<h1><%= nodefony.name %></h1>
<h1><%= name %></h1>
</body>
</html>
Loading

0 comments on commit ce29e61

Please sign in to comment.