@@ -40,11 +40,16 @@ export const serviceMiddleware = (callback: ServiceCallback) =>
4040 const { query, body : data } = req ;
4141 const { __feathersId : id = null , ...route } = req . params ;
4242 const params = { query, route, ...req . feathers } ;
43+
4344 const context = await callback ( req , res , { id, data, params } ) ;
45+
4446 const result = http . getData ( context ) ;
47+ const statusCode = http . getStatusCode ( context , result ) ;
48+ const location = http . getLocation ( context , req . get ( 'Referrer' ) ) ;
4549
4650 res . data = result ;
47- res . status ( http . getStatusCode ( context , result ) ) ;
51+ res . status ( statusCode ) ;
52+ if ( location ) res . set ( 'Location' , location ) ;
4853
4954 next ( ) ;
5055 } catch ( error : any ) {
@@ -66,11 +71,13 @@ export const serviceMethodHandler = (
6671 }
6772
6873 const args = getArgs ( options ) ;
69- const context = createContext ( service , method ) ;
74+ const contextBase = createContext ( service , method ) ;
75+ res . hook = contextBase ;
7076
77+ const context = await service [ method ] ( ...args , contextBase ) ;
7178 res . hook = context ;
7279
73- return service [ method ] ( ... args , context ) ;
80+ return context ;
7481} ) ;
7582
7683export function rest ( handler : RequestHandler = formatter ) {
0 commit comments