@aklinker1/aframe 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aklinker1/aframe",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "packageManager": "bun@1.2.2",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,5 +1,9 @@
1
1
  import type { BunFile } from "bun";
2
2
 
3
+ const headers = {
4
+ "Cache-Control": "max-age=31536000",
5
+ };
6
+
3
7
  export interface AframeServer {
4
8
  listen(port: number): void | never;
5
9
  }
@@ -12,10 +16,10 @@ export async function fetchStatic(request: Request): Promise<Response> {
12
16
  if (!path) return fetchRootHtml();
13
17
 
14
18
  const exactFile = Bun.file(`${import.meta.publicDir}${path}`);
15
- if (await isFile(exactFile)) return new Response(exactFile);
19
+ if (await isFile(exactFile)) return new Response(exactFile, { headers });
16
20
 
17
21
  const htmlFile = Bun.file(`${import.meta.publicDir}${path}/index.html`);
18
- if (await isFile(htmlFile)) return new Response(exactFile);
22
+ if (await isFile(htmlFile)) return new Response(exactFile, { headers });
19
23
 
20
24
  return fetchRootHtml();
21
25
  }
@@ -33,12 +37,15 @@ function fetchRootHtml() {
33
37
  {
34
38
  headers: {
35
39
  "Content-Type": "text/html",
40
+ ...headers,
36
41
  },
37
42
  },
38
43
  );
39
44
  }
40
45
 
41
- return new Response(Bun.file(`${import.meta.publicDir}/index.html`));
46
+ return new Response(Bun.file(`${import.meta.publicDir}/index.html`), {
47
+ headers,
48
+ });
42
49
  }
43
50
 
44
51
  async function isFile(file: BunFile): Promise<boolean> {