moleculer-api
Version:
A dynamic API Gateway for MoleculerJS which updates REST endpoints and aggregated GraphQL schema, access control policy for each action calls from metadata of remote services schema without restart or deployment.
33 lines • 1.26 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ServeStaticMiddleware = void 0;
const tslib_1 = require("tslib");
const _ = tslib_1.__importStar(require("lodash"));
const serve_static_1 = tslib_1.__importDefault(require("serve-static"));
const middleware_1 = require("./middleware");
/* eg.
{
dirRootPath: "./public",
routeBasePath: "/assets",
}
above options will serve files in `{where the node process running}/public` directory on http://.../assets path
or use absolute path for dirRootPath
*/
class ServeStaticMiddleware extends middleware_1.ServerMiddleware {
constructor(props, opts) {
super(props);
this.props = props;
this.opts = _.defaultsDeep(opts || {}, {
dirRootPath: "./public",
routeBasePath: "/assets",
});
}
apply(modules) {
const _a = this.opts, { dirRootPath, routeBasePath } = _a, opts = tslib_1.__rest(_a, ["dirRootPath", "routeBasePath"]);
modules.http.use(routeBasePath, serve_static_1.default(dirRootPath, opts));
}
}
exports.ServeStaticMiddleware = ServeStaticMiddleware;
ServeStaticMiddleware.key = "serveStatic";
ServeStaticMiddleware.autoLoadOptions = false;
//# sourceMappingURL=serve-static.js.map