mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
Working on settings. Adding .env value take in count when they are present in order to prefill the Settings on startup. Adding the SendEMail Feature and the form in settings.
This commit is contained in:
+29
-1
@@ -1,4 +1,6 @@
|
||||
import {prisma} from "@/prisma";
|
||||
import {Settings} from "@prisma/client";
|
||||
import {env} from "@/env.mjs";
|
||||
|
||||
|
||||
export function init() {
|
||||
@@ -15,19 +17,45 @@ export function init() {
|
||||
|
||||
async function createSettingsIfNotExist() {
|
||||
|
||||
const configSettings = {
|
||||
name: "system",
|
||||
smtpPassword: env.SMTP_PASSWORD ?? null,
|
||||
smtpFrom: env.SMTP_FROM ?? null,
|
||||
smtpHost: env.SMTP_HOST ?? null,
|
||||
smtpPort: env.SMTP_PORT ?? null,
|
||||
smtpUser: env.SMTP_USER ?? null,
|
||||
s3EndPointUrl: env.S3_ENDPOINT ?? null,
|
||||
s3AccessKeyId: env.S3_ACCESS_KEY ?? null,
|
||||
s3SecretAccessKey: env.S3_SECRET_KEY ?? null,
|
||||
S3BucketName: env.S3_BUCKET_NAME ?? null,
|
||||
}
|
||||
|
||||
|
||||
|
||||
const settings = await prisma.settings.findUnique({
|
||||
where: {
|
||||
name: "system",
|
||||
}
|
||||
})
|
||||
if(!settings){
|
||||
console.log("====Init Setting====")
|
||||
console.log("====Init Setting : Create ====")
|
||||
await prisma.settings.create({
|
||||
data: {
|
||||
name: "system",
|
||||
}
|
||||
})
|
||||
}else{
|
||||
console.log("====Init Setting : Update ====")
|
||||
await prisma.settings.update({
|
||||
where: {
|
||||
name: "system",
|
||||
},
|
||||
data: {
|
||||
...configSettings,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function consoleAscii(){
|
||||
|
||||
Reference in New Issue
Block a user