+20
apps/api/src/index.ts
+20
apps/api/src/index.ts
···
8
import * as Sentry from "@sentry/node"
9
import { recipeApp } from "./recipes/index.js";
10
import { XRPCError } from "./util/xrpc.js";
11
+
import { getFilePathWithoutDefaultDocument } from "hono/utils/filepath";
12
+
import { readFileSync } from "fs";
13
14
if (env.SENTRY_DSN) {
15
Sentry.init({
···
58
message: 'The server could not process the request.',
59
});
60
}
61
+
});
62
+
63
+
app.use('/*', async (ctx, next) => {
64
+
if (ctx.finalized) return next();
65
+
66
+
let path = getFilePathWithoutDefaultDocument({
67
+
filename: 'index.html',
68
+
root: env.PUBLIC_DIR,
69
+
})
70
+
71
+
if (path) {
72
+
path = `./${path}`;
73
+
} else {
74
+
return next();
75
+
}
76
+
77
+
const index = readFileSync(path).toString();
78
+
return ctx.html(index);
79
});
80
81
serve({
+4
-1
apps/web/src/routes/_.(app)/recipes/new.tsx
+4
-1
apps/web/src/routes/_.(app)/recipes/new.tsx
···
56
component: RouteComponent,
57
});
58
59
-
const schema = RecipeRecord;
60
61
function RouteComponent() {
62
const form = useForm<z.infer<typeof schema>>({
63
resolver: zodResolver(schema),
64
defaultValues: {
65
title: "",
66
description: "",
67
ingredients: [{ name: "" }],
68
steps: [{ text: "" }],
···
56
component: RouteComponent,
57
});
58
59
+
const schema = RecipeRecord.extend({
60
+
time: z.coerce.number(),
61
+
});
62
63
function RouteComponent() {
64
const form = useForm<z.infer<typeof schema>>({
65
resolver: zodResolver(schema),
66
defaultValues: {
67
title: "",
68
+
time: 0,
69
description: "",
70
ingredients: [{ name: "" }],
71
steps: [{ text: "" }],