@@ -2,6 +2,10 @@ import type { Blueprint } from '@seamapi/blueprint'
22import { kebabCase } from 'change-case'
33import type Metalsmith from 'metalsmith'
44
5+ import {
6+ type EndpointsLayoutContext ,
7+ setEndpointsLayoutContext ,
8+ } from './layouts/endpoints.js'
59import {
610 type RouteIndexLayoutContext ,
711 type RouteLayoutContext ,
@@ -12,7 +16,9 @@ interface Metadata {
1216 blueprint : Blueprint
1317}
1418
15- type File = RouteLayoutContext & RouteIndexLayoutContext & { layout : string }
19+ type File = RouteLayoutContext &
20+ RouteIndexLayoutContext &
21+ EndpointsLayoutContext & { layout : string }
1622
1723const rootPath = 'src/lib/seam/connect/routes'
1824
@@ -34,15 +40,22 @@ export const connect = (
3440
3541 const routeIndexes : Record < string , Set < string > > = { }
3642
37- const rootRouteKey = `${ rootPath } /seam-http.ts`
38- files [ rootRouteKey ] = { contents : Buffer . from ( '\n' ) }
39- const file = files [ rootRouteKey ] as unknown as File
43+ const k = `${ rootPath } /seam-http.ts`
44+ files [ k ] = { contents : Buffer . from ( '\n' ) }
45+ const file = files [ k ] as unknown as File
4046 file . layout = 'route.hbs'
4147 setRouteLayoutContext ( file , null , nodes )
4248
4349 routeIndexes [ '' ] ??= new Set ( )
4450 routeIndexes [ '' ] ?. add ( 'seam-http.js' )
4551
52+ const endpointsKey = `${ rootPath } /seam-http-endpoints.ts`
53+ files [ endpointsKey ] = { contents : Buffer . from ( '\n' ) }
54+ const endpointFile = files [ endpointsKey ] as unknown as File
55+ endpointFile . layout = 'endpoints.hbs'
56+ setEndpointsLayoutContext ( endpointFile , blueprint . routes )
57+ routeIndexes [ '' ] ?. add ( 'seam-http-endpoints.js' )
58+
4659 for ( const node of nodes ) {
4760 const path = toFilePath ( node . path )
4861 const name = kebabCase ( node . name )
0 commit comments