Moved metadata route and added static files (robots.txt)

This commit is contained in:
2026-02-11 00:51:24 +01:00
parent a40a6d6ad8
commit 1ddcf1eaf2
3 changed files with 26 additions and 3 deletions

View File

@@ -1,3 +1,7 @@
const fs = require("node:fs")
const path = require("node:path")
const { DefaultError } = require("../errors/errors")
function getServerMetadata() {
return {
name: process.env["INSTANCE_NAME"],
@@ -5,6 +9,15 @@ function getServerMetadata() {
}
}
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
}