MCPcopy
hub / github.com/vercel/next.js / getEdgeFunctionInfo

Method getEdgeFunctionInfo

packages/next/src/server/next-server.ts:1485–1545  ·  view source on GitHub ↗

* Get information for the edge function located in the provided page * folder. If the edge function info can't be found it will throw * an error.

(params: {
    page: string
    /** Whether we should look for a middleware or not */
    middleware: boolean
  })

Source from the content-addressed store, hash-verified

1483 * an error.
1484 */
1485 protected getEdgeFunctionInfo(params: {
1486 page: string
1487 /** Whether we should look for a middleware or not */
1488 middleware: boolean
1489 }): {
1490 name: string
1491 paths: string[]
1492 wasm: { filePath: string; name: string }[]
1493 env: { [key: string]: string }
1494 assets?: { filePath: string; name: string }[]
1495 } | null {
1496 const manifest = this.getMiddlewareManifest()
1497 if (!manifest) {
1498 return null
1499 }
1500
1501 let foundPage: string
1502
1503 try {
1504 foundPage = denormalizePagePath(normalizePagePath(params.page))
1505 } catch (err) {
1506 return null
1507 }
1508
1509 let pageInfo = params.middleware
1510 ? manifest.middleware[foundPage]
1511 : manifest.functions[foundPage]
1512
1513 if (!pageInfo) {
1514 if (!params.middleware) {
1515 throw new PageNotFoundError(foundPage)
1516 }
1517 return null
1518 }
1519
1520 return {
1521 name: pageInfo.name,
1522 paths: pageInfo.files.map((file) =>
1523 join(/* turbopackIgnore: true */ this.distDir, file)
1524 ),
1525 wasm: (pageInfo.wasm ?? []).map((binding) => ({
1526 ...binding,
1527 filePath: join(
1528 /* turbopackIgnore: true */ this.distDir,
1529 binding.filePath
1530 ),
1531 })),
1532 assets:
1533 pageInfo.assets &&
1534 pageInfo.assets.map((binding) => {
1535 return {
1536 ...binding,
1537 filePath: join(
1538 /* turbopackIgnore: true */ this.distDir,
1539 binding.filePath
1540 ),
1541 }
1542 }),

Callers 3

hasMiddlewareMethod · 0.95
runMiddlewareMethod · 0.95
runEdgeFunctionMethod · 0.95

Calls 5

getMiddlewareManifestMethod · 0.95
denormalizePagePathFunction · 0.90
normalizePagePathFunction · 0.90
joinFunction · 0.90
mapMethod · 0.45

Tested by

no test coverage detected