createIntegration() — astro Function Reference
Architecture documentation for the createIntegration() function in index.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 5dd1c441_d442_c1c9_1353_5b95f9ce843a["createIntegration()"] cd0e7127_96f9_d468_a86c_01d17d962513["index.ts"] 5dd1c441_d442_c1c9_1353_5b95f9ce843a -->|defined in| cd0e7127_96f9_d468_a86c_01d17d962513 49acc476_8ac9_7059_97c7_d8681244d41e["getAdapter()"] 5dd1c441_d442_c1c9_1353_5b95f9ce843a -->|calls| 49acc476_8ac9_7059_97c7_d8681244d41e style 5dd1c441_d442_c1c9_1353_5b95f9ce843a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/integrations/node/src/index.ts lines 40–142
export default function createIntegration(userOptions: UserOptions): AstroIntegration {
if (!userOptions?.mode) {
throw new AstroError(`Setting the 'mode' option is required.`);
}
const { experimentalErrorPageHost } = userOptions;
if (
experimentalErrorPageHost &&
(!URL.canParse(experimentalErrorPageHost) ||
!protocols.includes(new URL(experimentalErrorPageHost).protocol))
) {
throw new AstroError(
`Invalid experimentalErrorPageHost: ${experimentalErrorPageHost}. It should be a valid URL.`,
);
}
let _options: Options;
let _config: AstroConfig | undefined = undefined;
let _routeToHeaders: RouteToHeaders | undefined = undefined;
return {
name: '@astrojs/node',
hooks: {
'astro:config:setup': async ({ updateConfig, config, logger, command }) => {
let session = config.session;
_config = config;
if (!session?.driver) {
logger.info('Enabling sessions with filesystem storage');
session = {
driver: sessionDrivers.fsLite({
base: fileURLToPath(new URL('sessions', config.cacheDir)),
}),
cookie: session?.cookie,
ttl: session?.ttl,
};
}
updateConfig({
build: {
redirects: false,
},
image: {
endpoint: {
route: config.image.endpoint.route ?? '_image',
entrypoint:
config.image.endpoint.entrypoint ??
(command === 'dev' ? 'astro/assets/endpoint/dev' : 'astro/assets/endpoint/node'),
},
},
session,
vite: {
ssr: {
noExternal: ['@astrojs/node'],
},
},
});
},
'astro:build:generated': ({ routeToHeaders }) => {
_routeToHeaders = routeToHeaders;
},
'astro:config:done': ({ setAdapter, config }) => {
_options = {
...userOptions,
client: config.build.client?.toString(),
server: config.build.server?.toString(),
host: config.server.host,
port: config.server.port,
assets: config.build.assets,
staticHeaders: userOptions.staticHeaders ?? false,
experimentalErrorPageHost,
};
setAdapter(getAdapter(_options));
},
'astro:build:done': async () => {
if (!_config) {
return;
}
if (_routeToHeaders && _routeToHeaders.size > 0) {
const headersFileUrl = new URL(STATIC_HEADERS_FILE, _config.outDir);
const headersValue: NodeAppHeadersJson = [];
for (const [pathname, { headers }] of _routeToHeaders.entries()) {
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does createIntegration() do?
createIntegration() is a function in the astro codebase, defined in packages/integrations/node/src/index.ts.
Where is createIntegration() defined?
createIntegration() is defined in packages/integrations/node/src/index.ts at line 40.
What does createIntegration() call?
createIntegration() calls 1 function(s): getAdapter.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free