Skip to content

Commit 691794d

Browse files
committed
feat: add new route of scss conversion to css
1 parent 81e7a93 commit 691794d

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

package-lock.json

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
"passport-keycloak-bearer": "^2.1.0",
9090
"pug": "^3.0.2",
9191
"sanitize-filename": "^1.6.3",
92+
"sass": "^1.63.6",
9293
"subscriptions-transport-ws": "^0.9.18",
9394
"survey-knockout": "^1.9.64",
9495
"ts-node-dev": "^2.0.0",

src/routes/style/index.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { logger } from '@services/logger.service';
66
import { downloadFile } from '@utils/files';
77
import fs from 'fs';
88
import sanitize from 'sanitize-filename';
9+
import { compileString } from 'sass';
910

1011
/**
1112
* Exports css or scss custom style files
@@ -43,4 +44,17 @@ router.get('/application/:id', async (req, res) => {
4344
}
4445
});
4546

47+
/**
48+
* Get raw scss and return it to css.
49+
*/
50+
router.post('/scss-to-css', async (req, res) => {
51+
try {
52+
const scss = req.body.scss;
53+
res.status(200).send(compileString(scss).css);
54+
} catch (err) {
55+
logger.error(err.message, { stack: err.stack });
56+
res.status(500).send(req.t('common.errors.internalServerError'));
57+
}
58+
});
59+
4660
export default router;

0 commit comments

Comments
 (0)