Skip to content

Commit b995729

Browse files
committed
bugfix.
1 parent 079e1c4 commit b995729

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

dist/index.cjs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,4 +370,14 @@ function _start() {
370370
}));
371371
return _start.apply(this, arguments);
372372
}
373-
var _default = exports["default"] = fastifyInstance;
373+
var instanceProxy = new Proxy({}, {
374+
get: function get(target, prop) {
375+
if (!fastifyInstance) return undefined;
376+
return fastifyInstance[prop];
377+
},
378+
apply: function apply(target, thisArg, args) {
379+
if (!fastifyInstance) return undefined;
380+
return Reflect.apply(fastifyInstance, thisArg, args);
381+
}
382+
});
383+
var _default = exports["default"] = instanceProxy;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fastify-app",
3-
"version": "2.0.0",
3+
"version": "2.0.1",
44
"description": "A simple fastify app template for JSON API server with helpful routes and initial settings.",
55
"main": "src/index.mjs",
66
"module": "src/index.mjs",

src/index.mjs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,5 +242,16 @@ async function start() {
242242
});
243243
}
244244

245-
export default fastifyInstance;
245+
const instanceProxy = new Proxy({}, {
246+
get(target, prop) {
247+
if (!fastifyInstance) return undefined;
248+
return fastifyInstance[prop];
249+
},
250+
apply(target, thisArg, args) {
251+
if (!fastifyInstance) return undefined;
252+
return Reflect.apply(fastifyInstance, thisArg, args);
253+
}
254+
});
255+
256+
export default instanceProxy;
246257
export { init, start, ApiError };

0 commit comments

Comments
 (0)