mirror of
https://github.com/swissmakers/swiss-datashare.git
synced 2026-04-17 04:33:15 +02:00
feat: add setup wizard
This commit is contained in:
@@ -1,79 +1,8 @@
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
import configVariables from "../../src/configVariables";
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
const configVariables = [
|
||||
{
|
||||
key: "setupFinished",
|
||||
type: "boolean",
|
||||
default: "false",
|
||||
secret: false,
|
||||
locked: true
|
||||
},
|
||||
{
|
||||
key: "appUrl",
|
||||
type: "string",
|
||||
default: "http://localhost:3000",
|
||||
secret: false,
|
||||
},
|
||||
{
|
||||
key: "showHomePage",
|
||||
type: "boolean",
|
||||
default: "true",
|
||||
secret: false,
|
||||
},
|
||||
{
|
||||
key: "allowRegistration",
|
||||
type: "boolean",
|
||||
default: "true",
|
||||
secret: false,
|
||||
},
|
||||
{
|
||||
key: "allowUnauthenticatedShares",
|
||||
type: "boolean",
|
||||
default: "false",
|
||||
secret: false,
|
||||
},
|
||||
{
|
||||
key: "maxFileSize",
|
||||
type: "number",
|
||||
default: "1000000000",
|
||||
secret: false,
|
||||
},
|
||||
{
|
||||
key: "jwtSecret",
|
||||
type: "string",
|
||||
default: "long-random-string",
|
||||
locked: true
|
||||
},
|
||||
{
|
||||
key: "emailRecipientsEnabled",
|
||||
type: "boolean",
|
||||
default: "false",
|
||||
secret: false,
|
||||
},
|
||||
{
|
||||
key: "smtpHost",
|
||||
type: "string",
|
||||
default: "",
|
||||
},
|
||||
{
|
||||
key: "smtpPort",
|
||||
type: "number",
|
||||
default: "",
|
||||
},
|
||||
{
|
||||
key: "smtpEmail",
|
||||
type: "string",
|
||||
default: "",
|
||||
},
|
||||
{
|
||||
key: "smtpPassword",
|
||||
type: "string",
|
||||
default: "",
|
||||
},
|
||||
];
|
||||
|
||||
async function main() {
|
||||
for (const variable of configVariables) {
|
||||
const existingConfigVariable = await prisma.config.findUnique({
|
||||
@@ -85,14 +14,6 @@ async function main() {
|
||||
await prisma.config.create({
|
||||
data: variable,
|
||||
});
|
||||
} else {
|
||||
// Update the config variable if the default value has changed
|
||||
if (existingConfigVariable.default != variable.default) {
|
||||
await prisma.config.update({
|
||||
where: { key: variable.key },
|
||||
data: { default: variable.default },
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user