converted ts to js

This commit is contained in:
Andrey
2023-11-25 11:56:14 +03:00
parent 46c1a4915a
commit 12a6d49cf1
10 changed files with 1358 additions and 4 deletions
+30 -3
View File
@@ -1,9 +1,36 @@
const express = require("express");
const express = require('express')
const router = express.Router()
const fs = require("fs");
const path = require("path");
const BASE_PATH = __dirname;
const STATIC_PATH = `${BASE_PATH}/static`;
// Serve static files
router.use(express.static(path.join(__dirname, './assets/')))
// 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()
})
// Serve Static generated SVGs
router.get('/static/:name', async (req, res, next) => {
const fileName = req.params.name
const filePath = `${STATIC_PATH}/${fileName}`
const file = await fs.readFileSync(filePath)
res.setHeader('Content-Type', 'image/svg+xml')
res.send(file)
})
router.use('/api', require('./routes/api').default)
router.get('/info', (req, res) => {
res.send("entry point")
res.send('Pen-Plotter backend')
})
module.exports = router