-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* updated to have openapi support with Zudoku link * Added OpenAPI support (dirty) (#52) * added tests for the mockserver * updated with cleaner types * fixing tests * updated to use a plain OAS json doc * fixed routes (#54) * Zup josh 11 3 gold haddock (#55) * fixed routes * fixes (that I lost before) * Zup josh 11 3 amethyst wolverine (#56) * fixed routes * fixes (that I lost before) * added accept to caching headers * removed silly route * removed docs links for non-oas bins * fixed build error * Added yaml bundl * fixed domain using env * added better layout and file input * fixed error * added yaml support * fixed error --------- Co-authored-by: Josh Twist <[email protected]> Co-authored-by: Josh Twist <[email protected]>
- Loading branch information
1 parent
99b1def
commit 1875598
Showing
28 changed files
with
15,671 additions
and
2,981 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import esbuild from "esbuild"; | ||
import path from "path"; | ||
|
||
const toBundle = ["yaml"]; | ||
|
||
for (const dep of toBundle) { | ||
const entry = import.meta.resolve(dep); | ||
const outputPath = new URL( | ||
path.resolve("./modules/third-party", dep), | ||
import.meta.url, | ||
).pathname; | ||
const url = new URL(entry); | ||
await esbuild.build({ | ||
entryPoints: [url.pathname], | ||
bundle: true, | ||
platform: "browser", | ||
target: "es2022", | ||
legalComments: "linked", | ||
keepNames: true, | ||
treeShaking: true, | ||
minifyIdentifiers: false, | ||
minifySyntax: false, | ||
minifyWhitespace: false, | ||
conditions: ["workerd", "worker", "browser"], | ||
format: "esm", | ||
outfile: path.join(outputPath, "index.js"), | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { ZuploContext, ZuploRequest } from "@zuplo/runtime"; | ||
import { getInvokeBinUrl, isOasBin } from "./utils"; | ||
|
||
// Module-level function to add invokeBinUrl to the OpenAPI document | ||
function addInvokeBinUrlToOpenApiDoc(openApiDoc, invokeBinUrl) { | ||
// Ensure the 'servers' section exists | ||
if (!openApiDoc.servers) { | ||
openApiDoc.servers = []; | ||
} | ||
// Add the invokeBinUrl as the first server | ||
openApiDoc.servers.unshift({ url: invokeBinUrl }); | ||
return openApiDoc; | ||
} | ||
|
||
export default async function policy( | ||
response: Response, | ||
request: ZuploRequest, | ||
context: ZuploContext, | ||
options: never, | ||
policyName: string | ||
) { | ||
const binId = request.params.binId; | ||
const url = new URL(request.url); | ||
const invokeBinUrl = getInvokeBinUrl(url, binId); | ||
|
||
if (isOasBin(binId)) { | ||
const openApiDoc = await response.json(); | ||
|
||
// Add the invokeBinUrl as the first server to the openApiDoc | ||
const newOpenApiDoc = addInvokeBinUrlToOpenApiDoc(openApiDoc, invokeBinUrl); | ||
return new Response(JSON.stringify(newOpenApiDoc, null, 2), { | ||
headers: { "Content-Type": "application/json" }, | ||
}); | ||
} | ||
|
||
return response; | ||
} |
Oops, something went wrong.