feur
This commit is contained in:
parent
2737aadc7f
commit
8b6a86f17a
8 changed files with 95 additions and 10 deletions
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
|
@ -3,5 +3,6 @@
|
|||
"./"
|
||||
],
|
||||
"deno.enable": true,
|
||||
"deno.unstable": true,
|
||||
"editor.inlayHints.enabled": "off"
|
||||
}
|
7
api/login.ts
Normal file
7
api/login.ts
Normal file
|
@ -0,0 +1,7 @@
|
|||
import { Context } from "https://deno.land/x/hono@v4.3.10/mod.ts";
|
||||
import { Env } from "https://deno.land/x/hono@v4.3.10/mod.ts";
|
||||
import { BlankInput } from "https://deno.land/x/hono@v4.3.10/types.ts";
|
||||
|
||||
export function login_route(context: Context<Env, string, BlankInput>) {
|
||||
return context.text("E");
|
||||
}
|
5
deno.lock
generated
5
deno.lock
generated
|
@ -42,6 +42,7 @@
|
|||
"https://deno.land/x/hono@v4.3.10/adapter/deno/serve-static.ts": "db226d30f08f1a8bb77653ead42a911357b2f8710d653e43c01eccebb424b295",
|
||||
"https://deno.land/x/hono@v4.3.10/client/client.ts": "dcda3887257fa3164db7b32c56665c6e757f0ef047a14f3f9599ef41725c1525",
|
||||
"https://deno.land/x/hono@v4.3.10/client/index.ts": "30def535310a37bede261f1b23d11a9758983b8e9d60a6c56309cee5f6746ab2",
|
||||
"https://deno.land/x/hono@v4.3.10/client/types.ts": "73fbec704cf968ca5c5bba10aa1131758c52ab31a78301451c79cfc47368d43c",
|
||||
"https://deno.land/x/hono@v4.3.10/client/utils.ts": "8be84b49c5c7952666875a8e901fde3044c85c853ea6ba3a7e2c0468478459c0",
|
||||
"https://deno.land/x/hono@v4.3.10/compose.ts": "37d6e33b7db80e4c43a0629b12fd3a1e3406e7d9e62a4bfad4b30426ea7ae4f1",
|
||||
"https://deno.land/x/hono@v4.3.10/context.ts": "facfd749d823a645039571d66d9d228f5ae6836818b65d3b6c4c6891adfe071e",
|
||||
|
@ -64,6 +65,7 @@
|
|||
"https://deno.land/x/hono@v4.3.10/jsx/dom/utils.ts": "5d3e8c14996902db9c1223041fb21480fa0e921a4ccdc59f8c7571c08b7810f2",
|
||||
"https://deno.land/x/hono@v4.3.10/jsx/hooks/index.ts": "b7e0f0a754f31a1e1fbe0ac636b38b031603eb0ae195c32a30769a11d79fb871",
|
||||
"https://deno.land/x/hono@v4.3.10/jsx/index.ts": "fe3e582c2a4e24e5f8b6027925bddccaae0283747d8f0161eb6f5a34616edd11",
|
||||
"https://deno.land/x/hono@v4.3.10/jsx/intrinsic-elements.ts": "21c3a8f6ba07f0d7d7c0ec7293c79c26b9b62df2894e26cb6c17b6c7ec381264",
|
||||
"https://deno.land/x/hono@v4.3.10/jsx/streaming.ts": "5e5dde9a546041353b9a3860fc9020471f762813f10e1290009ab6bd40e7bdcf",
|
||||
"https://deno.land/x/hono@v4.3.10/jsx/types.ts": "51c2bdbb373860e2570ad403546a7fdbbb1cf00a47ce7ed10b2aece922031ac4",
|
||||
"https://deno.land/x/hono@v4.3.10/jsx/utils.ts": "4b8299d402ba5395472c552d1fe3297ee60112bfc32e0ef86cfe8e40086f7d54",
|
||||
|
@ -102,6 +104,7 @@
|
|||
"https://deno.land/x/hono@v4.3.10/router/trie-router/index.ts": "3eb75e7f71ba81801631b30de6b1f5cefb2c7239c03797e2b2cbab5085911b41",
|
||||
"https://deno.land/x/hono@v4.3.10/router/trie-router/node.ts": "d3e00e8f1ba7fb26896459d5bba882356891a07793387c4655d1864c519a91de",
|
||||
"https://deno.land/x/hono@v4.3.10/router/trie-router/router.ts": "54ced78d35676302c8fcdda4204f7bdf5a7cc907fbf9967c75674b1e394f830d",
|
||||
"https://deno.land/x/hono@v4.3.10/types.ts": "b561c3ee846121b33c2d81331246cdedf7781636ed72dad7406677105b4275de",
|
||||
"https://deno.land/x/hono@v4.3.10/utils/body.ts": "774cb319dfbe886a9d39f12c43dea15a39f9d01e45de0323167cdd5d0aad14d4",
|
||||
"https://deno.land/x/hono@v4.3.10/utils/buffer.ts": "2fae689954b427b51fb84ad02bed11a72eae96692c2973802b3b4c1e39cd5b9c",
|
||||
"https://deno.land/x/hono@v4.3.10/utils/color.ts": "10575c221f48bc806887710da8285f859f51daf9e6878bbdf99cb406b8494457",
|
||||
|
@ -110,6 +113,7 @@
|
|||
"https://deno.land/x/hono@v4.3.10/utils/encode.ts": "311dfdfae7eb0b6345e9680f7ebbb3a692e872ed964e2029aca38567af8d1f33",
|
||||
"https://deno.land/x/hono@v4.3.10/utils/filepath.ts": "a83e5fe87396bb291a6c5c28e13356fcbea0b5547bad2c3ba9660100ff964000",
|
||||
"https://deno.land/x/hono@v4.3.10/utils/html.ts": "6ea4f6bf41587a51607dff7a6d2865ef4d5001e4203b07e5c8a45b63a098e871",
|
||||
"https://deno.land/x/hono@v4.3.10/utils/http-status.ts": "f5b820f2793e45209f34deddf147b23e3133a89eb4c57dc643759a504706636b",
|
||||
"https://deno.land/x/hono@v4.3.10/utils/jwt/index.ts": "3b66f48cdd3fcc2caed5e908ca31776e11b1c30391008931276da3035e6ba1e9",
|
||||
"https://deno.land/x/hono@v4.3.10/utils/jwt/jwa.ts": "6874cacd8b6dde386636b81b5ea2754f8e4c61757802fa908dd1ce54b91a52fa",
|
||||
"https://deno.land/x/hono@v4.3.10/utils/jwt/jws.ts": "878fa7d1966b0db20ae231cfee279ba2bb198943e949049cab3f5845cd5ee2d1",
|
||||
|
@ -117,6 +121,7 @@
|
|||
"https://deno.land/x/hono@v4.3.10/utils/jwt/types.ts": "b6659ac85e7f8fcdd8cdfc7d51f5d1a91107ad8dfb647a8e4ea9c80f0f02afee",
|
||||
"https://deno.land/x/hono@v4.3.10/utils/jwt/utf8.ts": "17c507f68f23ccb82503ea6183e54b5f748a6fe621eb60994adfb4a8c2a3f561",
|
||||
"https://deno.land/x/hono@v4.3.10/utils/mime.ts": "d1fc2c047191ccb01d736c6acf90df731324536298181dba0ecc2259e5f7d661",
|
||||
"https://deno.land/x/hono@v4.3.10/utils/types.ts": "050bfa9dc6d0cc4b7c5069944a8bd60066c2f9f95ee69833623ad104f11f92bf",
|
||||
"https://deno.land/x/hono@v4.3.10/utils/url.ts": "855169632c61d03703bd08cafb27664ba3fdb352892f01687d5cce8fd49e3cb1",
|
||||
"https://deno.land/x/hono@v4.3.10/validator/index.ts": "6c986e8b91dcf857ecc8164a506ae8eea8665792a4ff7215471df669c632ae7c",
|
||||
"https://deno.land/x/hono@v4.3.10/validator/validator.ts": "53f3d2ad442e22f0bc2d85b7d8d90320d4e5ecf5fdd58882f906055d33a18e13",
|
||||
|
|
45
lib/storage.ts
Normal file
45
lib/storage.ts
Normal file
|
@ -0,0 +1,45 @@
|
|||
import { z } from "https://deno.land/x/zod@v3.23.8/mod.ts";
|
||||
|
||||
class Store<D, Schema> {
|
||||
kv;
|
||||
|
||||
private constructor(kv: Deno.Kv) {
|
||||
this.kv = kv;
|
||||
}
|
||||
}
|
||||
|
||||
class Schema<T extends TablesDescriptor<T>> {
|
||||
descriptor;
|
||||
|
||||
constructor(descriptor: T) {
|
||||
this.descriptor = descriptor;
|
||||
}
|
||||
}
|
||||
|
||||
type SchemaDescriptor<T extends TablesDescriptor<T>> = {
|
||||
tables: T;
|
||||
};
|
||||
|
||||
type TablesDescriptor<Self extends TablesDescriptor<Self>> = {
|
||||
[name: string]: TableDescr<Self, typeof name, { [key: string]: z.ZodType }>;
|
||||
};
|
||||
|
||||
type TableDescr<Tables extends TablesDescriptor<Tables>, Name extends keyof Tables, S extends z.ZodRawShape> = {
|
||||
structure: z.ZodObject<S>;
|
||||
relations: Relations<Tables, Name, S>;
|
||||
};
|
||||
|
||||
type Relations<Tables extends TablesDescriptor<Tables>, Name extends keyof Tables, S extends z.ZodRawShape> = {
|
||||
[name in Exclude<keyof Tables, Name>]?: [keyof S, keyof z.infer<Tables[name]["structure"]>];
|
||||
};
|
||||
|
||||
const store = new Schema({
|
||||
"user": {
|
||||
structure: z.object({ feur_id: z.string() }),
|
||||
relations: { "feur": ["_feur_id", "id"] },
|
||||
},
|
||||
"feur": {
|
||||
structure: z.object({ id: z.string(), content: z.string() }),
|
||||
relations: {},
|
||||
},
|
||||
});
|
|
@ -3,3 +3,7 @@ import { CSSProperties } from "https://deno.land/std@0.40.0/types/react.d.ts";
|
|||
export function _css(prop: CSSProperties) {
|
||||
return prop;
|
||||
}
|
||||
|
||||
// type wizardry
|
||||
|
||||
export type KeysOfType<T, V> = keyof { [P in keyof T as T[P] extends V ? P : never]: P };
|
||||
|
|
14
main.ts
14
main.ts
|
@ -8,13 +8,15 @@ const app = new Hono();
|
|||
app.use("/static/*", serveStatic({ root: "./pages/" }));
|
||||
app.use("/user", basicAuth({ username: "feur", password: "feur" })); // todo : transition to verify_user
|
||||
|
||||
app.get("/", (c) => {
|
||||
return c.html("Hello Hono!");
|
||||
});
|
||||
app.get("/", (c) => c.redirect("/home"));
|
||||
|
||||
import HomePage from "./pages/home.tsx";
|
||||
app.get("/home", (c) => {
|
||||
return c.html(HomePage());
|
||||
});
|
||||
app.get("/home", (c) => c.html(HomePage()));
|
||||
|
||||
import LoginPage from "./pages/login.tsx";
|
||||
app.get("/login", (c) => c.html(LoginPage()));
|
||||
|
||||
import { login_route } from "./api/login.ts";
|
||||
app.post("/api/login", (c) => login_route(c));
|
||||
|
||||
Deno.serve(app.fetch);
|
||||
|
|
|
@ -3,7 +3,10 @@
|
|||
import { jsx } from "https://deno.land/x/hono@v4.3.10/middleware.ts"
|
||||
|
||||
export default function Login() {
|
||||
return (<div>
|
||||
|
||||
</div>)
|
||||
}
|
||||
return (
|
||||
<form action="/api/login" method="post">
|
||||
<input type="text" name="login"/>
|
||||
<input type="password" name="password"/>
|
||||
</form>
|
||||
)
|
||||
}
|
||||
|
|
18
pages/login.tsx
Normal file
18
pages/login.tsx
Normal file
|
@ -0,0 +1,18 @@
|
|||
/** @jsx jsx */
|
||||
|
||||
import { jsx } from "https://deno.land/x/hono@v4.3.10/middleware.ts"
|
||||
import { BasePage } from "./components/base.tsx";
|
||||
import Heading from "./components/heading.tsx";
|
||||
import Main from "./components/main.tsx";
|
||||
import Login from "./components/login.tsx";
|
||||
|
||||
export default function LoginPage() {
|
||||
return (
|
||||
<BasePage name="Login">
|
||||
<Main>
|
||||
<h1>Login</h1>
|
||||
<Login/>
|
||||
</Main>
|
||||
</BasePage>
|
||||
)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue