本文整理汇总了TypeScript中koa-router.head函数的典型用法代码示例。如果您正苦于以下问题:TypeScript head函数的具体用法?TypeScript head怎么用?TypeScript head使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了head函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor() {
const storage = new FileStorage();
this.router = storage.storageRouter(false);
// this is usually handled by nginx directly, but might be used as fallback when there's no file before processors finish.
this.router.head('/files/:id.:ext', storage.head.bind(storage));
this.router.head('/files/:variation/:id.:ext', storage.head.bind(storage));
this.router.get('/files/:id.:ext', storage.get.bind(storage));
this.router.get('/files/:variation/:id.:ext', storage.get.bind(storage));
}
示例2: constructor
constructor() {
const api = new GameApi();
this.router = api.apiRouter();
this.router.get('/v1/games', api.list.bind(api));
this.router.head('/v1/games/:id', api.head.bind(api));
this.router.get('/v1/games/:id', api.view.bind(api));
this.router.patch('/v1/games/:id', api.auth(api.update.bind(api), 'games', 'update-own', [ Scope.ALL ]));
this.router.post('/v1/games', api.auth(api.create.bind(api), 'games', 'add-og', [ Scope.ALL ]));
this.router.delete('/v1/games/:id', api.auth(api.del.bind(api), 'games', 'delete', [ Scope.ALL ]));
const ratingApi = new RatingApi();
this.router.post('/v1/games/:id/rating', api.auth(ratingApi.createForGame.bind(ratingApi), 'games', 'rate', [ Scope.ALL, Scope.COMMUNITY ]));
this.router.put('/v1/games/:id/rating', api.auth(ratingApi.updateForGame.bind(ratingApi), 'games', 'rate', [ Scope.ALL, Scope.COMMUNITY ]));
this.router.get('/v1/games/:id/rating', api.auth(ratingApi.getForGame.bind(ratingApi), 'games', 'rate', [ Scope.ALL, Scope.COMMUNITY ]));
this.router.delete('/v1/games/:id/rating', api.auth(ratingApi.deleteForGame.bind(ratingApi), 'games', 'rate', [ Scope.ALL, Scope.COMMUNITY ]));
const starsApi = new StarApi();
this.router.post('/v1/games/:id/star', api.auth(starsApi.star('game').bind(starsApi), 'games', 'star', [ Scope.ALL, Scope.COMMUNITY ]));
this.router.delete('/v1/games/:id/star', api.auth(starsApi.unstar('game').bind(starsApi), 'games', 'star', [ Scope.ALL, Scope.COMMUNITY ]));
this.router.get('/v1/games/:id/star', api.auth(starsApi.get('game').bind(starsApi), 'games', 'star', [ Scope.ALL, Scope.COMMUNITY ]));
const backglassApi = new BackglassApi();
this.router.post('/v1/games/:gameId/backglasses', api.auth(backglassApi.create.bind(backglassApi), 'backglasses', 'add', [ Scope.ALL, Scope.CREATE ]));
this.router.get('/v1/games/:gameId/backglasses', backglassApi.list.bind(backglassApi));
const mediumApi = new MediumApi();
this.router.get('/v1/games/:gameId/media', mediumApi.list.bind(mediumApi));
const eventsApi = new LogEventApi();
this.router.get('/v1/games/:id/events', eventsApi.list({ byGame: true }).bind(eventsApi));
this.router.get('/v1/games/:id/release-name', api.auth(api.releaseName.bind(api), 'releases', 'add', [ Scope.ALL, Scope.CREATE ]));
}
示例3: constructor
constructor() {
const storage = new ReleaseStorage();
this.router = storage.storageRouter(true);
this.router.head('/v1/releases/:release_id', storage.auth(storage.checkDownload.bind(storage), 'files', 'download', [ Scope.ALL, Scope.STORAGE ]));
this.router.get('/v1/releases/:release_id', storage.auth(storage.download.bind(storage), 'files', 'download', [ Scope.ALL, Scope.STORAGE ]));
this.router.post('/v1/releases/:release_id', storage.auth(storage.download.bind(storage), 'files', 'download', [ Scope.ALL, Scope.STORAGE ]));
this.router.get('/v1/releases/:release_id/thumb', storage.thumbRedirect.bind(storage));
}
示例4: async
router.head(`/${resource}`, async (ctx, next) => {
let filter: Expression = true;
if (ctx.request.query.filter) filter = parse(ctx.request.query.filter);
const log = {
message: `Count ${resource}`,
context: ctx,
filter: ctx.request.query.filter,
count: null
};
if (!ctx.state.authorizer.hasAccess(resource, 1)) {
logUnauthorizedWarning(log);
return void next();
}
// Exclude temporary tasks and faults
if (resource === "tasks" || resource === "faults") {
filter = and(filter, [
"NOT",
["<", ["PARAM", "expiry"], Date.now() + 60000]
]);
}
const count = await db.count(resource, filter);
ctx.set("X-Total-Count", `${count}`);
ctx.body = "";
log.count = count;
logger.accessInfo(log);
});