How to use the midway-web.async 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 / service / errorService.ts View on Github external
import { ErrorRecord, PaginationResult } from '../../interface/services/common';
import * as Interface from '../../interface/services/IErrorService';
import { provide, async, logger, inject } from 'midway-web';
import {ErrorManager} from '../manager/errorManager';

@async()
@provide('errorService')
export class ErrorService implements Interface.IErrorService {

  @logger()
  protected logger;

  @inject('errorManager')
  protected errorManager: ErrorManager;

  async queryErrors(options: Interface.QueryErrorOptions): Promise> {
    this.logger.info('[Service:API:queryErrors:params:]', JSON.stringify(options));
    return this.errorManager.findErrors(options);
  }

  async queryErrorTypes(
    options: Interface.QueryErrorOptions,
github midwayjs / sandbox / packages / sandbox-core / src / core / manager / errorManager.ts View on Github external
import { logger, provide, inject, async } from 'midway-web';
import * as _ from 'lodash';
import * as Interface from '../../interface/services/IErrorService';
import * as Sequelize from 'sequelize';

interface SearchCondition {
  [key: string]: any;
}

@async()
@provide('errorManager')
export class ErrorManager {

  @logger()
  protected logger;

  @inject()
  protected errorModel;

  public async findErrors(options: Interface.QueryErrorOptions) {
    const conditions = this.buildSearchConditions(options);

    return this.errorModel.findAndCountAll({
      where: { [Sequelize.Op.and]: conditions },
      order: [[ 'timestamp', 'desc' ]],
      offset: (options.page - 1) * options.pageSize,
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 / 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 / service / applicationService.ts View on Github external
import { provide, logger, inject, async } from 'midway-web';
import * as assert from 'assert';
import { ModelQueryOptions, ScopeInfo } from '../../interface/models/common';
import { SandboxApplication } from '../../interface/models/application';
import {IPlatformGroup, IPlatformHost, IPlatformHostResult} from '../../interface/adapter/IPlatformAdapter';
import {AppSelector, ListResult} from '../../interface/services/common';
import { SandboxGroup } from '../../interface/models/group';
import { IApplicationService } from '../../interface/services/IApplicationService';
import { optionsCheck } from '../util/util';
import {ApplicationManager} from '../manager/applicationManager';
import {PlatformManagerAdapter} from '../adapter/platformManagerAdapter';
import {GroupManager} from '../manager/groupManager';

@async()
@provide('applicationService')
export class ApplicationService implements IApplicationService {

  @logger()
  protected logger;

  @inject()
  protected applicationManager: ApplicationManager;

  @inject()
  protected groupManager: GroupManager;

  @inject()
  protected platformManagerAdapter: PlatformManagerAdapter;

  async listByUser(uid: string, options?: ModelQueryOptions): Promise> {