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


TypeScript Application.get方法代码示例

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


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

示例1: it

    it('passes when entity service exists and `entityId` property is set', () => {
      app.get('authentication').entityId = 'id';
      app.use('/users', {
        async get () {
          return {};
        }
      });

      app.setup();
    });
开发者ID:feathersjs,项目名称:feathers,代码行数:10,代码来源:service.test.ts

示例2: logout

  logout () {
    return Promise.resolve(this.app.get('authentication'))
      .then(() => this.service.remove(null))
      .then((authResult: AuthenticationResult) => this.removeAccessToken()
        .then(() => this.reset())
        .then(() => {
          this.app.emit('logout', authResult);

          return authResult;
        })
      );
  }
开发者ID:feathersjs,项目名称:feathers,代码行数:12,代码来源:core.ts

示例3: it

    it('errors when trying to set invalid option', () => {
      app.get('authentication').otherJwt = {
        expiresIn: 'something'
      };

      try {
        app.service('authentication').register('otherJwt', new JWTStrategy());
        assert.fail('Should never get here');
      } catch (error) {
        assert.strictEqual(error.message, `Invalid JwtStrategy option 'authentication.otherJwt.expiresIn'. Did you mean to set it in 'authentication.jwtOptions'?`);
      }
    });
开发者ID:feathersjs,项目名称:feathers,代码行数:12,代码来源:jwt.test.ts

示例4: constructor

  constructor (app: Application, options: AuthenticationClientOptions) {
    const socket = app.io || app.primus;
    const storage = new StorageWrapper(app.get('storage') || options.storage);

    this.app = app;
    this.options = options;
    this.authenticated = false;
    this.app.set('storage', storage);

    if (socket) {
      this.handleSocket(socket);
    }
  }
开发者ID:feathersjs,项目名称:feathers,代码行数:13,代码来源:core.ts

示例5: Error

export const setup = (options: OauthSetupSettings) => (app: Application) => {
  const authPath = options.authService;
  const service: AuthenticationService = app.service(authPath);

  if (!service) {
    throw new Error(`'${authPath}' authentication service must exist before registering @feathersjs/authentication-oauth`);
  }

  const { oauth } = service.configuration;

  if (!oauth) {
    debug(`No oauth configuration found at '${authPath}'. Skipping oAuth setup.`);
    return;
  }

  const { strategyNames } = service;
  const { path = '/auth' } = oauth.defaults;
  const grant = merge({
    defaults: {
      path,
      host: `${app.get('host')}:${app.get('port')}`,
      protocol: app.get('env') === 'production' ? 'https' : 'http',
      transport: 'session'
    }
  }, omit(oauth, 'redirect'));

  each(grant, (value, key) => {
    if (key !== 'defaults') {
      value.callback = value.callback || `${path}/${key}/authenticate`;

      if (!strategyNames.includes(key)) {
        debug(`Registering oAuth default strategy for '${key}'`);
        service.register(key, new OAuthStrategy());
      }
    }
  });

  app.set('grant', grant);
};
开发者ID:feathersjs,项目名称:feathers,代码行数:39,代码来源:index.ts

示例6: session

export const getDefaultSettings = (app: Application, other?: Partial<OauthSetupSettings>) => {
  const defaults: OauthSetupSettings = {
    authService: app.get('defaultAuthentication'),
    linkStrategy: 'jwt',
    expressSession: session({
      secret: Math.random().toString(36).substring(7),
      saveUninitialized: true,
      resave: true
    }),
    ...other
  };

  return defaults;
};
开发者ID:feathersjs,项目名称:feathers,代码行数:14,代码来源:utils.ts

示例7: reAuthenticate

  reAuthenticate (force: boolean = false): Promise<AuthenticationResult> {
    // Either returns the authentication state or
    // tries to re-authenticate with the stored JWT and strategy
    const authPromise = this.app.get('authentication');

    if (!authPromise || force === true) {
      return this.getAccessToken().then(accessToken => {
        if (!accessToken) {
          throw new NotAuthenticated('No accessToken found in storage');
        }

        return this.authenticate({
          strategy: this.options.jwtStrategy,
          accessToken
        });
      }).catch((error: Error) =>
        this.removeAccessToken().then(() => Promise.reject(error))
      );
    }

    return authPromise;
  }
开发者ID:feathersjs,项目名称:feathers,代码行数:22,代码来源:core.ts


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