mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-13 21:01:21 +08:00
* added form setting card * removed unused code * added custom email server page * added email configuration dialog * added sender name * Update email server settings labels for clarity * added email config update endpoint * fixed update bugs * fixed bugs * fixed type errors * moved senderName to standard config, check secure setting by port * fixed duplicate settings * fixed build errors, added migration * updated tooltips * fixed tooltip display bug * added user permission edit
77 lines
2.1 KiB
TypeScript
77 lines
2.1 KiB
TypeScript
import { PrismaClient } from '@prisma/client';
|
|
const prisma = new PrismaClient();
|
|
|
|
|
|
async function seed() {
|
|
console.log('Seeding database...');
|
|
|
|
const oldProjects = await prisma.project.findUnique({
|
|
where: {
|
|
id: 'internal',
|
|
},
|
|
});
|
|
|
|
if (oldProjects) {
|
|
console.log('Internal project already exists, skipping seeding');
|
|
return;
|
|
}
|
|
|
|
await prisma.project.upsert({
|
|
where: {
|
|
id: 'internal',
|
|
},
|
|
create: {
|
|
id: 'internal',
|
|
displayName: 'Stack Dashboard',
|
|
description: 'Stack\'s admin dashboard',
|
|
isProductionMode: false,
|
|
apiKeySets: {
|
|
create: [{
|
|
description: "Internal API key set",
|
|
publishableClientKey: process.env.NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY ?? require('crypto').randomBytes(8).toString("hex"),
|
|
secretServerKey: process.env.STACK_SECRET_SERVER_KEY ?? require('crypto').randomBytes(8).toString("hex"),
|
|
expiresAt: new Date('2099-12-31T23:59:59Z'),
|
|
}],
|
|
},
|
|
config: {
|
|
create: {
|
|
allowLocalhost: true,
|
|
oauthProviderConfigs: {
|
|
create: (['github', 'facebook', 'google', 'microsoft'] as const).map((id) => ({
|
|
id,
|
|
proxiedOAuthConfig: {
|
|
create: {
|
|
type: id.toUpperCase() as any,
|
|
}
|
|
},
|
|
projectUserOAuthAccounts: {
|
|
create: []
|
|
}
|
|
})),
|
|
},
|
|
emailServiceConfig: {
|
|
create: {
|
|
proxiedEmailServiceConfig: {
|
|
create: {}
|
|
}
|
|
}
|
|
},
|
|
credentialEnabled: true,
|
|
magicLinkEnabled: true,
|
|
createTeamOnSignUp: false,
|
|
},
|
|
},
|
|
},
|
|
update: {},
|
|
});
|
|
console.log('Internal project created');
|
|
console.log('Seeding complete!');
|
|
}
|
|
|
|
seed().catch(async (e) => {
|
|
console.error(e);
|
|
await prisma.$disconnect();
|
|
process.exit(1);
|
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises, @typescript-eslint/return-await
|
|
}).finally(async () => await prisma.$disconnect());
|