Home / Function/ serverStart() — astro Function Reference

serverStart() — astro Function Reference

Architecture documentation for the serverStart() function in preview.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  6445b6ff_b146_6b78_6eb7_90f8bc42caf7["serverStart()"]
  0e850bda_fb21_6bc2_df97_aab29717b7c7["preview.ts"]
  6445b6ff_b146_6b78_6eb7_90f8bc42caf7 -->|defined in| 0e850bda_fb21_6bc2_df97_aab29717b7c7
  1e83288b_e626_faf6_40e6_9dd61efff0ed["createPreviewServer()"]
  1e83288b_e626_faf6_40e6_9dd61efff0ed -->|calls| 6445b6ff_b146_6b78_6eb7_90f8bc42caf7
  2e8b889a_0717_ae0e_876e_084c1878b285["getNetworkLogging()"]
  6445b6ff_b146_6b78_6eb7_90f8bc42caf7 -->|calls| 2e8b889a_0717_ae0e_876e_084c1878b285
  style 6445b6ff_b146_6b78_6eb7_90f8bc42caf7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/integrations/cloudflare/src/entrypoints/preview.ts lines 98–142

export function serverStart({
	startupTime,
	resolvedUrls,
	host,
	base,
}: {
	startupTime: number;
	resolvedUrls: ResolvedServerUrls;
	host: string | undefined;
	base: string;
}): string {
	// PACKAGE_VERSION is injected at build-time
	const version = process.env.PACKAGE_VERSION ?? '0.0.0';
	const localPrefix = `${colors.dim('┃')} Local    `;
	const networkPrefix = `${colors.dim('┃')} Network  `;
	const emptyPrefix = ' '.repeat(11);

	const localUrlMessages = resolvedUrls.local.map((url, i) => {
		return `${i === 0 ? localPrefix : emptyPrefix}${colors.cyan(new URL(url).origin + base)}`;
	});
	const networkUrlMessages = resolvedUrls.network.map((url, i) => {
		return `${i === 0 ? networkPrefix : emptyPrefix}${colors.cyan(new URL(url).origin + base)}`;
	});

	if (networkUrlMessages.length === 0) {
		const networkLogging = getNetworkLogging(host);
		if (networkLogging === 'host-to-expose') {
			networkUrlMessages.push(`${networkPrefix}${colors.dim('use --host to expose')}`);
		} else if (networkLogging === 'visible') {
			networkUrlMessages.push(`${networkPrefix}${colors.dim('unable to find network to expose')}`);
		}
	}

	const messages = [
		'',
		`${colors.bgGreen(colors.bold(` astro `))} ${colors.green(`v${version}`)} ${colors.dim(`ready in`)} ${Math.round(
			startupTime,
		)} ${colors.dim('ms')}`,
		'',
		...localUrlMessages,
		...networkUrlMessages,
		'',
	];
	return messages.filter((msg) => typeof msg === 'string').join('\n');
}

Domain

Subdomains

Frequently Asked Questions

What does serverStart() do?
serverStart() is a function in the astro codebase, defined in packages/integrations/cloudflare/src/entrypoints/preview.ts.
Where is serverStart() defined?
serverStart() is defined in packages/integrations/cloudflare/src/entrypoints/preview.ts at line 98.
What does serverStart() call?
serverStart() calls 1 function(s): getNetworkLogging.
What calls serverStart()?
serverStart() is called by 1 function(s): createPreviewServer.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free