-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathschemaParser.ts
30 lines (26 loc) · 1.15 KB
/
schemaParser.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { ISchemaParserOptions, SchemaReader } from '@vulcan-sql/build/models';
import { SchemaParser } from '@vulcan-sql/build/schema-parser';
import { AsyncContainerModule, interfaces } from 'inversify';
import { SchemaParserOptions } from '../../options/schemaParser';
import { TYPES } from '../types';
import { SchemaParserMiddlewares } from '@vulcan-sql/build/schema-parser/middleware';
export const schemaParserModule = (options?: ISchemaParserOptions) =>
new AsyncContainerModule(async (bind) => {
// Options
bind<ISchemaParserOptions>(TYPES.SchemaParserInputOptions).toConstantValue(
options || ({} as any)
);
bind<SchemaParserOptions>(TYPES.SchemaParserOptions)
.to(SchemaParserOptions)
.inSingletonScope();
// Schema reader
bind<interfaces.AutoNamedFactory<SchemaReader>>(
TYPES.Factory_SchemaReader
).toAutoNamedFactory<SchemaReader>(TYPES.Extension_SchemaReader);
// Schema parser
bind<SchemaParser>(TYPES.SchemaParser).to(SchemaParser).inSingletonScope();
// Middleware
for (const middleware of SchemaParserMiddlewares) {
bind(TYPES.SchemaParserMiddleware).to(middleware);
}
});