MCPcopy Create free account
hub / github.com/Linen-dev/linen.dev / create

Function create

apps/web/pages/api/highlight/index.ts:7–33  ·  view source on GitHub ↗
({
  input,
  language,
}: {
  input: string;
  language: string;
})

Source from the content-addressed store, hash-verified

5const LANGUAGES = highlightjs.listLanguages();
6
7export async function create({
8 input,
9 language,
10}: {
11 input: string;
12 language: string;
13}) {
14 try {
15 const output =
16 language && LANGUAGES.includes(language)
17 ? highlightjs.highlight(language, input).value
18 : highlightjs.highlightAuto(input).value;
19 return {
20 status: 200,
21 data: {
22 output,
23 },
24 };
25 } catch (exception) {
26 return {
27 status: 200,
28 data: {
29 output: input,
30 },
31 };
32 }
33}
34
35export default async function handler(
36 request: NextApiRequest,

Callers 1

handlerFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected