Working on settings Page. Adding init function on next.js startup.

This commit is contained in:
charles-gauthereau
2024-11-16 22:00:22 +01:00
parent b8218dcf85
commit b9a56188ae
16 changed files with 382 additions and 26 deletions
+41
View File
@@ -0,0 +1,41 @@
import {prisma} from "@/prisma";
export function init() {
consoleAscii()
console.log("====Init Functions====")
createSettingsIfNotExist()
.then(() => {
console.log('====Initialization completed====');
})
.catch((err) => {
console.error('Error during initialization:', err);
});
}
async function createSettingsIfNotExist() {
const settings = await prisma.settings.findUnique({
where: {
name: "system",
}
})
if(!settings){
console.log("====Init Setting====")
await prisma.settings.create({
data: {
name: "system",
}
})
}
}
function consoleAscii(){
console.log("\n" +
" ____ __ __ _____ \n" +
" / __ \\ ____ _____ / /_ ____ _ / /_ ____ _ _____ ___ / ___/ ___ _____ _ __ ___ _____\n" +
" / /_/ // __ \\ / ___// __// __ `// __ \\ / __ `// ___// _ \\ \\__ \\ / _ \\ / ___/| | / // _ \\ / ___/\n" +
" / ____// /_/ // / / /_ / /_/ // /_/ // /_/ /(__ )/ __/ ___/ // __// / | |/ // __// / \n" +
"/_/ \\____//_/ \\__/ \\__,_//_.___/ \\__,_//____/ \\___/ /____/ \\___//_/ |___/ \\___//_/ \n" +
" \n")
}