Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions client/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,15 @@ export default defineConfig({
sourcemap: true,
target: "esnext",
reportCompressedSize: false,
modulePreload: { polyfill: false },
rollupOptions: {
treeshake: {
moduleSideEffects: [`${normalizePath(__dirname)}/main.tsx`],
propertyReadSideEffects: false,
tryCatchDeoptimization: false,
unknownGlobalSideEffects: false,
},
},
},
esbuild: {
minifyIdentifiers: false,
Expand Down
2 changes: 2 additions & 0 deletions repo.dict.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ crsqlite
cryb
datetime
dbname
deoptimization
fastify
fract
knip
Expand All @@ -21,6 +22,7 @@ spotify
sqlite
SQLITE_IOERR_WRITE
tanstack
treeshake
tsbuildinfo
valibot
vlcn
2 changes: 1 addition & 1 deletion server/src/api/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const definition = define<typeof schema>({
method: "get",
})

export const handler = /* @__PURE__ */ procedure(schema, definition, {
export const handler = procedure(schema, definition, {
onRequest: authProtected.onRequest,
handler(request, reply) {
const user = request.session.user!
Expand Down
3 changes: 3 additions & 0 deletions server/src/api/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type SchemaToRouteGeneric<Schema extends BaseSchema> = {
: never
}

/* @__NO_SIDE_EFFECTS__ */
export function define<const Schema extends BaseSchema>(definition: {
method: HTTPMethods // | HTTPMethods[]
url: string
Expand All @@ -70,6 +71,7 @@ export function define<const Schema extends BaseSchema>(definition: {
} as any
}

/* @__NO_SIDE_EFFECTS__ */
export function procedure<const Schema extends BaseSchema = object>(
schema: Schema,
definition: {
Expand All @@ -90,6 +92,7 @@ export function procedure<const Schema extends BaseSchema = object>(
}

type Plugin = (fastify: FastifyInstance, opts: object, done: () => void) => void
/* @__NO_SIDE_EFFECTS__ */
export function pluginFromRoutes(routes: RouteOptions[]): Plugin {
return function routesPlugin(fastify, opts, done) {
for (const route of routes) {
Expand Down
2 changes: 1 addition & 1 deletion server/src/api/open.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const definition = define<typeof schema>({
method: "get",
})

export const handler = /* @__PURE__ */ procedure(schema, definition, {
export const handler = procedure(schema, definition, {
handler(request, reply) {
request.log.info("hello world", request.query.id, request.headers["x-id"])
if (request.query.id === "42") {
Expand Down
2 changes: 1 addition & 1 deletion server/src/api/protected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const definition = define<typeof schema>({
method: "get",
})

export const handler = /* @__PURE__ */ procedure(schema, definition, {
export const handler = procedure(schema, definition, {
onRequest: authProtected.onRequest,
handler(request, reply) {
void reply.status(200).send({ secret: "🙈" })
Expand Down
2 changes: 1 addition & 1 deletion server/src/api/save.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const definition = define<typeof schema>({
method: "post",
})

export const handler = /* @__PURE__ */ procedure(schema, definition, {
export const handler = procedure(schema, definition, {
async handler(request, reply) {
request.log.info(`Received: ${JSON.stringify(request.body)}`)
setTimeout(() => {
Expand Down