@lark-apaas/devtool-kits 1.2.21 → 1.2.22-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +20 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +20 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1773,11 +1773,30 @@ __name(createOpenapiHandler, "createOpenapiHandler");
|
|
|
1773
1773
|
var import_promises3 = __toESM(require("fs/promises"), 1);
|
|
1774
1774
|
var import_node_crypto2 = __toESM(require("crypto"), 1);
|
|
1775
1775
|
var MAX_REF_DEPTH = 5;
|
|
1776
|
+
var EMPTY_OPENAPI_SPEC = {
|
|
1777
|
+
openapi: "3.0.0",
|
|
1778
|
+
info: {
|
|
1779
|
+
title: "\u5F00\u653E API",
|
|
1780
|
+
version: "0.0.0"
|
|
1781
|
+
},
|
|
1782
|
+
paths: {},
|
|
1783
|
+
components: {
|
|
1784
|
+
schemas: {}
|
|
1785
|
+
}
|
|
1786
|
+
};
|
|
1776
1787
|
function createOpenapiSpecHandler(openapiSpecFilePath) {
|
|
1777
1788
|
let cache = null;
|
|
1778
1789
|
return async (_req, res, context) => {
|
|
1779
1790
|
try {
|
|
1780
|
-
|
|
1791
|
+
let fileBuffer;
|
|
1792
|
+
try {
|
|
1793
|
+
fileBuffer = await import_promises3.default.readFile(openapiSpecFilePath, "utf-8");
|
|
1794
|
+
} catch (err) {
|
|
1795
|
+
if (err?.code === "ENOENT") {
|
|
1796
|
+
return res.json(EMPTY_OPENAPI_SPEC);
|
|
1797
|
+
}
|
|
1798
|
+
throw err;
|
|
1799
|
+
}
|
|
1781
1800
|
const currentHash = import_node_crypto2.default.createHash("md5").update(fileBuffer).digest("hex");
|
|
1782
1801
|
if (cache && cache.fileHash === currentHash) {
|
|
1783
1802
|
return res.json(cache.data);
|