Skip to content

Commit

Permalink
Some major bug fixes and new features
Browse files Browse the repository at this point in the history
  • Loading branch information
privt00 committed Sep 22, 2024
1 parent 23cfbc0 commit a3f3e23
Show file tree
Hide file tree
Showing 67 changed files with 2,222 additions and 1,084 deletions.
Empty file modified exec/bin/index.js
100755 → 100644
Empty file.
66 changes: 36 additions & 30 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ const chalk = require('chalk');
const expressWs = require('express-ws')(app);
const { db } = require('./handlers/db.js')
const translationMiddleware = require('./handlers/translation');
const cookieParser = require('cookie-parser')
const cookieParser = require('cookie-parser');
const rateLimit = require('express-rate-limit');
const theme = require('./storage/theme.json');


const sqlite = require("better-sqlite3");
Expand Down Expand Up @@ -85,38 +86,42 @@ app.use(
saveUninitialized: true
})
);

app.use((req, res, next) => {
res.locals.languages = getlanguages();
res.locals.ogTitle = config.ogTitle;
res.locals.ogDescription = config.ogDescription;
next();
app.use(async (req, res, next) => {
try {
const settings = await db.get('settings');

res.locals.languages = getlanguages();
res.locals.ogTitle = config.ogTitle;
res.locals.ogDescription = config.ogDescription;
res.locals.footer = settings.footer;
res.locals.theme = theme;
next();
} catch (error) {
console.error('Error fetching settings:', error);
next(error);
}
});


if (config.mode === 'production' || false) {


app.use((req, res, next) => {
res.setHeader('Cache-Control', 'no-store');
res.setHeader('Pragma', 'no-cache');
res.setHeader('Expires', '5');
next();
});


app.use('/assets', (req, res, next) => {
res.setHeader('Cache-Control', 'public, max-age=1');
next();
});
app.use((req, res, next) => {
res.setHeader('Cache-Control', 'no-store');
res.setHeader('Pragma', 'no-cache');
res.setHeader('Expires', '5');
next();
});

app.use('/assets', (req, res, next) => {
res.setHeader('Cache-Control', 'public, max-age=1');
next();
});
}

// Initialize passport
app.use(passport.initialize());
app.use(passport.session());


// init
// Init
init();

// Log the ASCII
Expand All @@ -129,12 +134,10 @@ console.log(chalk.gray(ascii) + chalk.white(`version v${config.version}\n`));
*/
const routesDir = path.join(__dirname, 'routes');




function getlanguages() {
return fs.readdirSync(__dirname + '/lang').map(file => file.split('.')[0])
}

function getlangname() {
return fs.readdirSync(path.join(__dirname, '/lang')).map(file => {
const langFilePath = path.join(__dirname, '/lang', file);
Expand All @@ -143,11 +146,10 @@ function getlangname() {
});
}


app.get('/setLanguage', async (req, res) => {
const lang = req.query.lang;
if (lang && (await getlanguages()).includes(lang)) {
res.cookie('lang', lang, { maxAge: 90000000, httpOnly: true });
res.cookie('lang', lang, { maxAge: 90000000, httpOnly: true, sameSite: 'strict' });
req.user.lang = lang; // Update user language preference
res.json({ success: true });
} else {
Expand All @@ -166,7 +168,7 @@ function loadRoutes(directory) {
} else if (stat.isFile() && path.extname(file) === '.js') {
// Only require .js files
const route = require(fullPath);
//log.init('loaded route: ' + fullPath);
// log.init('loaded route: ' + fullPath);
expressWs.applyTo(route);
app.use("/", route);
}
Expand All @@ -193,5 +195,9 @@ app.use(express.static('public'));
app.listen(config.port, () => log.info(`skyport is listening on port ${config.port}`));

app.get('*', async function(req, res){
res.render('errors/404', { req, name: await db.get('name') || 'Skyport', logo: await db.get('logo') || false })
res.render('errors/404', {
req,
name: await db.get('name') || 'Skyport',
logo: await db.get('logo') || false
})
});
3 changes: 2 additions & 1 deletion lang/de/lang.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"de": "Deutsch",
"en": "Englisch",
"nl": "Niederländisch",
"pl": "Polieren",
"pl": "Polnisch",
"sp": "Spanisch",
"manageInstance": "Instanz verwalten",
"instanceViewDetailText": "Ansicht, Aktualisierung und Verwaltung einer Instanz im Skyport-Panel.",
"fivezerozeroInstanceError": "500 SERVERFEHLER",
Expand Down
3 changes: 3 additions & 0 deletions lang/en/lang.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"de": "German",
"nl": "Dutch",
"pl": "Polish",
"sp": "Spanish",
"in": "Hindi",
"it": "Italian",
"manageInstance": "Manage Instance",
"instanceViewDetailText": "View, update or manage an instance on the Skyport panel.",
"fivezerozeroInstanceError": "500 SERVER ERROR",
Expand Down
180 changes: 180 additions & 0 deletions lang/in/lang.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
{
"de": "जर्मन",
"en": "अंग्रेज़ी",
"nl": "डच",
"pl": "पोलिश",
"sp": "स्पेनिश",
"manageInstance": "इंस्टेंस प्रबंधित करें",
"instanceViewDetailText": "स्काईपोर्ट पैनल में एक इंस्टेंस देखें, अपडेट करें और प्रबंधित करें।",
"fivezerozeroInstanceError": "500 सर्वर त्रुटि",
"somethingWentWrongThere": "उफ़... कुछ गलत हो गया।",
"returnedTextError": "यह त्रुटि वापस आई:",
"informationAvailableError": "कोई त्रुटि जानकारी उपलब्ध नहीं है",
"updateAccount": "खाता अपडेट करें",
"username": "उपयोगकर्ता नाम",
"email": "ईमेल",
"currentPassword": "वर्तमान पासवर्ड",
"newPassword": "नया पासवर्ड",
"updateUsername": "उपयोगकर्ता नाम अपडेट करें",
"update_password": "पासवर्ड अपडेट करें",
"enabled2FA": "2FA सक्षम करें",
"disable2FA": "2FA अक्षम करें",
"enable2FATitle": "दो-कारक प्रमाणीकरण सक्षम करें",
"enable2FADescription": "अपने खाते को एक अतिरिक्त सुरक्षा परत के साथ सुरक्षित करें।",
"checking": "जांच हो रही है...",
"loading": "लोड हो रहा है...",
"search": "खोजें...",
"correctPassword": "✅ सही!",
"incorrectPassword": "❌ गलत पासवर्ड",
"usernameTaken": "❌ पहले से ही लिया गया",
"usernameIsNotTaken": "✅ उपलब्ध",
"validadingpasswordError": "पासवर्ड सत्यापन में त्रुटि",
"updatingUsernameError": "उपयोगकर्ता नाम अपडेट करते समय त्रुटि। कृपया बाद में पुनः प्रयास करें।",
"usernameUpdatedSuccess": "उपयोगकर्ता नाम सफलतापूर्वक अपडेट किया गया!",
"currentPasswordHide": "********",
"newPasswordHide": "********",
"authCode": "प्रमाणीकरण कोड",
"verifyCode": "कोड सत्यापित करें",
"instances": "इंस्टेंस",
"viewInstances": "उन इंस्टेंस को देखें जिन तक आपकी पहुंच है।",
"manageInstanceText": "स्काईपोर्ट पैनल में एक इंस्टेंस देखें, अपडेट करें और प्रबंधित करें।",
"createNewInstance": "नया इंस्टेंस बनाएं",
"instancesText": "स्काईपोर्ट पैनल पर सभी इंस्टेंस की एक सूची।",
"noInstances": "कोई इंस्टेंस नहीं",
"noInstancesText": "आपके खाते में कोई इंस्टेंस नहीं है।",
"seeAllInstances": "सभी इंस्टेंस देखें",
"showingYourInstances": "आपके इंस्टेंस दिखा रहा है",
"settings": "सेटिंग्स",
"changeSettings": "स्काईपोर्ट पैनल में सामान्य सेटिंग्स बदलें।",
"settingsSaved": "सहेजा गया!",
"settingsSaveFailed": "सेव असफल।",
"general": "सामान्य",
"panelName": "पैनल का नाम:",
"save": "सहेजें",
"saveNewLogo": "नया लोगो सहेजें",
"panelLogo": "पैनल लोगो:",
"uploadLogo": "लोगो अपलोड करें:",
"removeLogo": "लोगो हटाएं",
"registerPage": "पंजीकरण पृष्ठ:",
"enabled": "सक्रिय",
"enable": "सक्रिय करें",
"disabled": "असक्रिय",
"disable": "असक्रिय करें",
"forceVerifyEmail": "ईमेल सत्यापन अनिवार्य करें:",
"smtp": "SMTP",
"smtpServer": "SMTP सर्वर",
"smtpPort": "SMTP पोर्ट",
"smtpUsername": "SMTP उपयोगकर्ता नाम",
"smtpPassword": "SMTP पासवर्ड",
"saveSmtpSettings": "SMTP सेटिंग्स सहेजें",
"mailFromName": "प्रेषक का नाम",
"mailFromAddress": "प्रेषक का पता",
"recipientEmail": "प्राप्तकर्ता का ईमेल",
"sendTestEmail": "परीक्षण ईमेल भेजें",
"testEmailSuccess": "परीक्षण ईमेल सफल रहा।",
"testEmailFailed": "परीक्षण ईमेल असफल रहा।",
"usersDescription": "स्काईपोर्ट पैनल में सभी उपयोगकर्ताओं की सूची।",
"createUserButton": "नया उपयोगकर्ता बनाएं",
"information": "जानकारी",
"role": "भूमिका",
"verificationStatus": "सत्यापन स्थिति",
"action": "क्रिया",
"actions": "क्रियाएँ",
"regularUserRole": "साधारण उपयोगकर्ता",
"verifiedStatus": "सत्यापित",
"unverifiedStatus": "असत्यापित",
"error": "त्रुटि",
"edit": "संपादित करें",
"create": "बनाएं",
"remove": "हटाएं",
"usernamePlaceholder": "JohnDoe",
"emailPlaceholder": "आपका@email.tld",
"passwordLabel": "पासवर्ड",
"passwordPlaceholder": "******",
"admin": "प्रशासक",
"true": "सत्य",
"false": "असत्य",
"account": "खाता",
"overview": "अवलोकन",
"overviewText": "आपके पैनल का एक सरल अवलोकन।",
"user": "उपयोगकर्ता",
"users": "उपयोगकर्ता",
"node": "नोड",
"nodes": "नोड्स",
"nodesText": "स्काईपोर्ट पैनल में सभी नोड्स की सूची।",
"plugins": "प्लगइन्स",
"signOut": "साइन आउट",
"accountJSON": "खाता - JSON",
"nodesJSON": "नोड्स - JSON",
"image": "चित्र",
"images": "चित्र",
"imagesText": "स्काईपोर्ट पैनल में सभी चित्रों की सूची।",
"imageDelete": "चित्र हटाएं",
"imageReplace": "चित्र बदलें",
"sysInfo": "सिस्टम जानकारी",
"sysInfoText": "आप स्काईपोर्ट पैनल का संस्करण उपयोग कर रहे हैं",
"newReleaseSkyport1": "एक नया संस्करण, स्काईपोर्ट",
"newReleaseSkyport2": "उपलब्ध है। कृपया क्लिक करें",
"newReleaseSkyport3": "इसे डाउनलोड करने के लिए!",
"here": "यहां",
"runningLatestVersion": "आप नवीनतम संस्करण का उपयोग कर रहे हैं!",
"name": "नाम",
"dockerID": "डॉकर आईडी",
"volumeANDMount": "वॉल्यूम / माउंट",
"unsuspend": "अनलॉक करें",
"suspend": "लॉक करें",
"memory": "मेमोरी",
"cpuThreads": "CPU थ्रेड्स",
"ports": "पोर्ट्स",
"primaryPort": "मुख्य पोर्ट",
"connection": "कनेक्शन",
"createNewNode": "नया नोड बनाएं",
"configure": "कॉन्फ़िगर करें",
"ram": "RAM",
"disk": "डिस्क",
"cpu": "CPU",
"addressIP": "IP पता",
"deamonPort": "डेमन पोर्ट",
"tags": "टैग्स",
"author": "लेखक",
"dockerImage": "डॉकर इमेज",
"importImage": "इमेज आयात करें",
"back": "वापस",
"APIKeys": "API कुंजियाँ",
"APIKeysText": "स्काईपोर्ट पैनल पर सभी API कुंजियों की सूची।",
"id": "आईडी",
"key": "कुंजी",
"createdAt": "बनाया गया",
"createNewAPIKey": "नई API कुंजी बनाएं",
"clickToConfirmCreation": "सृजन की पुष्टि करने के लिए क्लिक करें",
"auditLogs": "ऑडिट लॉग्स",
"auditLogsText": "प्रशासकों द्वारा की गई कार्रवाइयों का इतिहास।",
"auditLogsNotAvailable": "कोई ऑडिट लॉग उपलब्ध नहीं है।",
"timestamp": "समय मोहर",
"you": "आप",
"address": "पता",
"identifier": "पहचानकर्ता",
"connectionFailure": "कनेक्शन विफलता",
"connectionFailureText": "यह इंस्टेंस चलाने वाला नोड समस्या कर रहा है। कृपया प्रतीक्षा करें...",
"SendACommand": "एक कमांड भेजें...",
"status": "स्थिति",
"ramUsage": "RAM उपयोग",
"cpuUsage": "CPU उपयोग",
"diskUsage": "डिस्क उपयोग",
"start": "शुरू करें",
"stop": "रोकें",
"restart": "पुनः प्रारंभ करें",
"created": "बनाया गया!",
"apiKeySuccessCreated": "API कुंजी सफलतापूर्वक बनाई गई।",
"apiKeyErrorDelete": "कुंजी को हटाने में त्रुटि",
"editUser": "उपयोगकर्ता संपादित करें",
"editUserDetails": "चयनित उपयोगकर्ता का विवरण बदलें।",
"userCreatedSuccess": "उपयोगकर्ता सफलतापूर्वक बनाया गया",
"userDeletingError": "उपयोगकर्ता को हटाते समय त्रुटि",
"userDeletingConfirmation": "क्या आप वाकई इस उपयोगकर्ता को हटाना चाहते हैं?",
"userCannotDelete": "वर्तमान उपयोगकर्ता को हटाया नहीं जा सकता।",
"databaseCannotDelete": "डेटाबेस में एकमात्र उपयोगकर्ता को हटाया नहीं जा सकता।",
"userCreateError": "उपयोगकर्ता बनाते समय त्रुटि",
"saveChanges": "परिवर्तन सहेजें",
"jsonSelectFile": "कृपया एक JSON फ़ाइल चुनें।"
}
Loading

0 comments on commit a3f3e23

Please sign in to comment.