Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit 5774387

Browse files
committed
Clean up
1 parent 5675123 commit 5774387

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

server/bundle_css.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ export type BundleCSSResult = {
1818
deps?: string[];
1919
};
2020

21+
/**
22+
* bundle css with `parcel-css`.
23+
*
24+
* https://github.com/parcel-bundler/parcel-css
25+
*/
2126
export async function bundleCSS(
2227
specifier: string,
2328
sourceCode: string,

server/proxy_modules.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ const esModuleLoader = async (input: { pathname: string } & ModuleLoaderContent,
7474
};
7575
};
7676

77-
const buildLoader = (moduleLoaders: ModuleLoader[], env: ModuleLoaderEnv) => {
77+
function initLoader(moduleLoaders: ModuleLoader[], env: ModuleLoaderEnv) {
7878
return async (req: Request): Promise<{ content: string | Uint8Array; contentType?: string } | undefined> => {
7979
const { pathname } = new URL(req.url);
8080
if (pathname.endsWith(".css")) {
@@ -92,7 +92,7 @@ const buildLoader = (moduleLoaders: ModuleLoader[], env: ModuleLoaderEnv) => {
9292
}
9393
}
9494
};
95-
};
95+
}
9696

9797
type ProxyModulesOptions = {
9898
moduleLoaders: ModuleLoader[];
@@ -107,7 +107,7 @@ export function proxyModules(port: number, options: ProxyModulesOptions) {
107107
serveDir({
108108
port,
109109
signal: options.signal,
110-
loader: buildLoader(options.moduleLoaders, {
110+
loader: initLoader(options.moduleLoaders, {
111111
importMap: options.importMap,
112112
isDev: Deno.env.get("ALEPH_ENV") === "development",
113113
ssr: true,

server/response.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
export function json(data: unknown, init?: ResponseInit): Response {
2-
const headers = new Headers(init?.headers);
3-
headers.append("content-type", "application/json; charset=utf-8");
4-
return new Response(JSON.stringify(data), { ...init, headers });
5-
}
6-
71
export type CacheControlOptions = {
82
maxAge?: number;
93
sMaxAge?: number;
@@ -52,6 +46,12 @@ export function content(
5246
return new Response(body, { ...init, headers });
5347
}
5448

49+
export function json(data: unknown, init?: ResponseInit): Response {
50+
const headers = new Headers(init?.headers);
51+
headers.append("content-type", "application/json; charset=utf-8");
52+
return new Response(JSON.stringify(data), { ...init, headers });
53+
}
54+
5555
export type CookieOptions = {
5656
expires?: number | Date;
5757
maxAge?: number;

server/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ export type AlephConfig = {
1111
unocss?: UnoConfig;
1212
};
1313

14+
/** The build platform. */
1415
export type BuildPlatform = "deno" | "cloudflare" | "vercel";
1516

17+
/** The build optioins for `build` command. */
1618
export type BuildOptions = {
1719
/** The supported platform. default is "deno" */
1820
platform?: BuildPlatform;

0 commit comments

Comments
 (0)