Skip to content

Commit

Permalink
creating all data files on startup instead of having existing files
Browse files Browse the repository at this point in the history
  • Loading branch information
erikpersson0884 committed May 20, 2024
1 parent fb25880 commit b92f1e0
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 deletions.
4 changes: 1 addition & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
data/adminKeys.json
data/patetos.json
data/posts.json
data/*

public/img/postImages/*
public/profileImages/*
44 changes: 43 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,50 @@ export async function initialize_files(directories, files) {
});
}

initialize_files([dataFolderPath, pathToPatetosImages, pathToPostImages], [pathToPostsFile, pathToPatetosFile, pathToCredentialsFile, pathToAdminkeysFile]);
async function initiate_commitee_file() {
if (!fs.existsSync(pathToCommiteeFile)) {
fs.writeFileSync(pathToCommiteeFile, JSON.stringify({
"name": "FikIT",
"logo": "img/logos/fikit23.png",
"established": "2017",
"fallbackProfileImage": "img/logos/fikit.png",
"socialMedia": [
{
"name": "Instagram",
"url": "https://www.instagram.com/fikit_chalmers/",
"logo": "img/logos/instagram.png"
},
{
"name": "wikIT",
"url": "https://wiki.chalmers.it/index.php/FikIT",
"logo": "img/logos/it.svg"
}
],
"contact": [
{
"type": "email",
"value": "[email protected]"
}
]
}, null, 2));
}
}

function initiate_credentials_file() {
if (!fs.existsSync(pathToCredentialsFile)) {
fs.writeFileSync(pathToCredentialsFile, JSON.stringify([
{
"name": process.env.MAIN_USERNAME || "Göken",
"password": process.env.MAIN_USER_PASSWORD || "1234",
"id": process.env.MAIN_USER_ID || "1"
}
], null, 2));
}
}

initialize_files([dataFolderPath, pathToPatetosImages, pathToPostImages], [pathToPostsFile, pathToPatetosFile, pathToCredentialsFile, pathToAdminkeysFile]);
initiate_commitee_file();
initiate_credentials_file();


// LOGIN SYSTEM
Expand Down

0 comments on commit b92f1e0

Please sign in to comment.