move old to legacy folder
This commit is contained in:
28
.bzr/legacy/epja-2023-2/pen-plotter/index.js
Normal file
28
.bzr/legacy/epja-2023-2/pen-plotter/index.js
Normal file
@@ -0,0 +1,28 @@
|
||||
const express = require('express')
|
||||
const router = express.Router()
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const { BASE_PATH } = require("./paths");
|
||||
|
||||
router.use("/profiles", express.static(path.join(BASE_PATH, "/profiles")));
|
||||
router.use("/static", express.static(path.join(BASE_PATH, "/static")));
|
||||
|
||||
router.use('/api', require('./routes/api').default)
|
||||
|
||||
// Add the required directories
|
||||
router.use((req, res, next) => {
|
||||
const directories = ["/static", "/profiles"];
|
||||
directories.forEach((dir) => {
|
||||
if (!fs.existsSync(BASE_PATH + dir)) {
|
||||
fs.mkdirSync(BASE_PATH + dir);
|
||||
}
|
||||
});
|
||||
next();
|
||||
});
|
||||
|
||||
|
||||
router.get('/info', (req, res) => {
|
||||
res.send('Pen-Plotter backend')
|
||||
})
|
||||
|
||||
module.exports = router
|
||||
Reference in New Issue
Block a user