MCPcopy
hub / github.com/adonisjs/core / boot

Method boot

providers/edge_provider.ts:76–235  ·  view source on GitHub ↗

* Bridge AdonisJS and Edge * * Configures EdgeJS integration by: * - Setting up template mounting and caching * - Defining global helpers (route, signedRoute, app, config) * - Adding view getter to HttpContext for isolated rendering * - Adding render macro to BriskRoute * - Regi

()

Source from the content-addressed store, hash-verified

74 * // Now edge templates can use {{ route('home') }} helper
75 */
76 async boot() {
77 const app = this.app
78 const qs = new Qs(app.config.get<any>('app.http.qs', {}))
79 const router = await this.app.container.make('router')
80 const dumper = await this.app.container.make('dumper')
81
82 /**
83 * Resolves configuration values for Edge templates
84 *
85 * Provides access to application configuration within templates.
86 * Includes a 'has' method to check for config key existence.
87 *
88 * @param key - The configuration key to retrieve
89 * @param defaultValue - Optional default value if key doesn't exist
90 */
91 function edgeConfigResolver(key: string, defaultValue?: any) {
92 return app.config.get(key, defaultValue)
93 }
94 edgeConfigResolver.has = function (key: string) {
95 return app.config.has(key)
96 }
97
98 /**
99 * Generates client-side route definitions for frontend use
100 *
101 * Transforms router definitions into a serializable format that
102 * can be used in client-side JavaScript for route generation.
103 * Only includes named routes.
104 */
105 function clientRoutes() {
106 const routes = router.toJSON()
107 return Object.keys(routes).reduce<Record<string, ClientRouteJSON[]>>((result, domain) => {
108 result[domain] = routes[domain].reduce<ClientRouteJSON[]>((routesResult, route) => {
109 if (!route.name) {
110 return routesResult
111 }
112 routesResult.push({
113 domain: route.domain,
114 methods: route.methods,
115 pattern: route.pattern,
116 tokens: route.tokens,
117 name: route.name,
118 })
119 return routesResult
120 }, [])
121 return result
122 }, {})
123 }
124
125 /**
126 * Mount the default disk
127 */
128 edge.mount(app.viewsPath())
129
130 /**
131 * Cache templates in production
132 */
133 edge.configure({ cache: app.inProduction })

Callers

nothing calls this directly

Calls 3

pluginEdgeDumperFunction · 0.90
makeMethod · 0.80
configureMethod · 0.45

Tested by

no test coverage detected