chore: initial Vector 2.0 monorepo
Ground-up TypeScript rewrite of the Vector hardware parts inventory
system. Ships the full roadmap (Phases 0-8) in one initial commit:
- pnpm + Turbo monorepo: apps/{api,web,e2e}, packages/{db,shared,ui,config}
- Express 5 + Prisma 5 + zod validation + JWT w/ refresh-token rotation
- React 19 + Vite + shadcn/ui + TanStack Query/Table + nuqs URL state
- Repair/RMA, tags, bulk ops, saved views, CSV audit export
- Analytics dashboard on Recharts + EOL tracking
- Signed webhook subscriptions (HMAC-SHA256) with in-process emitter
- Vitest unit tests (shared schemas, api services/helpers) + Playwright skeleton
- Gitea Actions CI (lint, typecheck, test+coverage, build) + Renovate
Deferred follow-ups: Postgres cutover (data-migration script ready),
BullMQ worker for webhook delivery, @react-pdf PDF export, CSV import wizard.
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { fileURLToPath, pathToFileURL } from 'node:url';
|
||||
import path from 'node:path';
|
||||
|
||||
declare global {
|
||||
// eslint-disable-next-line no-var
|
||||
var __vectorPrisma: PrismaClient | undefined;
|
||||
}
|
||||
|
||||
function resolveSqliteUrl(raw: string | undefined): string | undefined {
|
||||
if (!raw || !raw.startsWith('file:')) return raw;
|
||||
const rest = raw.slice('file:'.length).replace(/^\/+/, '');
|
||||
if (path.isAbsolute(rest) || /^[A-Za-z]:[\\/]/.test(rest)) {
|
||||
return 'file:' + rest.replace(/\\/g, '/');
|
||||
}
|
||||
const here = path.dirname(fileURLToPath(import.meta.url));
|
||||
const schemaDir = path.resolve(here, '..', 'prisma');
|
||||
const absolute = path.resolve(schemaDir, rest);
|
||||
return 'file:' + absolute.replace(/\\/g, '/');
|
||||
}
|
||||
|
||||
const url = resolveSqliteUrl(process.env.DATABASE_URL);
|
||||
|
||||
export const prisma: PrismaClient =
|
||||
globalThis.__vectorPrisma ??
|
||||
new PrismaClient({
|
||||
datasources: url ? { db: { url } } : undefined,
|
||||
log: process.env.NODE_ENV === 'production' ? ['error'] : ['warn', 'error'],
|
||||
});
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
globalThis.__vectorPrisma = prisma;
|
||||
}
|
||||
Reference in New Issue
Block a user