@@ -256,7 +256,7 @@ function healthEndpoint(req, res) {
256256
257257app . patch ( "/services" , function ( req , res ) {
258258 req . body = JSON . parse ( req . body ) ;
259- let service , url ;
259+ let service , url , integrity ;
260260 let env = getEnv ( req ) ;
261261 if ( req . body != undefined && req . body . hasOwnProperty ( "service" ) ) {
262262 service = req . body . service ;
@@ -273,6 +273,17 @@ app.patch("/services", function (req, res) {
273273 } else {
274274 return res . status ( 400 ) . send ( "url key is missing" ) ;
275275 }
276+ if ( req . body ?. hasOwnProperty ( "integrity" ) ) {
277+ if (
278+ typeof req . body . integrity !== "string" ||
279+ req . body . integrity . trim ( ) . length === 0
280+ ) {
281+ return res
282+ . status ( 400 )
283+ . send ( `Invalid integrity - must be a non-empty string` ) ;
284+ }
285+ integrity = req . body . integrity ;
286+ }
276287
277288 let packageDirLevel =
278289 req . query . packageDirLevel && req . query . packageDirLevel !== ""
@@ -296,7 +307,7 @@ app.patch("/services", function (req, res) {
296307 verifyValidUrl ( req , url )
297308 . then ( ( ) => {
298309 modify
299- . modifyService ( env , service , url , false , packageDirLevel )
310+ . modifyService ( env , service , url , false , packageDirLevel , integrity )
300311 . then ( ( json ) => {
301312 res . send ( json ) ;
302313 } )
0 commit comments