@celsoft/create-platform-app 0.9.0 → 0.11.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/package.json +1 -1
- package/template/README.md +5 -4
- package/template/gitignore +1 -0
- package/template/package.json +5 -1
- package/template/src/worker.ts +13 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celsoft/create-platform-app",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Create an app deployed by @celsoft/platform: npm create @celsoft/platform-app",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": { "type": "git", "url": "git+https://github.com/celsoft-com/platform.git", "directory": "packages/create-platform-app" },
|
package/template/README.md
CHANGED
|
@@ -13,7 +13,8 @@ Deployed to Cloudflare Workers with a Neon database by [@celsoft/platform](https
|
|
|
13
13
|
|
|
14
14
|
## Your code
|
|
15
15
|
|
|
16
|
-
1. **API:** `src/worker.ts`, where `
|
|
17
|
-
2. **
|
|
18
|
-
3. **
|
|
19
|
-
4. **
|
|
16
|
+
1. **API:** `src/worker.ts`, where each `endpoint` is a typed function with Zod schemas for its input and output, given `db`, a Drizzle client typed with your tables.
|
|
17
|
+
2. **Calling endpoints:** a bundled frontend imports `call` from `.platform/client.ts`, which the platform generates on install, and calls `call("listItems", {})`; never edit or commit `.platform/`.
|
|
18
|
+
3. **Pages:** `public/`, served as static files.
|
|
19
|
+
4. **Tables:** `src/schema.ts`; after changing it, run `npx @celsoft/platform db generate`, read the SQL it writes, and commit it. Each deploy applies new migrations.
|
|
20
|
+
5. **Local:** `npx @celsoft/platform dev` runs the app against its own copy of the database, generating migrations as you go.
|
package/template/gitignore
CHANGED
package/template/package.json
CHANGED
|
@@ -2,9 +2,13 @@
|
|
|
2
2
|
"name": "{{name}}",
|
|
3
3
|
"private": true,
|
|
4
4
|
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"postinstall": "platform generate"
|
|
7
|
+
},
|
|
5
8
|
"dependencies": {
|
|
6
9
|
"@celsoft/platform": "^{{platformVersion}}",
|
|
7
|
-
"drizzle-orm": "^0"
|
|
10
|
+
"drizzle-orm": "^0",
|
|
11
|
+
"zod": "^4.6.7"
|
|
8
12
|
},
|
|
9
13
|
"devDependencies": {
|
|
10
14
|
"@cloudflare/workers-types": "^5.20261023.1",
|
package/template/src/worker.ts
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import { defineApp } from "@celsoft/platform";
|
|
1
|
+
import { defineApp, endpoint } from "@celsoft/platform";
|
|
2
2
|
import { desc } from "drizzle-orm";
|
|
3
|
+
import { z } from "zod";
|
|
3
4
|
import * as schema from "./schema";
|
|
4
5
|
|
|
5
6
|
const { items } = schema;
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
async (request, { db }) => {
|
|
9
|
-
const url = new URL(request.url);
|
|
8
|
+
const Item = z.object({ id: z.uuid(), name: z.string(), createdAt: z.date(), updatedAt: z.date() });
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
// Each endpoint is one typed function; its Zod schemas are its only types. Every /api/ path
|
|
11
|
+
// needs a signed-in user except those under /api/public/.
|
|
12
|
+
export default defineApp(undefined, {
|
|
13
|
+
schema,
|
|
14
|
+
endpoints: {
|
|
15
|
+
listItems: endpoint(
|
|
16
|
+
{ method: "GET", path: "/api/public/items", description: "The newest 100 items", input: z.object({}), output: z.array(Item) },
|
|
17
|
+
async (_, { db }) => db.select().from(items).orderBy(desc(items.createdAt)).limit(100),
|
|
18
|
+
),
|
|
16
19
|
},
|
|
17
|
-
|
|
18
|
-
);
|
|
20
|
+
});
|