How to use the midway-web.scope function in midway-web

To help you get started, we’ve selected a few midway-web examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github midwayjs / sandbox / packages / sandbox-core / src / core / dataSource / core.ts View on Github external
import { provide, async, config, logger, scope, ScopeEnum } from 'midway-web';
import { BaseDataSource } from './base';

@scope(ScopeEnum.Singleton)
@async()
@provide('coreDB')
export class CoreDBDataSource extends BaseDataSource {

  @config('coreDB')
  config;

  @logger('coreDBLogger')
  logger;

  name: string = 'coreDB';
}
github midwayjs / sandbox / packages / sandbox-core / src / core / dataSource / dw.ts View on Github external
import { provide, async, config, logger, scope, ScopeEnum } from 'midway-web';
import { BaseDataSource } from './base';

@scope(ScopeEnum.Singleton)
@async()
@provide('dw')
export class DWDataSource extends BaseDataSource {

  @config('dw')
  config;

  @logger('dwLogger')
  logger;

  name: string = 'dw';
}
github midwayjs / sandbox / packages / sandbox-core / src / core / adapter / platformManagerAdapter.ts View on Github external
import { provide, inject, IApplicationContext, providerWrapper, scope, ScopeEnum } from 'midway-web';
import {IPlatformManagerAdapter} from '../../interface/adapter/IPlatformManagerAdapter';
import {IPlatformAdapter} from '../../interface/adapter/IPlatformAdapter';

@scope(ScopeEnum.Singleton)
@provide('platformManagerAdapter')
export class PlatformManagerAdapter implements IPlatformManagerAdapter {

  @inject()
  protected platformAdapterDispatcher;

  async get(name: string): Promise {
    return this.platformAdapterDispatcher(name);
  }

}

export function platformAdapterDispatcher(context: IApplicationContext) {
  return async (adapterName: string) => {
    try {
      return await context.getAsync(adapterName + 'PlatformAdapter');