feat: add script hot-reload and compile-on-save
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
import { Router } from "express";
|
||||
import { buildModule } from "../services/build.service.js";
|
||||
import {
|
||||
buildModule,
|
||||
hotReloadScripts,
|
||||
compileSingle,
|
||||
} from "../services/build.service.js";
|
||||
|
||||
const router = Router();
|
||||
|
||||
@@ -23,4 +27,24 @@ router.post("/module/pack", async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
router.post("/deploy", async (_req, res) => {
|
||||
try {
|
||||
const result = await hotReloadScripts();
|
||||
res.json(result);
|
||||
} catch (err: any) {
|
||||
res.status(500).json({ error: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
router.post("/compile-single", async (req, res) => {
|
||||
const { filePath } = req.body;
|
||||
if (!filePath) return res.status(400).json({ error: "filePath required" });
|
||||
try {
|
||||
const result = await compileSingle(filePath);
|
||||
res.json(result);
|
||||
} catch (err: any) {
|
||||
res.status(500).json({ error: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
export default router;
|
||||
|
||||
Reference in New Issue
Block a user