Skip to content

Commit

Permalink
fix: flow dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ccamensuli committed Jul 9, 2024
1 parent d576cf4 commit a431772
Show file tree
Hide file tree
Showing 46 changed files with 6,685 additions and 1,394 deletions.
3 changes: 3 additions & 0 deletions nodefony/config/modules/http-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,7 @@ export default {
session: {
handler: "sequelize",
},
formidable: {
uploadDir: "./tmp/upload",
},
};
813 changes: 486 additions & 327 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
],
"dependencies": {
"@nodefony/test": "file:src/modules/test",
"pm2": " 5.4.1"
"pm2": "5.4.2"
},
"devDependencies": {
"@rollup/plugin-commonjs": "26.0.1",
Expand All @@ -38,17 +38,17 @@
"@rollup/plugin-replace": "5.0.7",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "11.1.6",
"@types/node": "20.14.9",
"@typescript-eslint/eslint-plugin": "7.15.0",
"@typescript-eslint/parser": "7.15.0",
"@types/node": "20.14.10",
"@typescript-eslint/eslint-plugin": "7.16.0",
"@typescript-eslint/parser": "7.16.0",
"eslint": "9.6.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-prettier": "5.1.3",
"mkdirp": "3.0.1",
"nodemon": "3.1.4",
"prettier": "3.3.2",
"rimraf": "5.0.7",
"rollup": "4.18.0",
"rimraf": "6.0.0",
"rollup": "4.18.1",
"rollup-plugin-copy": "3.5.0",
"rollup-sourcemap-path-transform": "1.0.4",
"tslib": "2.6.3",
Expand Down
4 changes: 3 additions & 1 deletion src/modules/test/nodefony/controller/DefaultController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ class DefaultController extends Controller {

@route("index4", { path: "/index4" })
index4() {
return this.render({});
return this.render({
route: this.route,
});
}
}

Expand Down
30 changes: 25 additions & 5 deletions src/modules/test/nodefony/controller/HtmlController.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Controller, route, controller } from "@nodefony/framework";
import { Context } from "@nodefony/http";
import { Context, HttpError } from "@nodefony/http";
import { resolve } from "node:path";
//import { inject, Error } from "nodefony";

