當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript koa-router.head函數代碼示例

本文整理匯總了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));
	}
開發者ID:freezy,項目名稱:node-vpdb,代碼行數:10,代碼來源:file.storage.router.ts

示例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 ]));
	}
開發者ID:freezy,項目名稱:node-vpdb,代碼行數:33,代碼來源:game.api.router.ts

示例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));
	}
開發者ID:freezy,項目名稱:node-vpdb,代碼行數:9,代碼來源:release.storage.router.ts

示例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);
  });
開發者ID:zaidka,項目名稱:genieacs,代碼行數:32,代碼來源:api.ts


注:本文中的koa-router.head函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。