main
Ethan Niser 2023-09-17 23:43:25 -05:00
parent 2977b96725
commit b569488452
20 changed files with 52 additions and 26 deletions

@ -1,4 +1,3 @@
// .vscode/settings.json
{
"typescript.tsdk": "node_modules/typescript/lib"
}

Binary file not shown.

@ -16,10 +16,13 @@
"reset-cache": "rm -rf /home/whatplan/.bun/install/cache && rm -rf node_modules && bun i"
},
"devDependencies": {
"@ianvs/prettier-plugin-sort-imports": "^4.1.0",
"@kitajs/ts-html-plugin": "^1.0.1",
"bun-types": "latest",
"concurrently": "^8.2.1",
"drizzle-kit": "^0.19.13",
"prettier": "^3.0.3",
"prettier-plugin-tailwindcss": "^0.5.4",
"typescript": "^5.2.2",
"unocss": "^0.55.7"
},

@ -0,0 +1,17 @@
/** @typedef {import("prettier").Config} PrettierConfig */
/** @type { PrettierConfig | SortImportsConfig } */
const config = {
arrowParens: "always",
printWidth: 80,
singleQuote: false,
semi: true,
trailingComma: "all",
tabWidth: 2,
plugins: [
"@ianvs/prettier-plugin-sort-imports",
"prettier-plugin-tailwindcss",
],
};
module.exports = config;

@ -1,6 +1,6 @@
import { libsql } from "@lucia-auth/adapter-sqlite";
import { lucia } from "lucia";
import { web } from "lucia/middleware";
import { libsql } from "@lucia-auth/adapter-sqlite";
import { config } from "../config";
import { client } from "../db";

@ -1,6 +1,6 @@
import { type PropsWithChildren } from "beth-stack/jsx";
import { liveReloadScript } from "beth-stack/dev";
import { htmxExtensionScript } from "beth-stack";
import { liveReloadScript } from "beth-stack/dev";
import { type PropsWithChildren } from "beth-stack/jsx";
import { config } from "../config";
const safeScript =

@ -10,6 +10,7 @@ export function TodoItem({ content, completed, id }: Todo) {
hx-post={`/api/todos/toggle/${id}`}
hx-swap="outerHTML"
hx-target="closest div"
class="p4 pt-2"
/>
<button
class="text-red-500"

@ -6,6 +6,7 @@ import { client, db } from "../db";
import "beth-stack/jsx/register";
import { bethStack } from "beth-stack/elysia";
import { auth } from "../auth";
// import { cron } from "@elysiajs/cron";
// const stream = pretty({
@ -19,7 +20,7 @@ export const ctx = new Elysia({
bethStack({
log: true,
returnStaleWhileRevalidate: false,
})
}),
)
// .use(
// logger({

@ -1,5 +1,6 @@
import Elysia from "elysia";
import { todosController } from "./todos";
// import { authController } from "./auth";
export const api = new Elysia({

@ -1,10 +1,9 @@
import { eq } from "drizzle-orm";
import { Elysia, t } from "elysia";
import { TodoForm, TodoItem, TodoList } from "../components/todos";
import { ctx } from "../context";
import { insertTodoSchema, todos } from "../db/schema/todos";
import { TodoItem, TodoForm, TodoList } from "../components/todos";
import { client, db } from "../db";
import { eq } from "drizzle-orm";
import { insertTodoSchema, todos } from "../db/schema/todos";
export const todosController = new Elysia({
prefix: "/todos",
@ -46,7 +45,7 @@ export const todosController = new Elysia({
params: t.Object({
id: t.Numeric(),
}),
}
},
)
.delete(
"/:id",
@ -57,7 +56,7 @@ export const todosController = new Elysia({
params: t.Object({
id: t.Numeric(),
}),
}
},
)
.post(
"",
@ -94,5 +93,5 @@ export const todosController = new Elysia({
t.Literal("sub"),
]),
}),
}
},
);

@ -1,7 +1,7 @@
import { drizzle } from "drizzle-orm/libsql";
import { createClient } from "@libsql/client";
import * as schema from "./schema";
import { drizzle } from "drizzle-orm/libsql";
import { config } from "../config";
import * as schema from "./schema";
export const client = createClient({
url: config.env.DATABASE_URL,

@ -1,4 +1,4 @@
import { sqliteTable, text, blob } from "drizzle-orm/sqlite-core";
import { blob, sqliteTable, text } from "drizzle-orm/sqlite-core";
export const user = sqliteTable("user", {
id: text("id").primaryKey(),

@ -1,2 +1,2 @@
export { todos } from "./todos";
export * from "./auth"
export * from "./auth";

@ -1,4 +1,4 @@
import { text, integer, sqliteTable } from "drizzle-orm/sqlite-core";
import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
import { createInsertSchema, createSelectSchema } from "drizzle-typebox";
export const todos = sqliteTable("todos", {

@ -1,8 +1,8 @@
import { Elysia } from "elysia";
// import { swagger } from "@elysiajs/swagger";
import { staticPlugin } from "@elysiajs/static";
import { api } from "./controllers/*";
import { Elysia } from "elysia";
import { config } from "./config";
import { api } from "./controllers/*";
import { pages } from "./pages/*";
const app = new Elysia()
@ -24,5 +24,5 @@ const app = new Elysia()
export type App = typeof app;
console.log(
`app is listening on http://${app.server?.hostname}:${app.server?.port}`
`app is listening on http://${app.server?.hostname}:${app.server?.port}`,
);

@ -1,6 +1,7 @@
import Elysia from "elysia";
// import { signup } from "./signup";
import { profile } from "./profile";
// import { signin } from "./signin";
export const authGroup = new Elysia()

@ -9,6 +9,10 @@ export const profile = new Elysia()
const session = await authRequest.validate();
return html(() =>
session ? <div>Hello {session.user.email}</div> : <div>Not logged in</div>
session ? (
<div>Hello {session.user.email}</div>
) : (
<div>Not logged in</div>
),
);
});

@ -1,5 +1,5 @@
import Elysia from "elysia";
import { index } from "./index";
import { authGroup } from "./(auth)/*";
import { index } from "./index";
export const pages = new Elysia().use(index).use(authGroup);

@ -1,8 +1,8 @@
import { persistedCache, revalidateTag } from "beth-stack/cache";
import { renderToStream, renderToString, Suspense } from "beth-stack/jsx";
import { Elysia } from "elysia";
import { BaseHtml } from "../components/base";
import { ctx } from "../context";
import { Suspense, renderToStream, renderToString } from "beth-stack/jsx";
import { persistedCache, revalidateTag } from "beth-stack/cache";
const start = Date.now();
@ -58,7 +58,7 @@ function wait(ms: number): Promise<number> {
return new Promise((resolve) =>
setTimeout(() => {
resolve(ms);
}, ms)
}, ms),
);
}

@ -1,6 +1,6 @@
type RoutesByType<
Schema extends Record<string, any>, // Ensure keys are strings
Type extends "get" | "post" | "put" | "delete" | "patch"
Type extends "get" | "post" | "put" | "delete" | "patch",
> = RouterPattern<
RemoveSlash<
string &