@vulcan-sql/build
Version:
VulcanSQL package for building projects
33 lines • 1.59 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.schemaParserModule = void 0;
const tslib_1 = require("tslib");
const schema_parser_1 = require("../../lib/schema-parser/index");
const inversify_1 = require("inversify");
const schemaParser_1 = require("../../options/schemaParser");
const types_1 = require("../types");
const middleware_1 = require("../../lib/schema-parser/middleware");
const schemaParserModule = (options) => new inversify_1.AsyncContainerModule((bind) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
// Options
bind(types_1.TYPES.SchemaParserInputOptions).toConstantValue(options || {});
bind(types_1.TYPES.SchemaParserOptions)
.to(schemaParser_1.SchemaParserOptions)
.inSingletonScope();
// Schema reader
bind(types_1.TYPES.SchemaReader)
.toDynamicValue((context) => {
const factory = context.container.get(types_1.TYPES.Factory_SchemaReader);
const options = context.container.get(types_1.TYPES.SchemaParserOptions);
return factory(options.reader);
})
.inSingletonScope();
bind(types_1.TYPES.Factory_SchemaReader).toAutoNamedFactory(types_1.TYPES.Extension_SchemaReader);
// Schema parser
bind(types_1.TYPES.SchemaParser).to(schema_parser_1.SchemaParser).inSingletonScope();
// Middleware
for (const middleware of middleware_1.SchemaParserMiddlewares) {
bind(types_1.TYPES.SchemaParserMiddleware).to(middleware);
}
}));
exports.schemaParserModule = schemaParserModule;
//# sourceMappingURL=schemaParser.js.map