import type { Server } from 'http' ; import type { RouteOptions , RawRequestDefaultExpression , RawReplyDefaultExpression } from 'fastify' ; import { preconditionFailed } from '@hapi/boom' ; import { Readable } from 'stream' ; import { type , Querystring , type , Params , artifactsRouteSchema } from './schema' ; export const putArtifact = { url : '/artifacts/:id' , method : 'PUT' , schema : artifactsRouteSchema , async handler ( req , reply ) { const artifactId = req . params . id ; const teamId = req . query . teamId ; try { await this . location . createCachedArtifact ( artifactId , teamId , Readable . from ( req . body ) ) ; reply . send ( { urls : [ `${ teamId }/${ artifactId }` ] } ) ; } catch ( err ) { throw preconditionFailed ( `Error during the artifact creation` , err ) ; } } , } ;