replace pen-plotter to epja folder

This commit is contained in:
Andrey 2023-11-25 13:11:35 +03:00
parent 6a4c6c1d86
commit 1021d16469
11 changed files with 4 additions and 93 deletions

View File

@ -42,7 +42,6 @@ app.use(require('./root'))
*/ */
app.use('/lobsters', require('./routers/lobsters')) app.use('/lobsters', require('./routers/lobsters'))
app.use('/example', require('./routers/example')) app.use('/example', require('./routers/example'))
app.use('/pen-plotter', require('./routers/pen-plotter'))
// app.use('/coder', require('./routers/coder')) // app.use('/coder', require('./routers/coder'))
//app.use('/stc-21-03', require('./routers/stc-21-03')) //app.use('/stc-21-03', require('./routers/stc-21-03'))
//app.use('/stc-21', require('./routers/stc')) //app.use('/stc-21', require('./routers/stc'))

View File

@ -3,5 +3,6 @@ const router = express.Router()
router.use('/example', require('./example/index')) router.use('/example', require('./example/index'))
router.use('/pen-plotter', require('./pen-plotter/index'))
module.exports = router module.exports = router

View File

@ -0,0 +1,3 @@
dist/
static/
profiles/

View File

@ -26,7 +26,6 @@ router.get('/static/:name', async (req, res, next) => {
res.setHeader('Content-Type', 'image/svg+xml') res.setHeader('Content-Type', 'image/svg+xml')
res.send(file) res.send(file)
}) })
router.use('/api', require('./routes/api').default) router.use('/api', require('./routes/api').default)
router.get('/info', (req, res) => { router.get('/info', (req, res) => {

View File

@ -1,91 +0,0 @@
"use strict";
var __awaiter =
(this && this.__awaiter) ||
function (thisArg, _arguments, P, generator) {
function adopt(value) {
return value instanceof P
? value
: new P(function (resolve) {
resolve(value);
});
}
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
}
function rejected(value) {
try {
step(generator["throw"](value));
} catch (e) {
reject(e);
}
}
function step(result) {
result.done
? resolve(result.value)
: adopt(result.value).then(fulfilled, rejected);
}
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault =
(this && this.__importDefault) ||
function (mod) {
return mod && mod.__esModule ? mod : { default: mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const paths_1 = require("./paths");
const express_1 = __importDefault(require("express"));
const dotenv_1 = __importDefault(require("dotenv"));
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
// Initialize express
const app = (0, express_1.default)();
// Load environment variables
dotenv_1.default.config();
// Parse JSON bodies
app.use(express_1.default.json());
// CORS
app.use((req, res, next) => {
res.setHeader("Access-Control-Allow-Origin", "*");
res.setHeader("Access-Control-Allow-Methods", "GET, POST, DELETE");
res.setHeader("Access-Control-Allow-Headers", "Content-Type");
next();
});
// Add the required directories
app.use((req, res, next) => {
const directories = ["/static", "/profiles"];
directories.forEach((dir) => {
if (!fs_1.default.existsSync(paths_1.BASE_PATH + dir)) {
fs_1.default.mkdirSync(paths_1.BASE_PATH + dir);
}
});
next();
});
// TODO: Remove this in production
app.use((req, res, next) => {
console.log(`${req.method} ${req.url}`);
next();
});
// Serve Static generated SVGs
app.get("/static/:name", (req, res, next) =>
__awaiter(void 0, void 0, void 0, function* () {
const fileName = req.params.name;
const filePath = `${paths_1.STATIC_PATH}/${fileName}`;
const file = yield fs_1.default.readFileSync(filePath);
res.setHeader("Content-Type", "image/svg+xml");
res.send(file);
})
);
app.use("/api", require("./routes/api").default);
// Start server
const port = process.env.PORT || 5000;
app.listen(port, () => {
console.log(`Server started on port ${port}`);
});