a spot idek

main
Ethan Niser 2023-09-13 16:18:14 -05:00
parent 49684bd6e9
commit 349b208adb
9 changed files with 26 additions and 18 deletions

Binary file not shown.

@ -15,9 +15,9 @@
},
"dependencies": {
"@bogeychan/elysia-logger": "0.0.9",
"@elysiajs/html": "^0.6.5",
"@elysiajs/static": "^0.6.0",
"@elysiajs/swagger": "^0.6.2",
"@kitajs/html": "^2.1.2",
"@t3-oss/env-core": "^0.6.1",
"drizzle-orm": "^0.28.6",
"drizzle-typebox": "^0.1.1",

Binary file not shown.

@ -1,9 +1,9 @@
import { Elysia } from "elysia";
import { logger } from "@bogeychan/elysia-logger";
import pretty from "pino-pretty";
import { html } from "@elysiajs/html";
import { config } from "../config";
import { db } from "../model/store";
import "@kitajs/html/htmx";
const stream = pretty({
colorize: true,
@ -18,17 +18,16 @@ export const ctx = new Elysia({
stream,
})
)
.use(html())
.decorate("db", db)
.decorate("config", config)
// .onStart(({ log }) => log.info("Server starting"))
// .onStop(({ log }) => log.info("Server stopping"))
.onRequest(({ log, request }) =>
log.debug(`Request received: ${request.method}: ${request.url}`)
)
.onResponse(({ log, request, set }) =>
log.debug(
`Response sent: ${request.method}: ${request.url} with status ${set.status}`
)
);
.decorate("config", config);
// .onStart(({ log }) => log.info("Server starting"))
// .onStop(({ log }) => log.info("Server stopping"))
// .onRequest(({ log, request }) => {
// log.debug(`Request received: ${request.method}: ${request.url}`);
// });
// .onResponse(({ log, request, set }) => {
// log.debug(
// `Response sent: ${request.method}: ${request.url} with status ${set.status}`
// );
// });
// .onError(({ log, error }) => log.error(error));

@ -2,6 +2,8 @@ import Elysia from "elysia";
import { ctx } from "../context";
import { insertTodoSchema } from "../model/todo";
import { TodoItem } from "../views/todoItem";
import Html from "@kitajs/html";
import { db } from "../model/store";
export const todosController = new Elysia({
name: "@app/todos",
@ -11,7 +13,8 @@ export const todosController = new Elysia({
.model({
todo: insertTodoSchema,
})
.get("/", async ({ db }) => {
.get("/", async ({ log }) => {
log.info("get todos");
const todos = await db.query.todos.findMany();
return (

@ -12,3 +12,8 @@ const app = new Elysia({
.listen(3000);
console.log(`app is listening on ${app.server?.hostname}:${app.server?.port}`);
app
.handle(new Request("http://localhost:3000/todos"))
.then((res) => res.text())
.then(console.log);

@ -1,4 +1,5 @@
import type { Todo } from "../model/todo";
import Html from "@kitajs/html";
export const TodoItem = (todo: Todo) => {
return (

@ -12,8 +12,8 @@
"downlevelIteration": true,
"skipLibCheck": true,
"jsx": "react",
"jsxFactory": "ElysiaJSX",
"jsxFragmentFactory": "ElysiaJSX.Fragment",
"jsxFactory": "Html.createElement",
"jsxFragmentFactory": "Html.Fragment",
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"allowJs": true,

File diff suppressed because one or more lines are too long