generated from azures04/Base-REST-API
23 lines
624 B
JavaScript
23 lines
624 B
JavaScript
const fs = require("node:fs")
|
|
const path = require("node:path")
|
|
const { DefaultError } = require("../errors/errors")
|
|
|
|
function getServerMetadata() {
|
|
return {
|
|
name: process.env["INSTANCE_NAME"],
|
|
logo: process.env["INSTANCE_LOGO"]
|
|
}
|
|
}
|
|
|
|
function serveStaticFile(filePath) {
|
|
const finalFilePath = path.join(process.cwd(), "data", "static", filePath)
|
|
if (fs.existsSync(finalFilePath)) {
|
|
return finalFilePath
|
|
}
|
|
throw new DefaultError(404, "File not found", "File moved/deleted or don't exists", "NotFoundException")
|
|
}
|
|
|
|
module.exports = {
|
|
serveStaticFile,
|
|
getServerMetadata
|
|
} |