From 1021d16469bfc8212e9a38e661600d482f9f147c Mon Sep 17 00:00:00 2001 From: Andrey Date: Sat, 25 Nov 2023 13:11:35 +0300 Subject: [PATCH] replace pen-plotter to epja folder --- server/index.js | 1 - server/routers/epja-2023-2/index.js | 1 + .../epja-2023-2/pen-plotter/.gitignore | 3 + .../{ => epja-2023-2}/pen-plotter/index.js | 1 - .../{ => epja-2023-2}/pen-plotter/paths.js | 0 .../pen-plotter/routes/api.js | 0 .../pen-plotter/routes/sub-routes/svg.js | 0 .../pen-plotter/routes/sub-routes/users.js | 0 .../pen-plotter/utilities/svg.js | 0 .../pen-plotter/utilities/user.js | 0 server/routers/pen-plotter/app.js | 91 ------------------- 11 files changed, 4 insertions(+), 93 deletions(-) create mode 100644 server/routers/epja-2023-2/pen-plotter/.gitignore rename server/routers/{ => epja-2023-2}/pen-plotter/index.js (99%) rename server/routers/{ => epja-2023-2}/pen-plotter/paths.js (100%) rename server/routers/{ => epja-2023-2}/pen-plotter/routes/api.js (100%) rename server/routers/{ => epja-2023-2}/pen-plotter/routes/sub-routes/svg.js (100%) rename server/routers/{ => epja-2023-2}/pen-plotter/routes/sub-routes/users.js (100%) rename server/routers/{ => epja-2023-2}/pen-plotter/utilities/svg.js (100%) rename server/routers/{ => epja-2023-2}/pen-plotter/utilities/user.js (100%) delete mode 100644 server/routers/pen-plotter/app.js diff --git a/server/index.js b/server/index.js index 98fb3e7..1b427a7 100644 --- a/server/index.js +++ b/server/index.js @@ -42,7 +42,6 @@ app.use(require('./root')) */ app.use('/lobsters', require('./routers/lobsters')) app.use('/example', require('./routers/example')) -app.use('/pen-plotter', require('./routers/pen-plotter')) // app.use('/coder', require('./routers/coder')) //app.use('/stc-21-03', require('./routers/stc-21-03')) //app.use('/stc-21', require('./routers/stc')) diff --git a/server/routers/epja-2023-2/index.js b/server/routers/epja-2023-2/index.js index 34c59b3..c46fe4a 100644 --- a/server/routers/epja-2023-2/index.js +++ b/server/routers/epja-2023-2/index.js @@ -3,5 +3,6 @@ const router = express.Router() router.use('/example', require('./example/index')) +router.use('/pen-plotter', require('./pen-plotter/index')) module.exports = router diff --git a/server/routers/epja-2023-2/pen-plotter/.gitignore b/server/routers/epja-2023-2/pen-plotter/.gitignore new file mode 100644 index 0000000..6405610 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/.gitignore @@ -0,0 +1,3 @@ +dist/ +static/ +profiles/ diff --git a/server/routers/pen-plotter/index.js b/server/routers/epja-2023-2/pen-plotter/index.js similarity index 99% rename from server/routers/pen-plotter/index.js rename to server/routers/epja-2023-2/pen-plotter/index.js index f2bce74..4528f8d 100644 --- a/server/routers/pen-plotter/index.js +++ b/server/routers/epja-2023-2/pen-plotter/index.js @@ -26,7 +26,6 @@ router.get('/static/:name', async (req, res, next) => { res.setHeader('Content-Type', 'image/svg+xml') res.send(file) }) - router.use('/api', require('./routes/api').default) router.get('/info', (req, res) => { diff --git a/server/routers/pen-plotter/paths.js b/server/routers/epja-2023-2/pen-plotter/paths.js similarity index 100% rename from server/routers/pen-plotter/paths.js rename to server/routers/epja-2023-2/pen-plotter/paths.js diff --git a/server/routers/pen-plotter/routes/api.js b/server/routers/epja-2023-2/pen-plotter/routes/api.js similarity index 100% rename from server/routers/pen-plotter/routes/api.js rename to server/routers/epja-2023-2/pen-plotter/routes/api.js diff --git a/server/routers/pen-plotter/routes/sub-routes/svg.js b/server/routers/epja-2023-2/pen-plotter/routes/sub-routes/svg.js similarity index 100% rename from server/routers/pen-plotter/routes/sub-routes/svg.js rename to server/routers/epja-2023-2/pen-plotter/routes/sub-routes/svg.js diff --git a/server/routers/pen-plotter/routes/sub-routes/users.js b/server/routers/epja-2023-2/pen-plotter/routes/sub-routes/users.js similarity index 100% rename from server/routers/pen-plotter/routes/sub-routes/users.js rename to server/routers/epja-2023-2/pen-plotter/routes/sub-routes/users.js diff --git a/server/routers/pen-plotter/utilities/svg.js b/server/routers/epja-2023-2/pen-plotter/utilities/svg.js similarity index 100% rename from server/routers/pen-plotter/utilities/svg.js rename to server/routers/epja-2023-2/pen-plotter/utilities/svg.js diff --git a/server/routers/pen-plotter/utilities/user.js b/server/routers/epja-2023-2/pen-plotter/utilities/user.js similarity index 100% rename from server/routers/pen-plotter/utilities/user.js rename to server/routers/epja-2023-2/pen-plotter/utilities/user.js diff --git a/server/routers/pen-plotter/app.js b/server/routers/pen-plotter/app.js deleted file mode 100644 index ce09e2c..0000000 --- a/server/routers/pen-plotter/app.js +++ /dev/null @@ -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}`); -});