Violets-Purgatory/index.js

63 lines
1.4 KiB
JavaScript
Raw Normal View History

2023-10-20 21:53:49 -05:00
const express = require('express'),
2023-11-16 19:29:22 -06:00
path = require('path'),
fs = require('fs'),
2024-02-08 12:30:38 -06:00
pageUpdater = require('./pageUpdater.js')
2023-10-20 21:53:49 -05:00
var app = express()
const PORT = process.env.PORT || 8080
2023-11-16 15:16:22 -06:00
const staticpath = path.join(__dirname, 'static')
var lanyardData = undefined
2024-01-25 23:29:28 -06:00
var config = JSON.parse(fs.readFileSync(path.join(__dirname, 'config.json')))
var thumborInstances = config.thumborInstances
var thumbCount = 0
function getThumbor() {
thumbCount += 1
return thumborInstances[thumbCount % thumborInstances.length] + "unsafe"
}
2023-10-20 21:53:49 -05:00
2023-11-16 15:16:22 -06:00
app.listen(PORT, () => {
console.log("Violet's Purgatory is now listening on port: " + PORT)
2023-11-03 13:01:13 -05:00
})
2024-01-27 14:19:49 -06:00
if (!fs.existsSync(path.join(staticpath, 'cached'))) {
fs.mkdirSync(path.join(staticpath, 'cached'))
}
2024-01-25 23:29:28 -06:00
var randomQuotes = config.quotes
2024-02-04 15:03:54 -06:00
var commitCount = "300+"
2024-01-25 23:03:05 -06:00
function timeFormatter(seconds) {
seconds = Math.ceil(seconds)
2024-01-25 23:08:44 -06:00
var minutes = Math.floor(seconds / 60)
2024-01-25 23:03:05 -06:00
2024-01-25 23:11:53 -06:00
if (seconds % 60 < 10) {
2024-01-25 23:11:19 -06:00
return `${minutes}:0${seconds % 60}`
2024-01-25 23:11:53 -06:00
} else {
return `${minutes}:${seconds % 60}`
2024-01-25 23:11:19 -06:00
}
2024-01-27 14:19:49 -06:00
2024-01-25 23:03:05 -06:00
}
2024-01-25 23:07:26 -06:00
function gameTimeFormatter(seconds) {
seconds = Math.ceil(seconds)
var minutes = Math.ceil(seconds / 60)
2024-01-25 23:08:44 -06:00
var hours = Math.floor(minutes / 60)
2024-01-26 11:20:50 -06:00
if (seconds <= 60) {
2024-02-02 09:06:39 -06:00
return 'about ' + seconds + ' seconds'
2024-01-25 23:07:26 -06:00
} else if (minutes < 60) {
return `${minutes} Minutes`
}
2024-01-27 14:19:49 -06:00
2024-01-25 23:11:19 -06:00
return `${hours} hours and ${minutes % 60} minutes`
2024-01-27 14:19:49 -06:00
2024-01-25 23:07:26 -06:00
}
2024-02-12 08:46:49 -06:00
app.use(pageUpdater.middleWare)