本文整理汇总了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();
});
示例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;
})
);
}
示例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'?`);
}
});
示例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);
}
}
示例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);
};
示例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;
};
示例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;
}