janpaul123-valle_tmp_168173191488171673357222933830397.web.val.run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// This is a minimal formatter for JavaScript code using the Prettier library.
// The formatter will receive JavaScript code through a POST request and return the formatted code.
import { Hono } from "npm:hono";
import prettier from "npm:prettier";
const app = new Hono();
app.post("/", async (c) => {
const jsCode = await c.req.text(); // Get the JS code from the request body
const formattedCode = prettier.format(jsCode, { parser: "babel" }); // Format the JS code using Prettier
return c.text(formattedCode); // Return the formatted code as text
});
export default app.fetch;
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
July 15, 2024