23 lines
1.4 KiB
JavaScript
23 lines
1.4 KiB
JavaScript
// lib/routes.js
|
|
// routes(cfg) factory (ARCHITECTURE.md 6.3)
|
|
const { URL_PREFIX, API_BASE, CSS_ROUTE } = require("./constants");
|
|
const h = require("./apiHandlers");
|
|
|
|
function routes(cfg) {
|
|
return [
|
|
{ url: CSS_ROUTE, method: "get", callback: (req, res) => h.getThemeCss(req, res, cfg) }, // PUBLIC
|
|
{ url: `${URL_PREFIX}/editor`, method: "get", callback: h.getEditor },
|
|
{ url: `${API_BASE}/state`, method: "get", callback: h.getState_ },
|
|
{ url: `${API_BASE}/themes/:id`, method: "get", callback: h.loadTheme },
|
|
{ url: `${API_BASE}/themes`, method: "post", callback: h.createTheme },
|
|
{ url: `${API_BASE}/themes/:id/duplicate`, method: "post", callback: h.duplicateTheme },
|
|
{ url: `${API_BASE}/themes/:id/save`, method: "post", callback: h.saveTheme },
|
|
{ url: `${API_BASE}/themes/:id/rename`, method: "post", callback: h.renameTheme },
|
|
{ url: `${API_BASE}/themes/:id/delete`, method: "post", callback: h.deleteTheme },
|
|
{ url: `${API_BASE}/themes/:id/activate`, method: "post", callback: h.activateTheme },
|
|
{ url: `${API_BASE}/themes/:id/export`, method: "get", callback: h.exportTheme },
|
|
{ url: `${API_BASE}/import`, method: "post", callback: h.importTheme },
|
|
{ url: `${API_BASE}/preview-css`, method: "post", callback: h.previewCss }, // editor WYSIWYG (no save/activate)
|
|
];
|
|
}
|
|
module.exports = { routes };
|