mirror of
https://github.com/hoppscotch/hoppscotch.git
synced 2026-09-24 23:31:17 +08:00
Added codegen registrar
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { JSXHRCodegen } from "./generators/js-xhr"
|
||||
import { JSFetchCodegen } from "./generators/js-fetch"
|
||||
import { CurlCodegen } from "./generators/curl"
|
||||
|
||||
/* Register code generators here.
|
||||
* A code generator is defined as an object with the following structure.
|
||||
*
|
||||
* id: string
|
||||
* name: string
|
||||
* generator: (ctx) => string
|
||||
*
|
||||
*/
|
||||
export const codegens = [JSXHRCodegen, JSFetchCodegen, CurlCodegen]
|
||||
|
||||
export function generateCodeWithGenerator(codegenID, context) {
|
||||
if (codegenID) {
|
||||
const gen = codegens.find((e) => e.id === codegenID)
|
||||
return gen ? gen.generator(context) : ""
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
Reference in New Issue
Block a user