new commit
This commit is contained in:
17
routes/api/v1/file/hash.js
Normal file
17
routes/api/v1/file/hash.js
Normal file
@@ -0,0 +1,17 @@
|
||||
const fs = require("node:fs")
|
||||
const path = require("node:path")
|
||||
const controller = require("../../../../controllers/fileHash")
|
||||
const utils = require("../../../../modules/utils")
|
||||
const express = require("express")
|
||||
const router = express()
|
||||
|
||||
router.use("", (req, res) => {
|
||||
const finalPath = path.join(__dirname, "..", "..", "..", "..", "data", "gameFiles", req.path)
|
||||
if (fs.existsSync(finalPath)) {
|
||||
res.status(200).json(controller.getFileHash(finalPath))
|
||||
} else {
|
||||
utils.handleError(req, res, 404, "Fichier introuvable.")
|
||||
}
|
||||
})
|
||||
|
||||
module.exports = router
|
||||
Reference in New Issue
Block a user