-
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.
scaffold separation core/itty sample
- Loading branch information
Showing
9 changed files
with
90 additions
and
72 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { createYoga } from "graphql-yoga"; | ||
import { schema } from "../schema"; | ||
|
||
export const GraphQLHandler = async (req: Request, env: any, ctx: any) => { | ||
const yoga = createYoga({ | ||
schema, | ||
context: async (event) => { | ||
const { request } = event; | ||
const authorization = | ||
(request.headers.get("Authorization") || | ||
request.headers.get("authorization")) ?? | ||
null; | ||
|
||
const forwardedFor = request.headers.get("x-forwarded-for"); | ||
// "x-forwarded-for": "\"[2a02:1210:5274:9f00:b94e:d462:5886:5cc2]\", 140.248.74.113, 140.248.74.113", | ||
// extract ip address in [] in forwardedFor | ||
const remoteIp = forwardedFor?.match(/\[(.*?)\]/)?.[1] ?? null; | ||
|
||
return { | ||
authorization, | ||
remoteIp, | ||
userAgent: request.headers.get("user-agent") ?? null, | ||
}; | ||
}, | ||
landingPage: false, | ||
}); | ||
return yoga(req, env, ctx); | ||
}; |
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,29 +1 @@ | ||
import { createYoga } from "graphql-yoga"; | ||
import { schema } from "./schema"; | ||
|
||
export const GraphQLHandler = async (req: Request, env: any, ctx: any) => { | ||
const yoga = createYoga({ | ||
schema, | ||
context: async (event) => { | ||
const { request } = event; | ||
const authorization = | ||
(request.headers.get("Authorization") || | ||
request.headers.get("authorization")) ?? | ||
null; | ||
|
||
const forwardedFor = request.headers.get("x-forwarded-for"); | ||
// "x-forwarded-for": "\"[2a02:1210:5274:9f00:b94e:d462:5886:5cc2]\", 140.248.74.113, 140.248.74.113", | ||
// extract ip address in [] in forwardedFor | ||
const remoteIp = forwardedFor?.match(/\[(.*?)\]/)?.[1] ?? null; | ||
|
||
return { | ||
// request: modifiedRequest, // Pass the modified request to the context | ||
authorization, | ||
remoteIp, | ||
userAgent: request.headers.get("user-agent") ?? null, | ||
}; | ||
}, | ||
landingPage: false, | ||
}); | ||
return yoga(req, env, ctx); | ||
}; | ||
export {GraphQLHandler} from "./handlers/graphql"; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,11 @@ | ||
interface Context { | ||
|
||
} | ||
|
||
export const Hydra = async (request: Request, env: any, ctx: Context | ||
|
||
) => { | ||
return new Response("Hydra handler", { | ||
status: 200, | ||
}); | ||
} |
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