Add ESLint + Prettier + EditorConfig tooling at repo root
v1.0 Phase 1.1 — repo-wide lint/format baseline. - eslint.config.mjs (flat config) lints server, client, shared - .prettierrc.json, .prettierignore, .editorconfig, .nvmrc - Root package.json holds shared devDeps; per-package scripts keep their typecheck + test runners - Fix 7 lint issues surfaced by the baseline run: - TicketDetail.tsx: replace ternary-with-side-effects with if/else - admin/Users.tsx: escape apostrophe in JSX - errorHandler.ts: typed err as unknown with ErrorLike refinement - users.ts: Prisma.UserUpdateInput instead of Record<string, any> - seed.ts: drop unused goddard binding - Run prettier across tracked sources for a clean formatting baseline
This commit is contained in:
+27
-24
@@ -1,11 +1,11 @@
|
||||
import { PrismaClient } from '@prisma/client'
|
||||
import bcrypt from 'bcryptjs'
|
||||
import crypto from 'crypto'
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import bcrypt from 'bcryptjs';
|
||||
import crypto from 'crypto';
|
||||
|
||||
const prisma = new PrismaClient()
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function main() {
|
||||
console.log('Seeding database...')
|
||||
console.log('Seeding database...');
|
||||
|
||||
// Admin user
|
||||
await prisma.user.upsert({
|
||||
@@ -18,11 +18,11 @@ async function main() {
|
||||
passwordHash: await bcrypt.hash('admin123', 12),
|
||||
role: 'ADMIN',
|
||||
},
|
||||
})
|
||||
});
|
||||
|
||||
// Goddard — n8n service account
|
||||
const apiKey = `sk_${crypto.randomBytes(32).toString('hex')}`
|
||||
const goddard = await prisma.user.upsert({
|
||||
const apiKey = `sk_${crypto.randomBytes(32).toString('hex')}`;
|
||||
await prisma.user.upsert({
|
||||
where: { username: 'goddard' },
|
||||
update: {},
|
||||
create: {
|
||||
@@ -33,70 +33,73 @@ async function main() {
|
||||
role: 'SERVICE',
|
||||
apiKey,
|
||||
},
|
||||
})
|
||||
});
|
||||
|
||||
const existingGoddard = await prisma.user.findUnique({ where: { username: 'goddard' } })
|
||||
console.log(`\nGoddard API key: ${existingGoddard?.apiKey ?? apiKey}`)
|
||||
console.log('(This key is only displayed once on first seed — copy it now)\n')
|
||||
const existingGoddard = await prisma.user.findUnique({ where: { username: 'goddard' } });
|
||||
console.log(`\nGoddard API key: ${existingGoddard?.apiKey ?? apiKey}`);
|
||||
console.log('(This key is only displayed once on first seed — copy it now)\n');
|
||||
|
||||
// Sample CTI structure
|
||||
const theWrightServer = await prisma.category.upsert({
|
||||
where: { name: 'TheWrightServer' },
|
||||
update: {},
|
||||
create: { name: 'TheWrightServer' },
|
||||
})
|
||||
});
|
||||
|
||||
const homelab = await prisma.category.upsert({
|
||||
where: { name: 'Homelab' },
|
||||
update: {},
|
||||
create: { name: 'Homelab' },
|
||||
})
|
||||
});
|
||||
|
||||
const automation = await prisma.type.upsert({
|
||||
where: { categoryId_name: { categoryId: theWrightServer.id, name: 'Automation' } },
|
||||
update: {},
|
||||
create: { name: 'Automation', categoryId: theWrightServer.id },
|
||||
})
|
||||
});
|
||||
|
||||
const media = await prisma.type.upsert({
|
||||
where: { categoryId_name: { categoryId: theWrightServer.id, name: 'Media' } },
|
||||
update: {},
|
||||
create: { name: 'Media', categoryId: theWrightServer.id },
|
||||
})
|
||||
});
|
||||
|
||||
const infrastructure = await prisma.type.upsert({
|
||||
where: { categoryId_name: { categoryId: homelab.id, name: 'Infrastructure' } },
|
||||
update: {},
|
||||
create: { name: 'Infrastructure', categoryId: homelab.id },
|
||||
})
|
||||
});
|
||||
|
||||
await prisma.item.upsert({
|
||||
where: { typeId_name: { typeId: automation.id, name: 'Backup' } },
|
||||
update: {},
|
||||
create: { name: 'Backup', typeId: automation.id },
|
||||
})
|
||||
});
|
||||
|
||||
await prisma.item.upsert({
|
||||
where: { typeId_name: { typeId: automation.id, name: 'Sync' } },
|
||||
update: {},
|
||||
create: { name: 'Sync', typeId: automation.id },
|
||||
})
|
||||
});
|
||||
|
||||
await prisma.item.upsert({
|
||||
where: { typeId_name: { typeId: media.id, name: 'Plex' } },
|
||||
update: {},
|
||||
create: { name: 'Plex', typeId: media.id },
|
||||
})
|
||||
});
|
||||
|
||||
await prisma.item.upsert({
|
||||
where: { typeId_name: { typeId: infrastructure.id, name: 'Proxmox' } },
|
||||
update: {},
|
||||
create: { name: 'Proxmox', typeId: infrastructure.id },
|
||||
})
|
||||
});
|
||||
|
||||
console.log('Seed complete.')
|
||||
console.log('Seed complete.');
|
||||
}
|
||||
|
||||
main()
|
||||
.catch((e) => { console.error(e); process.exit(1) })
|
||||
.finally(() => prisma.$disconnect())
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
})
|
||||
.finally(() => prisma.$disconnect());
|
||||
|
||||
Reference in New Issue
Block a user