generated from azures04/Base-REST-API
Moved metadata route and added static files (robots.txt)
This commit is contained in:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user