-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/dotkom/monoweb into feature…
…/pro-1-create-profile-info-component
- Loading branch information
Showing
52 changed files
with
2,677 additions
and
1,842 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { env } from "@dotkomonline/env" | ||
import { createProxyRoute } from "@dotkomonline/proxy-nextjs" | ||
|
||
const handler = createProxyRoute({ | ||
mountPath: "/api/trpc", | ||
apiEndpoint: env.RPC_HOST, | ||
}) | ||
|
||
export const GET = handler | ||
export const POST = handler |
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 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,4 @@ | ||
{ | ||
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json", | ||
"extends": ["../../biome.json"] | ||
} |
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,30 @@ | ||
{ | ||
"name": "@dotkomonline/rpc", | ||
"version": "0.1.0", | ||
"private": true, | ||
"type": "module", | ||
"scripts": { | ||
"dev": "tsx src/index.ts", | ||
"build": "tsc", | ||
"lint": "biome check . --write", | ||
"lint-check": "biome check .", | ||
"type-check": "tsc --noEmit" | ||
}, | ||
"dependencies": { | ||
"@dotkomonline/env": "workspace:*", | ||
"@dotkomonline/gateway-trpc": "workspace:*", | ||
"@fastify/cors": "^9.0.1", | ||
"@trpc/server": "^10.45.0", | ||
"fastify": "^4.28.0", | ||
"zod": "^3.22.4" | ||
}, | ||
"devDependencies": { | ||
"@biomejs/biome": "^1.9.3", | ||
"@dotkomonline/config": "workspace:*", | ||
"@dotkomonline/tsconfig": "workspace:*", | ||
"@types/node": "^20.12.7", | ||
"tslib": "^2.6.2", | ||
"typescript": "^5.4.5", | ||
"tsx": "^4.15.6" | ||
} | ||
} |
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,51 @@ | ||
import { env } from "@dotkomonline/env" | ||
import { type AppRouter, JwtService, appRouter, createContext } from "@dotkomonline/gateway-trpc" | ||
import fastifyCors from "@fastify/cors" | ||
import { type FastifyTRPCPluginOptions, fastifyTRPCPlugin } from "@trpc/server/adapters/fastify" | ||
import type { CreateFastifyContextOptions } from "@trpc/server/dist/adapters/fastify" | ||
import fastify from "fastify" | ||
|
||
const jwtService = new JwtService(env.WEB_AUTH0_ISSUER, [ | ||
env.WEB_AUTH0_CLIENT_ID, | ||
env.DASHBOARD_AUTH0_CLIENT_ID, | ||
env.GTX_AUTH0_CLIENT_ID, | ||
]) | ||
|
||
const allowedOrigins = env.RPC_ALLOWED_ORIGINS.split(",") | ||
|
||
export async function createFastifyContext({ req }: CreateFastifyContextOptions) { | ||
const bearer = req.headers.authorization | ||
if (bearer !== undefined) { | ||
const token = bearer.substring("Bearer ".length) | ||
const principal = await jwtService.verify(token) | ||
return createContext({ principal: principal.payload.sub ?? null }) | ||
} | ||
|
||
return createContext({ | ||
principal: null, | ||
}) | ||
} | ||
|
||
const server = fastify({ | ||
maxParamLength: 5000, | ||
}) | ||
server.register(fastifyCors, { | ||
origin: allowedOrigins, | ||
methods: ["GET", "POST", "PUT", "DELETE"], | ||
allowedHeaders: ["Content-Type", "Authorization"], | ||
credentials: true, | ||
}) | ||
|
||
server.register(fastifyTRPCPlugin, { | ||
prefix: "/api/trpc", | ||
trpcOptions: { | ||
router: appRouter, | ||
createContext: createFastifyContext, | ||
onError: ({ path, error }) => { | ||
// report to error monitoring | ||
console.error(`Error in tRPC handler on path '${path}':`, error) | ||
}, | ||
} satisfies FastifyTRPCPluginOptions<AppRouter>["trpcOptions"], | ||
}) | ||
|
||
await server.listen({ port: 4444 }) |
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 @@ | ||
{ | ||
"extends": "../../packages/tsconfig/tsconfig.json", | ||
"include": ["./**/*.ts", "./**/*.tsx"], | ||
"exclude": [], | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"jsx": "preserve", | ||
"incremental": true, | ||
"strictNullChecks": true | ||
} | ||
} |
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,10 @@ | ||
import { env } from "@dotkomonline/env" | ||
import { createProxyRoute } from "@dotkomonline/proxy-nextjs" | ||
|
||
const handler = createProxyRoute({ | ||
mountPath: "/api/trpc", | ||
apiEndpoint: env.RPC_HOST, | ||
}) | ||
|
||
export const GET = handler | ||
export const POST = handler |
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
Oops, something went wrong.