chore: initialize SkyMoney (api + prisma + docker-compose) ( still in progress
This commit is contained in:
20
api/src/scripts/seed.ts
Normal file
20
api/src/scripts/seed.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
// prisma/seed.ts (optional: creates one demo user + categories)
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
const db = new PrismaClient();
|
||||
async function main() {
|
||||
const user = await db.user.upsert({
|
||||
where: { email: 'demo@user.test' },
|
||||
update: {},
|
||||
create: { email: 'demo@user.test' }
|
||||
});
|
||||
await db.variableCategory.createMany({
|
||||
data: [
|
||||
{ userId: user.id, name: 'Groceries', percent: 30, priority: 10 },
|
||||
{ userId: user.id, name: 'Gas', percent: 20, priority: 20 },
|
||||
{ userId: user.id, name: 'Fun', percent: 50, priority: 30 }
|
||||
],
|
||||
skipDuplicates: true
|
||||
});
|
||||
console.log('Seeded:', user.email);
|
||||
}
|
||||
main().finally(()=>db.$disconnect());
|
||||
10
api/src/server.ts
Normal file
10
api/src/server.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import Fastify from "fastify";
|
||||
|
||||
const app = Fastify({ logger: true });
|
||||
app.get("/health", async () => ({ ok: true }));
|
||||
|
||||
const port = Number(process.env.PORT ?? 8080);
|
||||
app.listen({ port, host: "0.0.0.0" }).catch((err) => {
|
||||
app.log.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user