MCPcopy Index your code
hub / github.com/TanStack/router / next

Function next

packages/start-server-core/src/createStartHandler.ts:259–299  ·  view source on GitHub ↗
(nextCtx?: TODO)

Source from the content-addressed store, hash-verified

257 let index = -1
258
259 const next = async (nextCtx?: TODO): Promise<TODO> => {
260 // Merge context if provided using safeObjectMerge for prototype pollution prevention
261 if (nextCtx) {
262 if (nextCtx.context) {
263 ctx.context = safeObjectMerge(ctx.context, nextCtx.context)
264 }
265 // Copy own properties except context (Object.keys returns only own enumerable properties)
266 for (const key of Object.keys(nextCtx)) {
267 if (key !== 'context') {
268 ctx[key] = nextCtx[key]
269 }
270 }
271 }
272
273 index++
274 const middleware = middlewares[index]
275 if (!middleware) return ctx
276
277 let result: TODO
278 try {
279 result = await middleware({ ...ctx, next })
280 } catch (err) {
281 if (isSpecialResponse(err)) {
282 ctx.response = err
283 return ctx
284 }
285 throw err
286 }
287
288 const normalized = handleCtxResult(result)
289 if (normalized) {
290 if (normalized.response !== undefined) {
291 ctx.response = normalized.response
292 }
293 if (normalized.context) {
294 ctx.context = safeObjectMerge(ctx.context, normalized.context)
295 }
296 }
297
298 return ctx
299 }
300
301 return next()
302}

Callers 15

executeMiddlewareFunction · 0.70
configureServerFunction · 0.50
handlerFunction · 0.50
configureServerFunction · 0.50
createStart.tsxFile · 0.50
createStart.tsxFile · 0.50
createAuthMiddlewareFunction · 0.50
factory.tsxFile · 0.50
factory.tsxFile · 0.50

Calls 3

safeObjectMergeFunction · 0.90
isSpecialResponseFunction · 0.85
handleCtxResultFunction · 0.85

Tested by

no test coverage detected