当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Kernel.get方法代码示例

本文整理汇总了TypeScript中inversify.Kernel.get方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Kernel.get方法的具体用法?TypeScript Kernel.get怎么用?TypeScript Kernel.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在inversify.Kernel的用法示例。


在下文中一共展示了Kernel.get方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: callback

server.setConfig((app) => {

    app.use(bodyParser.urlencoded({ extended: true }));
    app.use(bodyParser.json());
    app.use(morgan('combined'));
    app.use(cors({
        origin: (origin, callback) => {
            try {
                let ok: boolean = config.originsWhitelist.indexOf(origin) !== -1
                callback(null, ok);
            } catch (e) {
                callback(e, null);
            }

        }
    }));
    app.use(jwt({ secret: config.appSecret })
        .unless({
            path: ['/api/account/login', '/setup', '/',
                {
                    url: '/api/donors',
                    methods: ['GET', 'POST']
                }]
        }));

   let feed: DonorsFeed = kernel.get<DonorsFeed>(TYPES.DonorsFeed);
   feed.start(httpServer);
});
开发者ID:kibiluzbad,项目名称:kamrusepa,代码行数:28,代码来源:server.ts

示例2: expressMvc

export function expressMvc(...controllers: any[]): ExpressMvc {
    debug("Starting ExpressMVC");
    // Handle registering Controllers
    controllers.forEach(controller => {
        debug(`Binding controller (${controller.name})`);
        kernel.bind<mvcController>(controller).to(controller);
        debug(`Bound controller (${controller.name})`);
    });
    debug('Finished binding controllers...');
    return kernel.get<ExpressMvc>(ExpressMvc);
}
开发者ID:DemgelOpenSource,项目名称:demgel-mvc,代码行数:11,代码来源:setup.ts

示例3: testZone

        testZone(async () => {
            const kernel = new inversify.Kernel();
            kernel.bind(TestService).to(TestService);
            kernel.applyMiddleware(
                interceptor.methodInterceptorMiddleware(kernel, {
                    targetClass: /TestService/
                }, TestInterceptor)
            );

            const testService = kernel.get(TestService);
            interceptorCall = false;
            await testService.invoke();
            expect(interceptorCall).toBeTruthy();

        }));
开发者ID:takeshi,项目名称:inversity-async-method-interceptor,代码行数:15,代码来源:async-method-interceptor.spec.ts

示例4: getUserName

 @Get('/', 
     kernel.get<express.RequestHandler>('CustomMiddleware'),
     kernel.get<express.RequestHandler>('Morgan'))
 getUserName(req: any, res: any) {
     res.send(req.user.username);
 }
开发者ID:codyjs,项目名称:inversify-express-example,代码行数:6,代码来源:controller.ts

示例5:

export function getInstance<T>(name:string): T {
    return kernel.get<T>(name);
}
开发者ID:nshahm,项目名称:microservice-nodejs-layers,代码行数:3,代码来源:inversify.config.ts

示例6: getRouter

export function getRouter(): RouteBuilder {
    return kernel.get<RouteBuilder>(RouteBuilder);
}
开发者ID:DemgelOpenSource,项目名称:demgel-mvc,代码行数:3,代码来源:setup.ts

示例7: Kernel

// config inversify (dependency injection)
var kernel = new Kernel();
kernel.bind<Logger>(TYPES.Logger).to(LoggerBasic).inSingletonScope();
kernel.bind<ParkingService>(TYPES.ParkingService).to(ParkingServiceBasic);
kernel.bind<UserService>(TYPES.UserService).to(UserServiceBasic);
kernel.bind<TestDataService>(TYPES.TestDataService).to(TestDataServiceBasic).inSingletonScope();
kernel.bind<DistanceService>(TYPES.DistanceService).to(DistanceServiceBasic);
kernel.bind<TrackingService>(TYPES.TrackingService).to(TrackingServiceBasic);
kernel.bind<ParkingRepository>(TYPES.ParkingRepository).to(ParkingRepositoryBasic).inSingletonScope();
kernel.bind<UserRepository>(TYPES.UserRepository).to(UserRepositoryBasic).inSingletonScope();
kernel.bind<TrackingRepository>(TYPES.TrackingRepository).to(TrackingRepositoryBasic).inSingletonScope();
kernel.bind<GoogleDistanceMatrixKey>(TYPES.GoogleDistanceMatrixKey).to(GoogleDistanceMatrixKeyBasic).inSingletonScope();

// some variables
let version = '0.1.3';
let logger: Logger = kernel.get<Logger>(TYPES.Logger);
let parkingService: ParkingService = kernel.get<ParkingService>(TYPES.ParkingService);
let testDataService: TestDataService = kernel.get<TestDataService>(TYPES.TestDataService);
let userService: UserService = kernel.get<UserService>(TYPES.UserService);
let trackingService: TrackingService = kernel.get<TrackingService>(TYPES.TrackingService);

// mongodb (with mongoose) connection
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost:27017/test');
mongoose.connection.on('error', console.error.bind(console, 'connection error:'));

var serverError = function (response: Response, message: string, user?: User) {
    logger.error(message, user);
    response.type('application/json; charset=utf-8');
    response.writeHead(500);
    response.write('{"error": "' + message + '"}');
开发者ID:andi-git,项目名称:nodejs-test,代码行数:31,代码来源:app.ts


注:本文中的inversify.Kernel.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。