-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d2dd552
commit a9bc9bc
Showing
9 changed files
with
48 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { MetadataSchema } from "@schemas" | ||
import { MetadataService } from "@services" | ||
import type { APIContext, MiddlewareNext } from "astro" | ||
|
||
export async function onRequest(context: APIContext, next: MiddlewareNext) { | ||
const service = MetadataService(context.locals.runtime.env.BLOG) | ||
const metadata = await service.get() | ||
if (!metadata) throw new Error("Missing metadata") | ||
MetadataSchema.parse(metadata) | ||
context.locals.metadata = metadata | ||
return next() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import type { R2Bucket } from "@cloudflare/workers-types" | ||
import type { Metadata } from "@schemas" | ||
|
||
type MetadataService = { | ||
get(): Promise<Metadata | undefined> | ||
} | ||
|
||
export function MetadataService(blog: R2Bucket): MetadataService { | ||
return { | ||
async get() { | ||
const object = await blog.get("metadata.json") | ||
return object?.json<Metadata>() | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export * from "./EmailService" | ||
export * from "./Repository" | ||
export * from "./GearService" | ||
export * from "./PostService" | ||
export * from "./PostService" | ||
export * from "./MetadataService" |