docs: Add detail to Deno KV auth example (#1665)

This commit is contained in:
Josh Gum
2023-09-03 21:54:12 +00:00
committed by GitHub
parent f9ab05f7ea
commit 3858f5ad03
10 changed files with 22 additions and 16 deletions
+4 -4
View File
@@ -27,11 +27,11 @@ export async function handler(req: Request, ctx: MiddlewareHandlerContext) {
headers.set("Access-Control-Allow-Credentials", "true");
headers.set(
"Access-Control-Allow-Headers",
"Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With"
"Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With",
);
headers.set(
"Access-Control-Allow-Methods",
"POST, OPTIONS, GET, PUT, DELETE"
"POST, OPTIONS, GET, PUT, DELETE",
);
return resp;
@@ -66,11 +66,11 @@ export async function handler(_req: Request, ctx: MiddlewareHandlerContext) {
headers.set("Access-Control-Allow-Credentials", "true");
headers.set(
"Access-Control-Allow-Headers",
"Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With"
"Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With",
);
headers.set(
"Access-Control-Allow-Methods",
"POST, OPTIONS, GET, PUT, DELETE"
"POST, OPTIONS, GET, PUT, DELETE",
);
return resp;
+1 -1
View File
@@ -66,7 +66,7 @@ export class Context {
export async function handler(
req: Request,
ctx: MiddlewareHandlerContext<State>
ctx: MiddlewareHandlerContext<State>,
) {
ctx.state.context = Context.instance();
const resp = await ctx.next();
+1 -1
View File
@@ -30,7 +30,7 @@ export const handler: Handlers<Page> = {
let rawMarkdown = "";
if (ctx.params.slug === "remote") {
const resp = await fetch(
`https://raw.githubusercontent.com/denoland/fresh/main/docs/latest/introduction/index.md`
`https://raw.githubusercontent.com/denoland/fresh/main/docs/latest/introduction/index.md`,
);
if (resp.status !== 200) {
return ctx.render(undefined);
+2 -2
View File
@@ -270,8 +270,8 @@ export default function Home(req: Request, ctx: RouteContext) {
<>
<h1>
This page violates our configured CSP. But we don't have a{" "}
<code>RouteConfig</code> enabled, so Fresh doesn't know to use the CSP.
Styles will be applied.
<code>RouteConfig</code>{" "}
enabled, so Fresh doesn't know to use the CSP. Styles will be applied.
</h1>
<link rel="stylesheet" type="text/css" href="example.css" />
</>
+8 -1
View File
@@ -122,7 +122,14 @@ available.
}
```
5. Start your project with the necessary environment variables.
5. ⚠️ While Deno KV is still **experimental** you need to add the `--unstable`
option to the `start` task in the `deno.json` file.
```json
"start": "deno run -A --watch=static/,routes/ --unstable dev.ts",
```
6. Start your project with the necessary environment variables.
```sh
GITHUB_CLIENT_ID=xxx GITHUB_CLIENT_SECRET=xxx deno task start