princejs 1.7.3 → 1.7.5

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 (2) hide show
  1. package/Readme.md +26 -8
  2. package/package.json +1 -1
package/Readme.md CHANGED
@@ -105,8 +105,9 @@ import { cron, openapi } from "princejs/scheduler";
105
105
  import { prince } from "princejs";
106
106
  import { cors, logger, rateLimit } from "princejs/middleware";
107
107
  import { validate } from "princejs/validation";
108
- import { cache, ai, upload } from "princejs/helpers";
108
+ import { cache, upload } from "princejs/helpers";
109
109
  import { cron } from "princejs/scheduler";
110
+ import { Html, Head, Body, H1, P, render } from "princejs/jsx"
110
111
  import { z } from "zod";
111
112
 
112
113
  const app = prince(true);
@@ -117,23 +118,40 @@ app.use(rateLimit({ max: 100, window: 60 }));
117
118
 
118
119
  app.use(validate(z.object({ name: z.string() })));
119
120
 
121
+ const Page = () => (
122
+ Html({
123
+ children: [
124
+ Head({
125
+ children: [
126
+ "Test Page"
127
+ ]
128
+ }),
129
+ Body({
130
+ children: [
131
+ H1({
132
+ children: "Hello World"
133
+ }),
134
+ P({
135
+ children: "This is a test"
136
+ })
137
+ ]
138
+ })
139
+ ]
140
+ })
141
+ );
142
+
120
143
  app.get("/", () => ({ message: "Welcome to PrinceJS" }));
121
144
 
122
145
  app.get("/users/:id", (req) => ({ id: req.params.id }));
123
146
 
124
- app.get("/data", cache(60)(() => ({ time: Date.now() })));
147
+ app.get("/jsx", () => render(Page()));
125
148
 
126
- app.post("/ai", async (req) => ({ reply: await ai(req.body.q) }));
149
+ app.get("/data", cache(60)(() => ({ time: Date.now() })));
127
150
 
128
151
  app.post("/upload", upload(), (req) => ({ files: Object.keys(req.files || {}) }));
129
152
 
130
153
  cron("*/1 * * * *", () => console.log("PrinceJS heartbeat"));
131
154
 
132
- app.ws("/chat", {
133
- open: (ws) => ws.send("Welcome!"),
134
- message: (ws, msg) => ws.send(`Echo: ${msg}`)
135
- });
136
-
137
155
  app.listen(3000);
138
156
  ```
139
157
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "princejs",
3
- "version": "1.7.3",
3
+ "version": "1.7.5",
4
4
  "description": "An easy and fast backend framework — by a 13yo developer, for developers.",
5
5
  "main": "dist/prince.js",
6
6
  "types": "dist/prince.d.ts",