fastnode-cli 0.3.0 → 0.4.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 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(@Query("name") name?: string) {
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fastnode-cli",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "The official CLI for scaffolding and serving FastNode applications.",
5
5
  "bin": {
6
6
  "fastnode": "dist/index.js"
@@ -25,7 +25,7 @@
25
25
  "dependencies": {
26
26
  "chalk": "^5.3.0",
27
27
  "commander": "^11.0.0",
28
- "fastnode-core": "^0.3.0",
28
+ "fastnode-core": "^0.4.0",
29
29
  "reflect-metadata": "^0.1.13"
30
30
  },
31
31
  "devDependencies": {