@@ -161,12 +161,7 @@ export const shlApiRouter = new oak.Router()
161161      throw  new  Error ( `Can't manage SHLink `  +  context . params . shlId ) ; 
162162    } 
163163
164-     const  fileToRemove  =  { 
165-       contentType : context . request . headers . get ( 'content-type' ) ! , 
166-       content : await  currentFileBody . value , 
167-     } 
168- 
169-     const  deleted  =  db . DbLinks . deleteFile ( shl . id ,  fileToRemove ) ; 
164+     const  deleted  =  db . DbLinks . deleteFile ( shl . id ,  await  currentFileBody . value ) ; 
170165    context . response . body  =  { 
171166      ...shl , 
172167      deleted, 
@@ -190,12 +185,16 @@ export const shlApiRouter = new oak.Router()
190185  } ) 
191186  . delete ( '/shl/:shlId' ,  async  ( context )  =>  { 
192187    const  managementToken  =  await  context . request . headers . get ( 'authorization' ) ?. split ( / b e a r e r   / i) [ 1 ] ! ; 
193-     const  shl  =  db . DbLinks . getManagedShl ( context . params . shlId ,  managementToken ) ! ; 
194-     if  ( ! shl )  { 
195-       throw  new  Error ( `Can't manage SHLink `  +  context . params . shlId ) ; 
188+     if  ( db . DbLinks . linkExists ( context . params . shlId ) )  { 
189+       const  shl  =  db . DbLinks . getManagedShl ( context . params . shlId ,  managementToken ) ! ; 
190+       if  ( ! shl )  { 
191+         return  ( context . response . status  =  401 ) ; 
192+       } 
193+       const  deactivated  =  db . DbLinks . deactivate ( shl ) ; 
194+       context . response . body  =  deactivated ; 
195+     }  else  { 
196+       return  ( context . response . status  =  404 ) ; 
196197    } 
197-     const  deactivated  =  db . DbLinks . deactivate ( shl ) ; 
198-     context . response . body  =  deactivated ; 
199198  } ) 
200199  . post ( '/subscribe' ,  async  ( context )  =>  { 
201200    const  shlSet : {  shlId : string ;  managementToken : string  } [ ]  =  await  context . request . body ( {  type : 'json'  } ) . value ; 
0 commit comments