Expand Down Expand Up @@ -32,10 +32,10 @@ class HtmlController extends Controller {
name="description"
content="Node.js full-stack web framework Symfony Like"
/>
<title>Nodefony</title>
<title>Nodefony sinple text</title>
</head>
<body>
<h1>Nodefony</h1>
<h1>Nodefony sinple text</h1>
</body>
</html>`;
return this.render(html);
Expand All @@ -49,7 +49,7 @@ class HtmlController extends Controller {
@route("index-file-stream", { path: "/stream" })
stream1() {
const file = resolve(this.module?.path as string, "tsconfig.json");
return this.streamFile(file);
return this.streamFile(file, { "content-type": "application/json" });
}

@route("index-file-donwload", { path: "/download" })
Expand All @@ -66,7 +66,6 @@ class HtmlController extends Controller {
// "test",
// "chico_buarque.mp3"
// );
//console.log(this.session?.id);
const file = resolve(
this.module?.path as string,
"public",
Expand All @@ -75,6 +74,27 @@ class HtmlController extends Controller {
);
return this.renderMediaStream(file);
}

@route("index-upload1", {
path: "/upload",
requirements: { methods: ["POST", "PUT"] },
})
upload() {
return this.renderJson(this.queryFile);
}

@route("index-upload-error", {
path: "/uploaderror",
requirements: { methods: ["POST", "PUT"] },
})
upload2() {
// console.log(this.queryFile);
// console.log({
// result: this.queryFile,
// ...this.context?.metaData,
// });
throw new HttpError(undefined, 400, this.context);
}
}

export default HtmlController;
58 changes: 36 additions & 22 deletions src/modules/test/nodefony/controller/RouteController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,25 @@ class RouteController extends Controller {
return this;
}

@route("route-app-ejs", {
@route("route-test-1", {
path: "",
})
async method1() {
return this.renderJson(this.route);
}
@route("route-test-2", {
path: "*",
})
async method2() {
return this.renderJson(this.route);
}

@route("route-test-3", {
path: "/ejs/{name}",
requirements: { methods: ["GET", "POST"] },
requirements: { methods: ["GET", "POST", "DELETE"] },
defaults: { name: "cci" },
})
async method4(name: string) {
async method3(name: string) {
const view = resolve(
this.module?.path as string,
"nodefony",
Expand All @@ -33,26 +46,27 @@ class RouteController extends Controller {
);
}

@route("route3", { method: "DELETE" })
async method3() {
return this.renderJson(this.context?.metaData);
@route("route-test-4", {
path: "/{name}/move",
requirements: { methods: ["PUT", "DELETE"] },
})
async method4(name: string) {
return this.renderJson({ name, ...this.context?.metaData });
}

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

@route("route6", {
@route("route-test-6", {
path: "/ele/{metier}/{format}/add",
defaults: { format: "cci" },
})
async method6() {
console.log("other route for app");
return this.renderJson({ foo: "bar" });
async method6(metier: string, format: string) {
return this.renderJson({ metier, format });
}
@route("route7", {
@route("route-test-7", {
path: "/ele/{metier}/{format}/{method}/add",
})
method7(metier: string, format: string, method: string) {
Expand All @@ -62,14 +76,14 @@ class RouteController extends Controller {
"views",
"index.twig"
);
return this.renderTwig(view, { metier, format, method });
}

@route("route5", {
path: "*",
})
async method5() {
return this.renderJson(this.route);
return this.renderTwig(view, {
routing: {
metier,
format,
method,
},
...this.context?.metaData,
});
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ class WebsocketController extends Controller {
async cookie(message: any) {
switch (this.context?.webSocketState) {
case "connected":
console.log(this.context.cookies);
return this.renderJson({
...this.context?.metaData,
});
Expand Down
25 changes: 25 additions & 0 deletions src/modules/test/nodefony/views/index.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!doctype html>
<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"
/>

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

<body>
<h1><%= nodefony.name %> EJS</h1>
<h1><%= name %></h1>
</body>
</html>
38 changes: 38 additions & 0 deletions src/modules/test/nodefony/views/index.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!doctype html>
<html lang="{{nodefony.local|escape}}">
<head>
{% block head %}
{% block meta %}
<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">
{% endblock %}
{% block description %}{% endblock %}
<title>{% block title %}{{nodefony.name|escape}}{% endblock %}</title>
{% block stylesheets %} {% endblock %}
{% endblock %}

</head>

<body>
<h1>{{nodefony.name}} Twig</h1>
{% block body %}
{% if routing %}
Metier : {{routing.metier}} <br/>
Format : {{routing.format}} <br/>
Method : {{routing.method}} <br/>
{% endif %}
<pre>
<code>
{{dump(nodefony)}}
</code>
</pre>
{% endblock %}
{% block javascripts %} {% endblock %}
</body>

</html>
10 changes: 5 additions & 5 deletions src/modules/test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
"@rollup/plugin-replace": "5.0.7",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "11.1.6",
"@types/node": "20.14.9",
"@typescript-eslint/eslint-plugin": "7.15.0",
"@typescript-eslint/parser": "7.15.0",
"rimraf": "5.0.7",
"rollup": "4.18.0",
"@types/node": "20.14.10",
"@typescript-eslint/eslint-plugin": "7.16.0",
"@typescript-eslint/parser": "7.16.0",
"rimraf": "6.0.0",
"rollup": "4.18.1",
"rollup-plugin-copy": "3.5.0",
"rollup-sourcemap-path-transform": "1.0.4",
"typescript": "5.5.3"
Expand Down
Loading

0 comments on commit a431772

Please sign in to comment.