import { AsyncLocalStorage } from "async_hooks" ; import * as git from "@fluidframework/gitresources" ; import { IThrottler } from "@fluidframework/server-services-core" ; import { IThrottleMiddlewareOptions , throttle , getParam } from "@fluidframework/server-services-utils" ; import { Router } from "express" ; import * as nconf from "nconf" ; import winston from "winston" ; import { ICache , ITenantService } from "../../services" ; import * as utils from "../utils" ; export function create ( config , tenantService , throttler , cache ? , asyncLocalStorage ? ) { const router = Router ( ) ; const commonThrottleOptions = { throttleIdPrefix : ( req ) => getParam ( req . params , "tenantId" ) , throttleIdSuffix : utils . Constants . throttleIdSuffix , } ; async function createTag ( tenantId , authorization , params ) { const service = await utils . createGitService ( tenantId , authorization , tenantService , cache , asyncLocalStorage ) ; return service . createTag ( params ) ; } async function getTag ( tenantId , authorization , tag ) { const service = await utils . createGitService ( tenantId , authorization , tenantService , cache , asyncLocalStorage ) ; return service . getTag ( tag ) ; } router . post ( "/repos/:ignored?/:tenantId/git/tags" , throttle ( throttler , winston , commonThrottleOptions ) , ( request , response , next ) => { const tagP = createTag ( request . params . tenantId , request . get ( "Authorization" ) , request . body ) ; utils . handleResponse ( tagP , response , false , 201 ) ; } ) ; router . get ( "/repos/:ignored?/:tenantId/git/tags/*" , throttle ( throttler , winston , commonThrottleOptions ) , ( request , response , next ) => { const tagP = getTag ( request . params . tenantId , request . get ( "Authorization" ) , request . params [ 0 ] ) ; utils . handleResponse ( tagP , response , false ) ; } ) ; return router ; }