create-ponder 0.5.0-next.1 → 0.5.0-next.2
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/dist/index.js
CHANGED
|
@@ -16,7 +16,7 @@ import { default as prompts } from "prompts";
|
|
|
16
16
|
// package.json
|
|
17
17
|
var package_default = {
|
|
18
18
|
name: "create-ponder",
|
|
19
|
-
version: "0.5.0-next.
|
|
19
|
+
version: "0.5.0-next.2",
|
|
20
20
|
type: "module",
|
|
21
21
|
description: "A CLI tool to create Ponder apps",
|
|
22
22
|
license: "MIT",
|
package/package.json
CHANGED
|
@@ -25,3 +25,23 @@ declare module "@/generated" {
|
|
|
25
25
|
Virtual.IndexingFunctionArgs<config, schema, name>;
|
|
26
26
|
export type Schema = Virtual.Schema<schema>;
|
|
27
27
|
}
|
|
28
|
+
|
|
29
|
+
declare module "ponder:db" {
|
|
30
|
+
import type { ConvertToDrizzleTable } from "@ponder/core";
|
|
31
|
+
|
|
32
|
+
type schema = typeof import("./ponder.schema.ts").default;
|
|
33
|
+
|
|
34
|
+
const drizzleTables: {
|
|
35
|
+
[tableName in keyof schema]: ConvertToDrizzleTable<
|
|
36
|
+
tableName,
|
|
37
|
+
schema[tableName]["table"],
|
|
38
|
+
schema
|
|
39
|
+
>;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export = drizzleTables;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
declare module "ponder:db" {
|
|
46
|
+
export * from "@ponder/core/drizzle";
|
|
47
|
+
}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
+
import { Allowance, asc, desc, sql } from "ponder:db";
|
|
1
2
|
import { ponder } from "@/generated";
|
|
2
|
-
import { graphql,
|
|
3
|
+
import { graphql, replaceBigInts } from "@ponder/core";
|
|
3
4
|
|
|
4
5
|
// write file
|
|
5
6
|
ponder.use("/graphql", graphql());
|
|
6
7
|
|
|
7
|
-
ponder.get("/
|
|
8
|
+
ponder.get("/allowance", async (c) => {
|
|
8
9
|
const db = c.get("db");
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
const result = await db
|
|
12
|
+
.select({
|
|
13
|
+
owner: Allowance.ownerId,
|
|
14
|
+
count: sql<number>`cast(count(${Allowance.id}) as int)`,
|
|
15
|
+
balance: sql<number>`cast(sum(${Allowance.amount}) as numeric(78,0))`,
|
|
16
|
+
})
|
|
17
|
+
.from(Allowance)
|
|
18
|
+
.groupBy(Allowance.ownerId)
|
|
19
|
+
.orderBy(desc(sql`count`))
|
|
20
|
+
.limit(2);
|
|
14
21
|
|
|
15
|
-
|
|
22
|
+
// Hono JSON doesn't support BigInts
|
|
23
|
+
const safeResult = replaceBigInts(result, (b) => b.toString());
|
|
16
24
|
|
|
17
|
-
|
|
18
|
-
sql`SELECT * FROM "Account" LIMIT ${v}`,
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
if (account.rows.length === 0) {
|
|
22
|
-
return c.text("Not Found!");
|
|
23
|
-
} else {
|
|
24
|
-
return c.text(`Balance: ${account.rows[0]!.balance.toString()}`);
|
|
25
|
-
}
|
|
25
|
+
return c.json(safeResult);
|
|
26
26
|
});
|