Repository: withastro/astro
File: packages/integrations/cloudflare/src/index.ts (TypeScript)

Code before:
	 *
	 * ```sh
	 * npx wrangler kv namespace create SESSION
	 * ```
	 *
	 * This will log the id of the created namespace. You can then add it to your `wrangler.json` file like this:
	 *
	 * ```json
	 * {
	 *   "kv_namespaces": [
	 *     {
	 *       "binding": "SESSION",
	 *       "id": "<your kv namespace id here>"
	 *     }
	 *   ]
	 * }
	 * ```
	 * By default, the driver looks for the binding named `SESSION`, but you can override this by providing a different name here.
	 *
	 * See https://developers.cloudflare.com/kv/concepts/kv-namespaces/ for more details on using KV namespaces.
	 *
	 */
	sessionKVBindingName?: string;

	/**
	 * The path to the entry file for the server. This is used to determine the entry point for the server.
	 * By default, this is set to `@astrojs/cloudflare/entrypoints/server.js`.
	 */
	entryfilePath?: string;

	/**
	 * The exports to use for the server entry file. By default, this is set to `['default']`. If you need to have other top level exports, e.g. DurableObjects you need to provide them here.
	 */
	entryfileExports?: string[];
};

function wrapWithSlashes(path: string): string {
	return prependForwardSlash(appendForwardSlash(path));
}

function setProcessEnv(config: AstroConfig, env: Record<string, unknown>) {
	const getEnv = createGetEnv(env);

	if (config.env?.schema) {
		for (const key of Object.keys(config.env.schema)) {
			const value = getEnv(key);
			if (value !== undefined) {
				process.env[key] = value;
			}
		}
	}

Review comment (suggestion):
Users should be able to provide a `string` and `URL`. Generally, those are the APIs we provide to users. Also, we should document that paths are relative to the project's root. It would be helpful to provide an example here. 

Also we could link Astro docs about server entry point. That will provide useful information such as signature, usage, etc. 

Code after:
	 * you must create a KV namespace and declare it in your wrangler config file. You can do this with the wrangler command:
	 *
	 * ```sh
	 * npx wrangler kv namespace create SESSION
	 * ```
	 *
	 * This will log the id of the created namespace. You can then add it to your `wrangler.json` file like this:
	 *
	 * ```json
	 * {
	 *   "kv_namespaces": [
	 *     {
	 *       "binding": "SESSION",
	 *       "id": "<your kv namespace id here>"
	 *     }
	 *   ]
	 * }
	 * ```
	 * By default, the driver looks for the binding named `SESSION`, but you can override this by providing a different name here.
	 *
	 * See https://developers.cloudflare.com/kv/concepts/kv-namespaces/ for more details on using KV namespaces.
	 *
	 */
	sessionKVBindingName?: string;

	/**
	 * This configuration option allows you to specify a custom entryPoint for your Cloudflare Worker.
	 * The entry point is the file that will be executed when your Worker is invoked.
	 * By default, this is set to `@astrojs/cloudflare/entrypoints/server.js` and `['default']`.
	 * @docs https://docs.astro.build/en/guides/integrations-guide/cloudflare/#workerEntryPoint
	 */
	workerEntryPoint?: {
		/**
		 * The path to the entry file. This should be a relative path from the root of your Astro project.
		 * @example`'src/worker.ts'`
		 * @docs https://docs.astro.build/en/guides/integrations-guide/cloudflare/#workerentrypointpath
		 */
		path: string | URL;
		/**
		 * Additional named exports to use for the entry file. Astro always includes the default export (`['default']`). If you need to have other top level named exports use this option.
		 * @example ['MyDurableObject', 'namedExport']
		 * @docs https://docs.astro.build/en/guides/integrations-guide/cloudflare/#workerentrypointnamedexports
		 */
		namedExports?: string[];
	};
};

function wrapWithSlashes(path: string): string {
	return prependForwardSlash(appendForwardSlash(path));
}