fastnode-cli 0.2.0 → 0.3.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.
Files changed (3) hide show
  1. package/README.md +26 -4
  2. package/dist/index.js +27 -3
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -47,24 +47,31 @@ src/items/items.controller.ts
47
47
 
48
48
  ## What the Scaffold Includes
49
49
 
50
- The generated app now includes a simple execution policy example:
50
+ The generated app now includes a minimal HTTP + Socket.IO setup:
51
51
 
52
52
  - app-level default execution policy in `createApp(...)`
53
53
  - controller-level policy with `@ExecutionPolicy(...)`
54
54
  - FastAPI-style path placeholders like `/{item_id}`
55
55
  - parameter decorators like `@Param()` and `@Query()`
56
+ - one Socket.IO namespace controller with `@Subscribe()` and `@EmitToClient()`
57
+ - Swagger docs available automatically at `/docs`
58
+ - Socket.IO attached automatically at the default `/socket.io` path
56
59
 
57
60
  Example generated shape:
58
61
 
59
62
  ```ts
60
63
  import "reflect-metadata";
61
64
  import {
65
+ Body,
62
66
  Controller,
67
+ EmitToClient,
63
68
  ExecutionPolicy,
64
69
  Get,
65
70
  Module,
66
71
  Param,
67
72
  Query,
73
+ SocketController,
74
+ Subscribe,
68
75
  createApp,
69
76
  } from "fastnode-core";
70
77
 
@@ -84,7 +91,16 @@ class HelloController {
84
91
  }
85
92
  }
86
93
 
87
- @Module({ controllers: [HelloController] })
94
+ @SocketController("/chat")
95
+ class HelloSocketController {
96
+ @Subscribe("ping")
97
+ @EmitToClient()
98
+ ping(@Body("message") message?: string) {
99
+ return { message: message ?? "pong" };
100
+ }
101
+ }
102
+
103
+ @Module({ controllers: [HelloController, HelloSocketController] })
88
104
  class HelloModule {}
89
105
 
90
106
  createApp([HelloModule], {
@@ -99,15 +115,21 @@ Generated controller files also include request-data examples for:
99
115
 
100
116
  - `@Param("id")`
101
117
  - `@Query("page")`
118
+ - `@Post("/")`
102
119
  - `@Body()`
103
120
  - `@Body("name")`
104
121
 
105
122
  ## Related Docs
106
123
 
107
- See `packages/core/README.md` for the full execution policy guide, including:
124
+ See `packages/core/README.md` for the full framework guide, including:
108
125
 
109
126
  - `@ExecutionPolicy()`
110
127
  - `@UseExecutionPolicy()`
111
128
  - `@IsolatedHandler()`
129
+ - `@SocketController()`
130
+ - `@Subscribe()`
131
+ - `@UseGuard()`
132
+ - `@UseRateLimit()`
133
+ - `@UseValidation()`
112
134
  - inline vs isolated execution
113
- - timeout response behavior
135
+ - socket event handling and room broadcasts
package/dist/index.js CHANGED
@@ -89,12 +89,17 @@ function buildMainTemplate(projectName) {
89
89
  const moduleName = `${toPascalCase(projectName)}Module`;
90
90
  return `import "reflect-metadata";
91
91
  import {
92
+ Body,
92
93
  Controller,
94
+ EmitToClient,
93
95
  ExecutionPolicy,
94
96
  Get,
95
97
  Module,
96
98
  Param,
99
+ Post,
97
100
  Query,
101
+ SocketController,
102
+ Subscribe,
98
103
  createApp,
99
104
  } from "fastnode-core";
100
105
 
@@ -118,9 +123,27 @@ class ${className} {
118
123
  include,
119
124
  };
120
125
  }
126
+
127
+ @Post("/")
128
+ create() {
129
+ return {
130
+ created: true,
131
+ };
132
+ }
133
+ }
134
+
135
+ @SocketController("/chat")
136
+ class ${toPascalCase(projectName)}SocketController {
137
+ @Subscribe("ping")
138
+ @EmitToClient()
139
+ ping(@Body("message") message?: string) {
140
+ return {
141
+ message: message ?? "pong",
142
+ };
143
+ }
121
144
  }
122
145
 
123
- @Module({ controllers: [${className}] })
146
+ @Module({ controllers: [${className}, ${toPascalCase(projectName)}SocketController] })
124
147
  class ${moduleName} {}
125
148
 
126
149
  createApp([${moduleName}], {
@@ -137,6 +160,7 @@ function buildControllerTemplate(controllerName) {
137
160
  Body,
138
161
  Controller,
139
162
  Get,
163
+ Post,
140
164
  Param,
141
165
  Query,
142
166
  } from "fastnode-core";
@@ -166,8 +190,8 @@ export class ${className} {
166
190
  };
167
191
  }
168
192
 
169
- @Get("/request/echo")
170
- echoRequest(
193
+ @Post("/")
194
+ create(
171
195
  @Body() payload?: Record<string, unknown>,
172
196
  @Body("name") name?: string
173
197
  ) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fastnode-cli",
3
- "version": "0.2.0",
3
+ "version": "0.3.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.2.0",
28
+ "fastnode-core": "^0.3.0",
29
29
  "reflect-metadata": "^0.1.13"
30
30
  },
31
31
  "devDependencies": {