vinojs 0.1.0 → 0.1.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/client.mjs +1 -1
- package/dist/{compile-Lxl_tdxL.mjs → compile-glNMkyyx.mjs} +3 -47
- package/dist/compile-glNMkyyx.mjs.map +1 -0
- package/dist/{definePage-Ba4r-TFh.mjs → definePage--9Pz7rHs.mjs} +29 -7
- package/dist/definePage--9Pz7rHs.mjs.map +1 -0
- package/dist/defineServerFn-H-bz7xBX.mjs +47 -0
- package/dist/defineServerFn-H-bz7xBX.mjs.map +1 -0
- package/dist/factory-CVT0-OZw.d.mts +187 -0
- package/dist/factory-CVT0-OZw.d.mts.map +1 -0
- package/dist/factory.d.mts +2 -0
- package/dist/factory.mjs +153 -0
- package/dist/factory.mjs.map +1 -0
- package/dist/vino.d.mts +4 -103
- package/dist/vino.d.mts.map +1 -1
- package/dist/vino.mjs +8 -3
- package/dist/vino.mjs.map +1 -1
- package/dist/vite.mjs +3 -2
- package/dist/vite.mjs.map +1 -1
- package/package.json +5 -1
- package/dist/compile-Lxl_tdxL.mjs.map +0 -1
- package/dist/definePage-Ba4r-TFh.mjs.map +0 -1
- package/examples/basic/dist/client/.assetsignore +0 -2
- package/examples/basic/dist/client/about.html +0 -1
- package/examples/basic/dist/client/admin.html +0 -1
- package/examples/basic/dist/client/assets/Counter-BvqMZKON.js +0 -1
- package/examples/basic/dist/client/assets/_slug_-CYpOSbrn.js +0 -1
- package/examples/basic/dist/client/assets/about-BZXRzUyv.js +0 -1
- package/examples/basic/dist/client/assets/admin-DRE7uh2s.js +0 -1
- package/examples/basic/dist/client/assets/client-B6nFkut5.js +0 -1
- package/examples/basic/dist/client/assets/client-pages-Bc6cNZAm.js +0 -2
- package/examples/basic/dist/client/assets/components-DX9r6vHn.js +0 -1
- package/examples/basic/dist/client/assets/components-DsWJ6F73.js +0 -2
- package/examples/basic/dist/client/assets/counter-DBpvln_F.js +0 -1
- package/examples/basic/dist/client/assets/dom-B5sHIJ1E.js +0 -1
- package/examples/basic/dist/client/assets/honoto-9UtdLp4J.js +0 -33
- package/examples/basic/dist/client/assets/honoto-client-DEh86_WZ.css +0 -1
- package/examples/basic/dist/client/assets/honoto-client.js +0 -2
- package/examples/basic/dist/client/assets/hooks-Cz6AT21d.js +0 -1
- package/examples/basic/dist/client/assets/jsx-dev-runtime-92VDsVyo.js +0 -1
- package/examples/basic/dist/client/counter.html +0 -1
- package/examples/basic/dist/client/index.html +0 -1
- package/examples/basic/dist/client/jobs.html +0 -1
- package/examples/basic/dist/ssr/.vite/manifest.json +0 -140
- package/examples/basic/dist/ssr/assets/_slug_-CY3-kffX.js +0 -46
- package/examples/basic/dist/ssr/assets/about-CTDjNhkO.js +0 -15
- package/examples/basic/dist/ssr/assets/admin-DvS-UGJx.js +0 -26
- package/examples/basic/dist/ssr/assets/constants-UoriGYcX-CUecBFMT.js +0 -6
- package/examples/basic/dist/ssr/assets/counter-DfIbc9Sp.js +0 -30
- package/examples/basic/dist/ssr/assets/honoto-CA313cVy.js +0 -2129
- package/examples/basic/dist/ssr/assets/jobs-D9hh-UO9.js +0 -42
- package/examples/basic/dist/ssr/assets/jsx-CgYLQazd.js +0 -1080
- package/examples/basic/dist/ssr/assets/jsx-dev-runtime-BlUda7H8.js +0 -742
- package/examples/basic/dist/ssr/assets/jsx-renderer-CzZcZPnS.js +0 -65
- package/examples/basic/dist/ssr/assets/layout-DYvLwr2u.js +0 -53
- package/examples/basic/dist/ssr/assets/pages-DB6jeyrt.js +0 -53
- package/examples/basic/dist/ssr/assets/rolldown-runtime-D7D4PA-g.js +0 -13
- package/examples/basic/dist/ssr/assets/ssr-hooks-CBQr0cdH.js +0 -7
- package/examples/basic/dist/ssr/index.js +0 -22
- package/examples/basic/dist/ssr/wrangler.json +0 -1
- package/examples/full/dist/client/.assetsignore +0 -2
- package/examples/full/dist/client/assets/BookmarkButton-py0xGxgl.js +0 -1
- package/examples/full/dist/client/assets/_slug_-DZUFsE9O.js +0 -1
- package/examples/full/dist/client/assets/auth-client-D2Wtuobe.js +0 -1
- package/examples/full/dist/client/assets/bun-sqlite-dialect-C7ftEUSI-CsHdUKBY.js +0 -1
- package/examples/full/dist/client/assets/client-B6nFkut5.js +0 -1
- package/examples/full/dist/client/assets/client-pages-fshKs747.js +0 -2
- package/examples/full/dist/client/assets/components-DX9r6vHn.js +0 -1
- package/examples/full/dist/client/assets/components-S_-rWrKi.js +0 -2
- package/examples/full/dist/client/assets/d1-sqlite-dialect-BZmaVTp8-FPCaMZqX.js +0 -1
- package/examples/full/dist/client/assets/default-query-compiler-CUdqIu1h.js +0 -1
- package/examples/full/dist/client/assets/dist-BoGTNvkC.js +0 -1
- package/examples/full/dist/client/assets/dom-DCd3wYW7.js +0 -1
- package/examples/full/dist/client/assets/factory-Bgf4EtLx.js +0 -8
- package/examples/full/dist/client/assets/honoto-client-BSvNAnxN.css +0 -1
- package/examples/full/dist/client/assets/honoto-client.js +0 -2
- package/examples/full/dist/client/assets/hooks-Cz6AT21d.js +0 -1
- package/examples/full/dist/client/assets/jsx-dev-runtime-92VDsVyo.js +0 -1
- package/examples/full/dist/client/assets/kysely-adapter-BHhasAnc.js +0 -1
- package/examples/full/dist/client/assets/kysely-migration-tables-DFfmKhq--U5ujlMwE.js +0 -1
- package/examples/full/dist/client/assets/node-sqlite-dialect-DJDXH5Ot.js +0 -1
- package/examples/full/dist/client/assets/pages-CUQx6Eus.js +0 -1
- package/examples/full/dist/client/assets/saved-jIi74ncJ.js +0 -1
- package/examples/full/dist/client/assets/session-B-accyM3.js +0 -611
- package/examples/full/dist/client/assets/sign-in-BelI3gSs.js +0 -1
- package/examples/full/dist/client/assets/sign-up-pR94lfdu.js +0 -1
- package/examples/full/dist/client/index.html +0 -1
- package/examples/full/dist/client/saved.html +0 -1
- package/examples/full/dist/client/sign-in.html +0 -1
- package/examples/full/dist/client/sign-up.html +0 -1
- package/examples/full/dist/ssr/.dev.vars +0 -1
- package/examples/full/dist/ssr/.vite/manifest.json +0 -219
- package/examples/full/dist/ssr/assets/BookmarkButton-KS7z5_vi.js +0 -298
- package/examples/full/dist/ssr/assets/_slug_-rRStRaAN.js +0 -89
- package/examples/full/dist/ssr/assets/auth-DSFZ4iak.js +0 -31434
- package/examples/full/dist/ssr/assets/auth-client-BFSBVoML.js +0 -894
- package/examples/full/dist/ssr/assets/bun-sqlite-dialect-C7ftEUSI-BeXpIqKl.js +0 -162
- package/examples/full/dist/ssr/assets/compiled-query-DmoyCh28.js +0 -8410
- package/examples/full/dist/ssr/assets/d1-sqlite-dialect-BZmaVTp8-CjJdvL94.js +0 -114
- package/examples/full/dist/ssr/assets/default-query-compiler-D7xOzCCJ.js +0 -1727
- package/examples/full/dist/ssr/assets/dist-LmmDoNdk.js +0 -6832
- package/examples/full/dist/ssr/assets/dist-kFDN1l4Z.js +0 -342
- package/examples/full/dist/ssr/assets/factory-AD6s9SIW.js +0 -2079
- package/examples/full/dist/ssr/assets/jsx-renderer-mMLf5XLN.js +0 -1926
- package/examples/full/dist/ssr/assets/kysely-adapter-BCLenpM8.js +0 -2
- package/examples/full/dist/ssr/assets/kysely-migration-tables-DFfmKhq--BtVr6hRe.js +0 -17
- package/examples/full/dist/ssr/assets/layout-mVA7qP4j.js +0 -44
- package/examples/full/dist/ssr/assets/node-sqlite-dialect-D-wtYAD7.js +0 -162
- package/examples/full/dist/ssr/assets/pages-Do5kR_Ia.js +0 -147
- package/examples/full/dist/ssr/assets/saved-Dr4pP6B5.js +0 -111
- package/examples/full/dist/ssr/assets/session-BvIpX7tr.js +0 -13
- package/examples/full/dist/ssr/assets/sign-in-22pzTnJE.js +0 -115
- package/examples/full/dist/ssr/assets/sign-up-CN4j8Qg1.js +0 -117
- package/examples/full/dist/ssr/assets/sqlite-adapter-DVlms5wO.js +0 -79
- package/examples/full/dist/ssr/index.js +0 -97
- package/examples/full/dist/ssr/wrangler.json +0 -1
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { a as useState, o as jsxDEV } from "./jsx-renderer-mMLf5XLN.js";
|
|
2
|
-
import { g as definePage } from "./auth-DSFZ4iak.js";
|
|
3
|
-
import { t as getSessionUser } from "./session-BvIpX7tr.js";
|
|
4
|
-
import { t as authClient } from "./auth-client-BFSBVoML.js";
|
|
5
|
-
//#region src/features/sign-up.tsx
|
|
6
|
-
function SignUpForm({ data }) {
|
|
7
|
-
const [name, setName] = useState("");
|
|
8
|
-
const [email, setEmail] = useState("");
|
|
9
|
-
const [password, setPassword] = useState("");
|
|
10
|
-
const [error, setError] = useState(null);
|
|
11
|
-
const [pending, setPending] = useState(false);
|
|
12
|
-
if (data.user) return /* @__PURE__ */ jsxDEV("main", {
|
|
13
|
-
class: "max-w-md mx-auto px-4 py-12",
|
|
14
|
-
children: [/* @__PURE__ */ jsxDEV("h1", {
|
|
15
|
-
class: "text-2xl font-semibold",
|
|
16
|
-
children: "You are signed in"
|
|
17
|
-
}), /* @__PURE__ */ jsxDEV("a", {
|
|
18
|
-
href: "/",
|
|
19
|
-
class: "inline-block mt-6 text-stone-800 underline",
|
|
20
|
-
children: "Go to feed"
|
|
21
|
-
})]
|
|
22
|
-
});
|
|
23
|
-
async function onSubmit(e) {
|
|
24
|
-
e.preventDefault();
|
|
25
|
-
setPending(true);
|
|
26
|
-
setError(null);
|
|
27
|
-
const res = await authClient.signUp.email({
|
|
28
|
-
name,
|
|
29
|
-
email,
|
|
30
|
-
password
|
|
31
|
-
});
|
|
32
|
-
setPending(false);
|
|
33
|
-
if (res.error) {
|
|
34
|
-
setError(res.error.message ?? "Sign up failed");
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
window.location.href = "/";
|
|
38
|
-
}
|
|
39
|
-
return /* @__PURE__ */ jsxDEV("main", {
|
|
40
|
-
class: "max-w-md mx-auto px-4 py-12",
|
|
41
|
-
children: [
|
|
42
|
-
/* @__PURE__ */ jsxDEV("h1", {
|
|
43
|
-
class: "text-2xl font-semibold",
|
|
44
|
-
children: "Create account"
|
|
45
|
-
}),
|
|
46
|
-
/* @__PURE__ */ jsxDEV("p", {
|
|
47
|
-
class: "mt-2 text-stone-600 text-sm",
|
|
48
|
-
children: [
|
|
49
|
-
"Already have one?",
|
|
50
|
-
" ",
|
|
51
|
-
/* @__PURE__ */ jsxDEV("a", {
|
|
52
|
-
href: "/sign-in",
|
|
53
|
-
class: "underline text-stone-800",
|
|
54
|
-
children: "Sign in"
|
|
55
|
-
})
|
|
56
|
-
]
|
|
57
|
-
}),
|
|
58
|
-
/* @__PURE__ */ jsxDEV("form", {
|
|
59
|
-
class: "mt-8 flex flex-col gap-4",
|
|
60
|
-
onSubmit,
|
|
61
|
-
children: [
|
|
62
|
-
/* @__PURE__ */ jsxDEV("label", {
|
|
63
|
-
class: "flex flex-col gap-1 text-sm",
|
|
64
|
-
children: ["Name", /* @__PURE__ */ jsxDEV("input", {
|
|
65
|
-
type: "text",
|
|
66
|
-
required: true,
|
|
67
|
-
value: name,
|
|
68
|
-
onInput: (e) => setName(e.currentTarget.value),
|
|
69
|
-
class: "border border-stone-300 rounded-md px-3 py-2 bg-white"
|
|
70
|
-
})]
|
|
71
|
-
}),
|
|
72
|
-
/* @__PURE__ */ jsxDEV("label", {
|
|
73
|
-
class: "flex flex-col gap-1 text-sm",
|
|
74
|
-
children: ["Email", /* @__PURE__ */ jsxDEV("input", {
|
|
75
|
-
type: "email",
|
|
76
|
-
required: true,
|
|
77
|
-
value: email,
|
|
78
|
-
onInput: (e) => setEmail(e.currentTarget.value),
|
|
79
|
-
class: "border border-stone-300 rounded-md px-3 py-2 bg-white"
|
|
80
|
-
})]
|
|
81
|
-
}),
|
|
82
|
-
/* @__PURE__ */ jsxDEV("label", {
|
|
83
|
-
class: "flex flex-col gap-1 text-sm",
|
|
84
|
-
children: ["Password", /* @__PURE__ */ jsxDEV("input", {
|
|
85
|
-
type: "password",
|
|
86
|
-
required: true,
|
|
87
|
-
minLength: 8,
|
|
88
|
-
value: password,
|
|
89
|
-
onInput: (e) => setPassword(e.currentTarget.value),
|
|
90
|
-
class: "border border-stone-300 rounded-md px-3 py-2 bg-white"
|
|
91
|
-
})]
|
|
92
|
-
}),
|
|
93
|
-
error ? /* @__PURE__ */ jsxDEV("p", {
|
|
94
|
-
class: "text-sm text-red-700",
|
|
95
|
-
children: error
|
|
96
|
-
}) : null,
|
|
97
|
-
/* @__PURE__ */ jsxDEV("button", {
|
|
98
|
-
type: "submit",
|
|
99
|
-
disabled: pending,
|
|
100
|
-
class: "bg-stone-900 text-stone-50 rounded-md px-4 py-2 disabled:opacity-50",
|
|
101
|
-
children: pending ? "Creating…" : "Sign up"
|
|
102
|
-
})
|
|
103
|
-
]
|
|
104
|
-
})
|
|
105
|
-
]
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
//#endregion
|
|
109
|
-
//#region src/pages/sign-up.tsx
|
|
110
|
-
var sign_up_default = definePage({
|
|
111
|
-
async data(c) {
|
|
112
|
-
return { user: await getSessionUser(c) };
|
|
113
|
-
},
|
|
114
|
-
render: SignUpForm
|
|
115
|
-
});
|
|
116
|
-
//#endregion
|
|
117
|
-
export { sign_up_default as default };
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { t as DefaultQueryCompiler } from "./default-query-compiler-D7xOzCCJ.js";
|
|
2
|
-
//#region ../../node_modules/.pnpm/kysely@0.29.5/node_modules/kysely/dist/dialect/dialect-adapter-base.js
|
|
3
|
-
/**
|
|
4
|
-
* A basic implementation of `DialectAdapter` with sensible default values.
|
|
5
|
-
* Third-party dialects can extend this instead of implementing the `DialectAdapter`
|
|
6
|
-
* interface from scratch. That way all new settings will get default values when
|
|
7
|
-
* they are added and there will be less breaking changes.
|
|
8
|
-
*/
|
|
9
|
-
var DialectAdapterBase = class {
|
|
10
|
-
get supportsCreateIfNotExists() {
|
|
11
|
-
return true;
|
|
12
|
-
}
|
|
13
|
-
get supportsMultipleConnections() {
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
get supportsTransactionalDdl() {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
get supportsReturning() {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
get supportsOutput() {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
//#endregion
|
|
27
|
-
//#region ../../node_modules/.pnpm/kysely@0.29.5/node_modules/kysely/dist/dialect/sqlite/sqlite-query-compiler.js
|
|
28
|
-
var ID_WRAP_REGEX = /"/g;
|
|
29
|
-
var JSON_PATH_MEMBER_ESCAPE_REGEX = /[\\'"]/g;
|
|
30
|
-
var SqliteQueryCompiler = class extends DefaultQueryCompiler {
|
|
31
|
-
visitOrAction(node) {
|
|
32
|
-
this.append("or ");
|
|
33
|
-
this.append(node.action);
|
|
34
|
-
}
|
|
35
|
-
getCurrentParameterPlaceholder() {
|
|
36
|
-
return "?";
|
|
37
|
-
}
|
|
38
|
-
getLeftExplainOptionsWrapper() {
|
|
39
|
-
return "";
|
|
40
|
-
}
|
|
41
|
-
getRightExplainOptionsWrapper() {
|
|
42
|
-
return "";
|
|
43
|
-
}
|
|
44
|
-
getLeftIdentifierWrapper() {
|
|
45
|
-
return "\"";
|
|
46
|
-
}
|
|
47
|
-
getRightIdentifierWrapper() {
|
|
48
|
-
return "\"";
|
|
49
|
-
}
|
|
50
|
-
getAutoIncrement() {
|
|
51
|
-
return "autoincrement";
|
|
52
|
-
}
|
|
53
|
-
sanitizeIdentifier(identifier) {
|
|
54
|
-
return identifier.replace(ID_WRAP_REGEX, "\"\"");
|
|
55
|
-
}
|
|
56
|
-
sanitizeJSONPathMemberValue(value) {
|
|
57
|
-
return value.replace(JSON_PATH_MEMBER_ESCAPE_REGEX, (char) => char === "\\" ? "\\\\" : char === "'" ? "''" : "\\\"");
|
|
58
|
-
}
|
|
59
|
-
visitDefaultInsertValue(_) {
|
|
60
|
-
this.append("null");
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
//#endregion
|
|
64
|
-
//#region ../../node_modules/.pnpm/kysely@0.29.5/node_modules/kysely/dist/dialect/sqlite/sqlite-adapter.js
|
|
65
|
-
var SqliteAdapter = class extends DialectAdapterBase {
|
|
66
|
-
get supportsMultipleConnections() {
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
get supportsTransactionalDdl() {
|
|
70
|
-
return false;
|
|
71
|
-
}
|
|
72
|
-
get supportsReturning() {
|
|
73
|
-
return true;
|
|
74
|
-
}
|
|
75
|
-
async acquireMigrationLock(_db, _opt) {}
|
|
76
|
-
async releaseMigrationLock(_db, _opt) {}
|
|
77
|
-
};
|
|
78
|
-
//#endregion
|
|
79
|
-
export { SqliteQueryCompiler as n, DialectAdapterBase as r, SqliteAdapter as t };
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { d as eq, h as createHonoto, i as bookmarks, l as desc, m as or, n as createDb, p as lt, r as articles, t as createAuth, u as and, y as Hono } from "./assets/auth-DSFZ4iak.js";
|
|
2
|
-
//#region src/api.ts
|
|
3
|
-
async function requireUser(c) {
|
|
4
|
-
const session = await createAuth(c.env).api.getSession({ headers: c.req.raw.headers });
|
|
5
|
-
if (!session?.user) return null;
|
|
6
|
-
return session.user;
|
|
7
|
-
}
|
|
8
|
-
function serializeArticle(row) {
|
|
9
|
-
return {
|
|
10
|
-
id: row.id,
|
|
11
|
-
slug: row.slug,
|
|
12
|
-
title: row.title,
|
|
13
|
-
excerpt: row.excerpt,
|
|
14
|
-
body: row.body,
|
|
15
|
-
author: row.author,
|
|
16
|
-
publishedAt: row.publishedAt instanceof Date ? row.publishedAt.toISOString() : String(row.publishedAt)
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
var api = new Hono().get("/articles", async (c) => {
|
|
20
|
-
const db = createDb(c.env.DB);
|
|
21
|
-
const limit = Math.min(Number(c.req.query("limit") ?? 10) || 10, 50);
|
|
22
|
-
const cursor = c.req.query("cursor");
|
|
23
|
-
let rows;
|
|
24
|
-
if (cursor) {
|
|
25
|
-
const [cursorTime, cursorId] = cursor.split("|");
|
|
26
|
-
const cursorDate = new Date(cursorTime);
|
|
27
|
-
rows = await db.select().from(articles).where(or(lt(articles.publishedAt, cursorDate), and(eq(articles.publishedAt, cursorDate), lt(articles.id, cursorId)))).orderBy(desc(articles.publishedAt), desc(articles.id)).limit(limit + 1);
|
|
28
|
-
} else rows = await db.select().from(articles).orderBy(desc(articles.publishedAt), desc(articles.id)).limit(limit + 1);
|
|
29
|
-
const hasMore = rows.length > limit;
|
|
30
|
-
const page = hasMore ? rows.slice(0, limit) : rows;
|
|
31
|
-
const last = page[page.length - 1];
|
|
32
|
-
const nextCursor = hasMore && last ? `${last.publishedAt instanceof Date ? last.publishedAt.toISOString() : last.publishedAt}|${last.id}` : null;
|
|
33
|
-
return c.json({
|
|
34
|
-
items: page.map(serializeArticle),
|
|
35
|
-
nextCursor
|
|
36
|
-
});
|
|
37
|
-
}).get("/articles/:slug", async (c) => {
|
|
38
|
-
const db = createDb(c.env.DB);
|
|
39
|
-
const slug = c.req.param("slug");
|
|
40
|
-
const row = await db.select().from(articles).where(eq(articles.slug, slug)).get();
|
|
41
|
-
if (!row) return c.json({ error: "Not found" }, 404);
|
|
42
|
-
return c.json(serializeArticle(row));
|
|
43
|
-
}).get("/bookmarks", async (c) => {
|
|
44
|
-
const user = await requireUser(c);
|
|
45
|
-
if (!user) return c.json({ error: "Unauthorized" }, 401);
|
|
46
|
-
const rows = await createDb(c.env.DB).select({
|
|
47
|
-
articleId: bookmarks.articleId,
|
|
48
|
-
article: articles
|
|
49
|
-
}).from(bookmarks).innerJoin(articles, eq(bookmarks.articleId, articles.id)).where(eq(bookmarks.userId, user.id)).orderBy(desc(bookmarks.createdAt));
|
|
50
|
-
return c.json({
|
|
51
|
-
items: rows.map((r) => serializeArticle(r.article)),
|
|
52
|
-
articleIds: rows.map((r) => r.articleId)
|
|
53
|
-
});
|
|
54
|
-
}).post("/bookmarks", async (c) => {
|
|
55
|
-
const user = await requireUser(c);
|
|
56
|
-
if (!user) return c.json({ error: "Unauthorized" }, 401);
|
|
57
|
-
const body = await c.req.json();
|
|
58
|
-
if (!body?.articleId) return c.json({ error: "articleId required" }, 400);
|
|
59
|
-
const db = createDb(c.env.DB);
|
|
60
|
-
if (!await db.select().from(articles).where(eq(articles.id, body.articleId)).get()) return c.json({ error: "Article not found" }, 404);
|
|
61
|
-
if (await db.select().from(bookmarks).where(and(eq(bookmarks.userId, user.id), eq(bookmarks.articleId, body.articleId))).get()) return c.json({
|
|
62
|
-
ok: true,
|
|
63
|
-
bookmarked: true
|
|
64
|
-
});
|
|
65
|
-
await db.insert(bookmarks).values({
|
|
66
|
-
id: crypto.randomUUID(),
|
|
67
|
-
userId: user.id,
|
|
68
|
-
articleId: body.articleId
|
|
69
|
-
});
|
|
70
|
-
return c.json({
|
|
71
|
-
ok: true,
|
|
72
|
-
bookmarked: true
|
|
73
|
-
}, 201);
|
|
74
|
-
}).delete("/bookmarks/:articleId", async (c) => {
|
|
75
|
-
const user = await requireUser(c);
|
|
76
|
-
if (!user) return c.json({ error: "Unauthorized" }, 401);
|
|
77
|
-
const articleId = c.req.param("articleId");
|
|
78
|
-
await createDb(c.env.DB).delete(bookmarks).where(and(eq(bookmarks.userId, user.id), eq(bookmarks.articleId, articleId)));
|
|
79
|
-
return c.json({
|
|
80
|
-
ok: true,
|
|
81
|
-
bookmarked: false
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
//#endregion
|
|
85
|
-
//#region src/server.ts
|
|
86
|
-
var app = new Hono();
|
|
87
|
-
app.all("/api/auth/*", (c) => {
|
|
88
|
-
return createAuth(c.env).handler(c.req.raw);
|
|
89
|
-
});
|
|
90
|
-
var client = createHonoto();
|
|
91
|
-
app.route("/", client);
|
|
92
|
-
app.route("/api", api);
|
|
93
|
-
//#endregion
|
|
94
|
-
//#region \0virtual:cloudflare/worker-entry
|
|
95
|
-
var worker_entry_default = app ?? {};
|
|
96
|
-
//#endregion
|
|
97
|
-
export { worker_entry_default as default };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"configPath":"/home/chris/workspace/proto/vino/examples/full/wrangler.jsonc","userConfigPath":"/home/chris/workspace/proto/vino/examples/full/wrangler.jsonc","topLevelName":"honoto-example-full","definedEnvironments":[],"compatibility_date":"2026-08-18","compatibility_flags":["nodejs_compat"],"jsx_factory":"React.createElement","jsx_fragment":"React.Fragment","rules":[{"type":"ESModule","globs":["**/*.js","**/*.mjs"]}],"name":"honoto-example-full","main":"index.js","triggers":{},"assets":{"directory":"../client"},"vars":{"BETTER_AUTH_URL":"http://localhost:5173"},"durable_objects":{"bindings":[]},"workflows":[],"migrations":[],"exports":{},"kv_namespaces":[],"cloudchamber":{},"send_email":[],"queues":{"producers":[],"consumers":[]},"connect":[],"r2_buckets":[],"d1_databases":[{"binding":"DB","database_name":"honoto-example-full","database_id":"5de13d7d-ddeb-430d-b2b6-12131c23fcff","migrations_dir":"../../drizzle"}],"vectorize":[],"ai_search_namespaces":[],"ai_search":[],"agent_memory":[],"hyperdrive":[],"services":[],"analytics_engine_datasets":[],"dispatch_namespaces":[],"mtls_certificates":[],"pipelines":[],"secrets_store_secrets":[],"artifacts":[],"unsafe_hello_world":[],"flagship":[],"worker_loaders":[],"ratelimits":[],"vpc_services":[],"vpc_networks":[],"logfwdr":{"bindings":[]},"python_modules":{"exclude":["**/*.pyc"]},"dev":{"ip":"localhost","local_protocol":"http","upstream_protocol":"http","enable_containers":true,"generate_types":false},"no_bundle":true}
|