create-buntok 0.1.3 → 0.1.4
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/package.json +1 -1
- package/templates/README.md +26 -0
package/package.json
CHANGED
package/templates/README.md
CHANGED
|
@@ -133,6 +133,32 @@ api.get("/users", getUsers);
|
|
|
133
133
|
api.post("/users", createUser);
|
|
134
134
|
```
|
|
135
135
|
|
|
136
|
+
### Controllers (Decorators)
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
import { Controller, Get } from "buntok";
|
|
140
|
+
|
|
141
|
+
@Controller("/users")
|
|
142
|
+
export class UserController {
|
|
143
|
+
@Get("/")
|
|
144
|
+
getAll(ctx: Context) {
|
|
145
|
+
return ctx.json([{ id: 1 }]);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
app.registerController(UserController);
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### WebSockets
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
app.ws("/chat", {
|
|
156
|
+
open: (ws) => ws.subscribe("room"),
|
|
157
|
+
message: (ws, msg) => ws.publish("room", msg),
|
|
158
|
+
close: (ws) => console.log("Disconnected"),
|
|
159
|
+
});
|
|
160
|
+
```
|
|
161
|
+
|
|
136
162
|
### Middleware
|
|
137
163
|
|
|
138
164
|
```ts
|