diff options
author | terminaldweller <devi@terminaldweller.com> | 2024-05-06 17:38:20 +0000 |
---|---|---|
committer | terminaldweller <devi@terminaldweller.com> | 2024-05-06 17:38:20 +0000 |
commit | a7abf29115f8c3a279c447487687296c7610ee96 (patch) | |
tree | 6debdd2ab81c08f9dc32fefc892c06512f775954 /prettier/server.js | |
parent | gemini is finally fixed (diff) | |
download | milla-a7abf29115f8c3a279c447487687296c7610ee96.tar.gz milla-a7abf29115f8c3a279c447487687296c7610ee96.zip |
initial version of the prettier service
Diffstat (limited to '')
-rwxr-xr-x | prettier/server.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/prettier/server.js b/prettier/server.js new file mode 100755 index 0000000..d752046 --- /dev/null +++ b/prettier/server.js @@ -0,0 +1,25 @@ +#!/usr/bin/env node +"use strict"; + +const express = require("express"); +const prettier = require("prettier"); + +const app = express(); +app.use(express.json()); + +// app.use((req, res, next) => { +// res.append("Access-Control-Allow-Origin", ["*"]); +// res.append("Access-Control-Allow-Methods", "POST", "OPTIONS"); +// res.append("Access-Control-Allow-Headers", "Content-Type"); +// next(); +// }); + +app.post("/api/v1/format", async function (req, res) { + const formattedText = await prettier.format(req.body["content"], { + parser: "babel", + }); + res.set("Content-Type", "application/json"); + res.json({ formattedText: formattedText }); +}); + +app.listen(9001); |