forked from imbytecat/fullstack-starter
style: 将 biome lineWidth 从默认 80 调整为 120
This commit is contained in:
@@ -28,8 +28,7 @@ const sidecar = createSidecarRuntime({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const toErrorMessage = (error: unknown): string =>
|
const toErrorMessage = (error: unknown): string => (error instanceof Error ? error.message : String(error))
|
||||||
error instanceof Error ? error.message : String(error)
|
|
||||||
|
|
||||||
const canOpenExternally = (url: string): boolean => {
|
const canOpenExternally = (url: string): boolean => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -29,12 +29,9 @@ type SidecarRuntime = {
|
|||||||
stop: () => void
|
stop: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const sleep = (ms: number): Promise<void> =>
|
const sleep = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms))
|
||||||
new Promise((resolve) => setTimeout(resolve, ms))
|
|
||||||
|
|
||||||
const isProcessAlive = (
|
const isProcessAlive = (processToCheck: ChildProcess | null): processToCheck is ChildProcess => {
|
||||||
processToCheck: ChildProcess | null,
|
|
||||||
): processToCheck is ChildProcess => {
|
|
||||||
if (!processToCheck || !processToCheck.pid) {
|
if (!processToCheck || !processToCheck.pid) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -81,11 +78,7 @@ const isServerReady = async (url: string): Promise<boolean> => {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
const waitForServer = async (
|
const waitForServer = async (url: string, isQuitting: () => boolean, processRef?: ChildProcess): Promise<boolean> => {
|
||||||
url: string,
|
|
||||||
isQuitting: () => boolean,
|
|
||||||
processRef?: ChildProcess,
|
|
||||||
): Promise<boolean> => {
|
|
||||||
const start = Date.now()
|
const start = Date.now()
|
||||||
while (Date.now() - start < SERVER_READY_TIMEOUT_MS && !isQuitting()) {
|
while (Date.now() - start < SERVER_READY_TIMEOUT_MS && !isQuitting()) {
|
||||||
if (processRef && processRef.exitCode !== null) {
|
if (processRef && processRef.exitCode !== null) {
|
||||||
@@ -119,9 +112,7 @@ const formatUnexpectedStopMessage = (
|
|||||||
return `Server process exited unexpectedly (code ${code ?? 'unknown'}, signal ${signal ?? 'none'}).`
|
return `Server process exited unexpectedly (code ${code ?? 'unknown'}, signal ${signal ?? 'none'}).`
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createSidecarRuntime = (
|
export const createSidecarRuntime = (options: SidecarRuntimeOptions): SidecarRuntime => {
|
||||||
options: SidecarRuntimeOptions,
|
|
||||||
): SidecarRuntime => {
|
|
||||||
const state: SidecarState = {
|
const state: SidecarState = {
|
||||||
process: null,
|
process: null,
|
||||||
startup: null,
|
startup: null,
|
||||||
@@ -162,9 +153,7 @@ export const createSidecarRuntime = (
|
|||||||
resetState(processRef)
|
resetState(processRef)
|
||||||
|
|
||||||
if (!options.isQuitting() && hadReadyServer) {
|
if (!options.isQuitting() && hadReadyServer) {
|
||||||
options.onUnexpectedStop(
|
options.onUnexpectedStop('The background service crashed unexpectedly. Please restart the app.')
|
||||||
'The background service crashed unexpectedly. Please restart the app.',
|
|
||||||
)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,9 +169,7 @@ export const createSidecarRuntime = (
|
|||||||
resetState(processRef)
|
resetState(processRef)
|
||||||
|
|
||||||
if (!options.isQuitting() && hadReadyServer) {
|
if (!options.isQuitting() && hadReadyServer) {
|
||||||
options.onUnexpectedStop(
|
options.onUnexpectedStop(formatUnexpectedStopMessage(options.isPackaged, code, signal))
|
||||||
formatUnexpectedStopMessage(options.isPackaged, code, signal),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -222,11 +209,7 @@ export const createSidecarRuntime = (
|
|||||||
state.process = processRef
|
state.process = processRef
|
||||||
attachLifecycleHandlers(processRef)
|
attachLifecycleHandlers(processRef)
|
||||||
|
|
||||||
const ready = await waitForServer(
|
const ready = await waitForServer(nextServerUrl, options.isQuitting, processRef)
|
||||||
nextServerUrl,
|
|
||||||
options.isQuitting,
|
|
||||||
processRef,
|
|
||||||
)
|
|
||||||
if (ready && isProcessAlive(processRef)) {
|
if (ready && isProcessAlive(processRef)) {
|
||||||
state.url = nextServerUrl
|
state.url = nextServerUrl
|
||||||
return nextServerUrl
|
return nextServerUrl
|
||||||
@@ -253,9 +236,7 @@ export const createSidecarRuntime = (
|
|||||||
|
|
||||||
const ready = await waitForServer(options.devServerUrl, options.isQuitting)
|
const ready = await waitForServer(options.devServerUrl, options.isQuitting)
|
||||||
if (!ready) {
|
if (!ready) {
|
||||||
throw new Error(
|
throw new Error('Dev server not responding. Run `bun dev` in apps/server first.')
|
||||||
'Dev server not responding. Run `bun dev` in apps/server first.',
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return options.devServerUrl
|
return options.devServerUrl
|
||||||
|
|||||||
@@ -13,12 +13,7 @@ export const SplashApp = () => {
|
|||||||
ease: [0.16, 1, 0.3, 1],
|
ease: [0.16, 1, 0.3, 1],
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<img
|
<img alt="Logo" className="h-20 w-auto object-contain" draggable={false} src={logoImage} />
|
||||||
alt="Logo"
|
|
||||||
className="h-20 w-auto object-contain"
|
|
||||||
draggable={false}
|
|
||||||
src={logoImage}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div className="relative h-[4px] w-36 overflow-hidden rounded-full bg-zinc-100">
|
<div className="relative h-[4px] w-36 overflow-hidden rounded-full bg-zinc-100">
|
||||||
<motion.div
|
<motion.div
|
||||||
|
|||||||
@@ -10,11 +10,7 @@
|
|||||||
"outputs": ["dist/**"]
|
"outputs": ["dist/**"]
|
||||||
},
|
},
|
||||||
"dist:linux": {
|
"dist:linux": {
|
||||||
"dependsOn": [
|
"dependsOn": ["build", "@furtherverse/server#compile:linux:arm64", "@furtherverse/server#compile:linux:x64"],
|
||||||
"build",
|
|
||||||
"@furtherverse/server#compile:linux:arm64",
|
|
||||||
"@furtherverse/server#compile:linux:x64"
|
|
||||||
],
|
|
||||||
"outputs": ["dist/**"]
|
"outputs": ["dist/**"]
|
||||||
},
|
},
|
||||||
"dist:linux:arm64": {
|
"dist:linux:arm64": {
|
||||||
@@ -26,11 +22,7 @@
|
|||||||
"outputs": ["dist/**"]
|
"outputs": ["dist/**"]
|
||||||
},
|
},
|
||||||
"dist:mac": {
|
"dist:mac": {
|
||||||
"dependsOn": [
|
"dependsOn": ["build", "@furtherverse/server#compile:darwin:arm64", "@furtherverse/server#compile:darwin:x64"],
|
||||||
"build",
|
|
||||||
"@furtherverse/server#compile:darwin:arm64",
|
|
||||||
"@furtherverse/server#compile:darwin:x64"
|
|
||||||
],
|
|
||||||
"outputs": ["dist/**"]
|
"outputs": ["dist/**"]
|
||||||
},
|
},
|
||||||
"dist:mac:arm64": {
|
"dist:mac:arm64": {
|
||||||
|
|||||||
@@ -24,9 +24,7 @@ const { values } = parseArgs({
|
|||||||
const resolveTarget = (): Bun.Build.CompileTarget => {
|
const resolveTarget = (): Bun.Build.CompileTarget => {
|
||||||
if (values.target !== undefined) {
|
if (values.target !== undefined) {
|
||||||
if (!isSupportedTarget(values.target)) {
|
if (!isSupportedTarget(values.target)) {
|
||||||
throw new Error(
|
throw new Error(`Invalid target: ${values.target}\nAllowed: ${SUPPORTED_TARGETS.join(', ')}`)
|
||||||
`Invalid target: ${values.target}\nAllowed: ${SUPPORTED_TARGETS.join(', ')}`,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
return values.target
|
return values.target
|
||||||
}
|
}
|
||||||
@@ -45,10 +43,7 @@ const main = async () => {
|
|||||||
const outfile = `server-${suffix}`
|
const outfile = `server-${suffix}`
|
||||||
|
|
||||||
await mkdir(OUTDIR, { recursive: true })
|
await mkdir(OUTDIR, { recursive: true })
|
||||||
await Promise.all([
|
await Promise.all([rm(`${OUTDIR}/${outfile}`, { force: true }), rm(`${OUTDIR}/${outfile}.exe`, { force: true })])
|
||||||
rm(`${OUTDIR}/${outfile}`, { force: true }),
|
|
||||||
rm(`${OUTDIR}/${outfile}.exe`, { force: true }),
|
|
||||||
])
|
|
||||||
|
|
||||||
const result = await Bun.build({
|
const result = await Bun.build({
|
||||||
entrypoints: [ENTRYPOINT],
|
entrypoints: [ENTRYPOINT],
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
import { TanStackDevtools } from '@tanstack/react-devtools'
|
import { TanStackDevtools } from '@tanstack/react-devtools'
|
||||||
import type { QueryClient } from '@tanstack/react-query'
|
import type { QueryClient } from '@tanstack/react-query'
|
||||||
import { ReactQueryDevtoolsPanel } from '@tanstack/react-query-devtools'
|
import { ReactQueryDevtoolsPanel } from '@tanstack/react-query-devtools'
|
||||||
import {
|
import { createRootRouteWithContext, HeadContent, Scripts } from '@tanstack/react-router'
|
||||||
createRootRouteWithContext,
|
|
||||||
HeadContent,
|
|
||||||
Scripts,
|
|
||||||
} from '@tanstack/react-router'
|
|
||||||
import { TanStackRouterDevtoolsPanel } from '@tanstack/react-router-devtools'
|
import { TanStackRouterDevtoolsPanel } from '@tanstack/react-router-devtools'
|
||||||
import type { ReactNode } from 'react'
|
import type { ReactNode } from 'react'
|
||||||
import { ErrorComponent } from '@/components/Error'
|
import { ErrorComponent } from '@/components/Error'
|
||||||
|
|||||||
@@ -53,9 +53,7 @@ function Todos() {
|
|||||||
{/* Header */}
|
{/* Header */}
|
||||||
<div className="flex items-end justify-between">
|
<div className="flex items-end justify-between">
|
||||||
<div>
|
<div>
|
||||||
<h1 className="text-3xl font-bold text-slate-900 tracking-tight">
|
<h1 className="text-3xl font-bold text-slate-900 tracking-tight">我的待办</h1>
|
||||||
我的待办
|
|
||||||
</h1>
|
|
||||||
<p className="text-slate-500 mt-1">保持专注,逐个击破</p>
|
<p className="text-slate-500 mt-1">保持专注,逐个击破</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="text-right">
|
<div className="text-right">
|
||||||
@@ -63,9 +61,7 @@ function Todos() {
|
|||||||
{completedCount}
|
{completedCount}
|
||||||
<span className="text-slate-400 text-lg">/{totalCount}</span>
|
<span className="text-slate-400 text-lg">/{totalCount}</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="text-xs font-medium text-slate-400 uppercase tracking-wider">
|
<div className="text-xs font-medium text-slate-400 uppercase tracking-wider">已完成</div>
|
||||||
已完成
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -112,18 +108,11 @@ function Todos() {
|
|||||||
stroke="currentColor"
|
stroke="currentColor"
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
>
|
>
|
||||||
<path
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} d="M12 6v6m0 0v6m0-6h6m-6 0H6" />
|
||||||
strokeLinecap="round"
|
|
||||||
strokeLinejoin="round"
|
|
||||||
strokeWidth={1.5}
|
|
||||||
d="M12 6v6m0 0v6m0-6h6m-6 0H6"
|
|
||||||
/>
|
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
<p className="text-slate-500 text-lg font-medium">没有待办事项</p>
|
<p className="text-slate-500 text-lg font-medium">没有待办事项</p>
|
||||||
<p className="text-slate-400 text-sm mt-1">
|
<p className="text-slate-400 text-sm mt-1">输入上方内容添加您的第一个任务</p>
|
||||||
输入上方内容添加您的第一个任务
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
todos.map((todo) => (
|
todos.map((todo) => (
|
||||||
@@ -151,11 +140,7 @@ function Todos() {
|
|||||||
strokeWidth={3}
|
strokeWidth={3}
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
>
|
>
|
||||||
<path
|
<path strokeLinecap="round" strokeLinejoin="round" d="M5 13l4 4L19 7" />
|
||||||
strokeLinecap="round"
|
|
||||||
strokeLinejoin="round"
|
|
||||||
d="M5 13l4 4L19 7"
|
|
||||||
/>
|
|
||||||
</svg>
|
</svg>
|
||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
import { oc } from '@orpc/contract'
|
import { oc } from '@orpc/contract'
|
||||||
import {
|
import { createInsertSchema, createSelectSchema, createUpdateSchema } from 'drizzle-orm/zod'
|
||||||
createInsertSchema,
|
|
||||||
createSelectSchema,
|
|
||||||
createUpdateSchema,
|
|
||||||
} from 'drizzle-orm/zod'
|
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
import { todoTable } from '@/server/db/schema'
|
import { todoTable } from '@/server/db/schema'
|
||||||
|
|
||||||
|
|||||||
@@ -6,11 +6,7 @@ export const logError = (error: unknown) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const handleValidationError = (error: unknown) => {
|
export const handleValidationError = (error: unknown) => {
|
||||||
if (
|
if (error instanceof ORPCError && error.code === 'BAD_REQUEST' && error.cause instanceof ValidationError) {
|
||||||
error instanceof ORPCError &&
|
|
||||||
error.code === 'BAD_REQUEST' &&
|
|
||||||
error.cause instanceof ValidationError
|
|
||||||
) {
|
|
||||||
// If you only use Zod you can safely cast to ZodIssue[] (per ORPC official docs)
|
// If you only use Zod you can safely cast to ZodIssue[] (per ORPC official docs)
|
||||||
const zodError = new z.ZodError(error.cause.issues as z.core.$ZodIssue[])
|
const zodError = new z.ZodError(error.cause.issues as z.core.$ZodIssue[])
|
||||||
|
|
||||||
@@ -22,11 +18,7 @@ export const handleValidationError = (error: unknown) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (error instanceof ORPCError && error.code === 'INTERNAL_SERVER_ERROR' && error.cause instanceof ValidationError) {
|
||||||
error instanceof ORPCError &&
|
|
||||||
error.code === 'INTERNAL_SERVER_ERROR' &&
|
|
||||||
error.cause instanceof ValidationError
|
|
||||||
) {
|
|
||||||
throw new ORPCError('OUTPUT_VALIDATION_FAILED', {
|
throw new ORPCError('OUTPUT_VALIDATION_FAILED', {
|
||||||
cause: error.cause,
|
cause: error.cause,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -11,13 +11,8 @@ export const list = os.todo.list.use(db).handler(async ({ context }) => {
|
|||||||
return todos
|
return todos
|
||||||
})
|
})
|
||||||
|
|
||||||
export const create = os.todo.create
|
export const create = os.todo.create.use(db).handler(async ({ context, input }) => {
|
||||||
.use(db)
|
const [newTodo] = await context.db.insert(todoTable).values(input).returning()
|
||||||
.handler(async ({ context, input }) => {
|
|
||||||
const [newTodo] = await context.db
|
|
||||||
.insert(todoTable)
|
|
||||||
.values(input)
|
|
||||||
.returning()
|
|
||||||
|
|
||||||
if (!newTodo) {
|
if (!newTodo) {
|
||||||
throw new ORPCError('NOT_FOUND')
|
throw new ORPCError('NOT_FOUND')
|
||||||
@@ -26,14 +21,8 @@ export const create = os.todo.create
|
|||||||
return newTodo
|
return newTodo
|
||||||
})
|
})
|
||||||
|
|
||||||
export const update = os.todo.update
|
export const update = os.todo.update.use(db).handler(async ({ context, input }) => {
|
||||||
.use(db)
|
const [updatedTodo] = await context.db.update(todoTable).set(input.data).where(eq(todoTable.id, input.id)).returning()
|
||||||
.handler(async ({ context, input }) => {
|
|
||||||
const [updatedTodo] = await context.db
|
|
||||||
.update(todoTable)
|
|
||||||
.set(input.data)
|
|
||||||
.where(eq(todoTable.id, input.id))
|
|
||||||
.returning()
|
|
||||||
|
|
||||||
if (!updatedTodo) {
|
if (!updatedTodo) {
|
||||||
throw new ORPCError('NOT_FOUND')
|
throw new ORPCError('NOT_FOUND')
|
||||||
@@ -42,8 +31,6 @@ export const update = os.todo.update
|
|||||||
return updatedTodo
|
return updatedTodo
|
||||||
})
|
})
|
||||||
|
|
||||||
export const remove = os.todo.remove
|
export const remove = os.todo.remove.use(db).handler(async ({ context, input }) => {
|
||||||
.use(db)
|
|
||||||
.handler(async ({ context, input }) => {
|
|
||||||
await context.db.delete(todoTable).where(eq(todoTable.id, input.id))
|
await context.db.delete(todoTable).where(eq(todoTable.id, input.id))
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
import type {
|
import type { ContractRouterClient, InferContractRouterInputs, InferContractRouterOutputs } from '@orpc/contract'
|
||||||
ContractRouterClient,
|
|
||||||
InferContractRouterInputs,
|
|
||||||
InferContractRouterOutputs,
|
|
||||||
} from '@orpc/contract'
|
|
||||||
import type { Contract } from './contracts'
|
import type { Contract } from './contracts'
|
||||||
|
|
||||||
export type RouterClient = ContractRouterClient<Contract>
|
export type RouterClient = ContractRouterClient<Contract>
|
||||||
|
|||||||
@@ -25,8 +25,7 @@ export const pk = (name: string, strategy?: 'native' | 'extension') => {
|
|||||||
|
|
||||||
// timestamp
|
// timestamp
|
||||||
|
|
||||||
export const createdAt = (name = 'created_at') =>
|
export const createdAt = (name = 'created_at') => timestamp(name, { withTimezone: true }).notNull().defaultNow()
|
||||||
timestamp(name, { withTimezone: true }).notNull().defaultNow()
|
|
||||||
|
|
||||||
export const updatedAt = (name = 'updated_at') =>
|
export const updatedAt = (name = 'updated_at') =>
|
||||||
timestamp(name, { withTimezone: true })
|
timestamp(name, { withTimezone: true })
|
||||||
@@ -43,9 +42,7 @@ export const generatedFields = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Helper to create omit keys from generatedFields
|
// Helper to create omit keys from generatedFields
|
||||||
const createGeneratedFieldKeys = <T extends Record<string, unknown>>(
|
const createGeneratedFieldKeys = <T extends Record<string, unknown>>(fields: T): Record<keyof T, true> => {
|
||||||
fields: T,
|
|
||||||
): Record<keyof T, true> => {
|
|
||||||
return Object.keys(fields).reduce(
|
return Object.keys(fields).reduce(
|
||||||
(acc, key) => {
|
(acc, key) => {
|
||||||
acc[key as keyof T] = true
|
acc[key as keyof T] = true
|
||||||
|
|||||||
@@ -11,7 +11,8 @@
|
|||||||
"formatter": {
|
"formatter": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"indentStyle": "space",
|
"indentStyle": "space",
|
||||||
"lineEnding": "lf"
|
"lineEnding": "lf",
|
||||||
|
"lineWidth": 120
|
||||||
},
|
},
|
||||||
"linter": {
|
"linter": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
|
|||||||
Reference in New Issue
Block a user