fastnode-cli 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -1
- package/dist/index.js +9 -1
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img
|
|
3
|
+
src="https://res.cloudinary.com/dlvcthd0a/image/upload/v1773121010/fast_cgma5m.png"
|
|
4
|
+
alt="FastNode logo"
|
|
5
|
+
width="220"
|
|
6
|
+
/>
|
|
7
|
+
</p>
|
|
8
|
+
|
|
1
9
|
# fastnode-cli
|
|
2
10
|
|
|
3
11
|
`fastnode-cli` scaffolds FastNode applications and works with `fastnode-core`.
|
|
@@ -51,6 +59,7 @@ The generated app now includes a minimal HTTP + Socket.IO setup:
|
|
|
51
59
|
|
|
52
60
|
- app-level default execution policy in `createApp(...)`
|
|
53
61
|
- controller-level policy with `@ExecutionPolicy(...)`
|
|
62
|
+
- request-scoped execution helpers with `@Context()`
|
|
54
63
|
- FastAPI-style path placeholders like `/{item_id}`
|
|
55
64
|
- parameter decorators like `@Param()` and `@Query()`
|
|
56
65
|
- one Socket.IO namespace controller with `@Subscribe()` and `@EmitToClient()`
|
|
@@ -63,6 +72,7 @@ Example generated shape:
|
|
|
63
72
|
import "reflect-metadata";
|
|
64
73
|
import {
|
|
65
74
|
Body,
|
|
75
|
+
Context,
|
|
66
76
|
Controller,
|
|
67
77
|
EmitToClient,
|
|
68
78
|
ExecutionPolicy,
|
|
@@ -79,9 +89,12 @@ import {
|
|
|
79
89
|
@ExecutionPolicy({ timeout: 5000 })
|
|
80
90
|
class HelloController {
|
|
81
91
|
@Get("/")
|
|
82
|
-
hello(@Query("name") name?: string) {
|
|
92
|
+
async hello(@Query("name") name?: string, @Context() ctx?: any) {
|
|
93
|
+
await ctx?.sleep(25);
|
|
94
|
+
|
|
83
95
|
return {
|
|
84
96
|
message: `Hello from hello${name ? `, ${name}` : ""}`,
|
|
97
|
+
deadline: ctx?.snapshot?.().deadline,
|
|
85
98
|
};
|
|
86
99
|
}
|
|
87
100
|
|
|
@@ -125,6 +138,8 @@ See `packages/core/README.md` for the full framework guide, including:
|
|
|
125
138
|
|
|
126
139
|
- `@ExecutionPolicy()`
|
|
127
140
|
- `@UseExecutionPolicy()`
|
|
141
|
+
- `@Context()`
|
|
142
|
+
- `@IsolatedInput()`
|
|
128
143
|
- `@IsolatedHandler()`
|
|
129
144
|
- `@SocketController()`
|
|
130
145
|
- `@Subscribe()`
|
package/dist/index.js
CHANGED
|
@@ -90,6 +90,7 @@ function buildMainTemplate(projectName) {
|
|
|
90
90
|
return `import "reflect-metadata";
|
|
91
91
|
import {
|
|
92
92
|
Body,
|
|
93
|
+
Context,
|
|
93
94
|
Controller,
|
|
94
95
|
EmitToClient,
|
|
95
96
|
ExecutionPolicy,
|
|
@@ -107,9 +108,15 @@ import {
|
|
|
107
108
|
@ExecutionPolicy({ timeout: 5000 })
|
|
108
109
|
class ${className} {
|
|
109
110
|
@Get("/")
|
|
110
|
-
hello(
|
|
111
|
+
async hello(
|
|
112
|
+
@Query("name") name?: string,
|
|
113
|
+
@Context() ctx?: any
|
|
114
|
+
) {
|
|
115
|
+
await ctx?.sleep(25);
|
|
116
|
+
|
|
111
117
|
return {
|
|
112
118
|
message: \`Hello from ${projectName}\${name ? \`, \${name}\` : ""}\`,
|
|
119
|
+
deadline: ctx?.snapshot?.().deadline,
|
|
113
120
|
};
|
|
114
121
|
}
|
|
115
122
|
|
|
@@ -146,6 +153,7 @@ class ${toPascalCase(projectName)}SocketController {
|
|
|
146
153
|
@Module({ controllers: [${className}, ${toPascalCase(projectName)}SocketController] })
|
|
147
154
|
class ${moduleName} {}
|
|
148
155
|
|
|
156
|
+
// Drop files into ./static to serve them automatically, for example static/logo.png -> /logo.png.
|
|
149
157
|
createApp([${moduleName}], {
|
|
150
158
|
executionPolicy: {
|
|
151
159
|
timeout: 30000,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fastnode-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "The official CLI for scaffolding and serving FastNode applications.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"fastnode": "dist/index.js"
|
|
@@ -19,23 +19,23 @@
|
|
|
19
19
|
"scaffolding",
|
|
20
20
|
"generator",
|
|
21
21
|
"fastnode"
|
|
22
|
-
],
|
|
23
|
-
"author": "Valentine Emmanuel Ikechukwu",
|
|
24
|
-
"license": "MIT",
|
|
22
|
+
],
|
|
23
|
+
"author": "Valentine Emmanuel Ikechukwu",
|
|
24
|
+
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"chalk": "^5.3.0",
|
|
27
27
|
"commander": "^11.0.0",
|
|
28
|
-
"fastnode-core": "^0.
|
|
28
|
+
"fastnode-core": "^0.5.0",
|
|
29
29
|
"reflect-metadata": "^0.1.13"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/node": "^24.5.2",
|
|
33
33
|
"typescript": "^5.0.0"
|
|
34
34
|
},
|
|
35
|
-
"engines": {
|
|
36
|
-
"node": ">=18.0.0"
|
|
37
|
-
},
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=18.0.0"
|
|
37
|
+
},
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"access": "public"
|
|
40
40
|
}
|
|
41
|
-
}
|
|
41
|
+
}
|