diff --git a/cloud/packages/functions/package.json b/cloud/packages/functions/package.json index 1f9a2785..54d3fbec 100644 --- a/cloud/packages/functions/package.json +++ b/cloud/packages/functions/package.json @@ -16,6 +16,7 @@ "dependencies": { "@actor-core/bun": "^0.8.0", "@actor-core/file-system": "^0.8.0", + "@openauthjs/openauth": "catalog:", "@aws-sdk/client-lambda": "^3.821.0", "@aws-sdk/client-s3": "^3.806.0", "@aws-sdk/client-sqs": "^3.806.0", @@ -27,4 +28,4 @@ "steamcommunity": "^3.48.6", "steamid": "^2.1.0" } -} \ No newline at end of file +} diff --git a/cloud/packages/functions/src/api/index.ts b/cloud/packages/functions/src/api/index.ts index 904f7089..8d9a1d19 100644 --- a/cloud/packages/functions/src/api/index.ts +++ b/cloud/packages/functions/src/api/index.ts @@ -9,88 +9,88 @@ import { AccountApi } from "./account"; import { openAPISpecs } from "hono-openapi"; import { patchLogger } from "../utils/patch-logger"; import { HTTPException } from "hono/http-exception"; -import { handle, streamHandle } from "hono/aws-lambda"; import { ErrorCodes, VisibleError } from "@nestri/core/error"; patchLogger(); export const app = new Hono(); app - .use(logger()) - .use(async (c, next) => { - c.header("Cache-Control", "no-store"); - return next(); - }) - .use(auth) + .use(logger()) + .use(async (c, next) => { + c.header("Cache-Control", "no-store"); + return next(); + }) + .use(auth); const routes = app - .get("/", (c) => c.text("Hello World!")) - .route("/games", GameApi.route) - .route("/steam", SteamApi.route) - .route("/friends", FriendApi.route) - .route("/account", AccountApi.route) - .onError((error, c) => { - if (error instanceof VisibleError) { - console.error("api error:", error); - // @ts-expect-error - return c.json(error.toResponse(), error.statusCode()); - } - // Handle HTTP exceptions - if (error instanceof HTTPException) { - console.error("http error:", error); - return c.json( - { - type: "validation", - code: ErrorCodes.Validation.INVALID_PARAMETER, - message: "Invalid request", - }, - error.status, - ); - } - console.error("unhandled error:", error); - return c.json( - { - type: "internal", - code: ErrorCodes.Server.INTERNAL_ERROR, - message: "Internal server error", - }, - 500, - ); - }); + .get("/", (c) => c.text("Hello World!")) + .route("/games", GameApi.route) + .route("/steam", SteamApi.route) + .route("/friends", FriendApi.route) + .route("/account", AccountApi.route) + .onError((error, c) => { + if (error instanceof VisibleError) { + console.error("api error:", error); + // @ts-expect-error + return c.json(error.toResponse(), error.statusCode()); + } + // Handle HTTP exceptions + if (error instanceof HTTPException) { + console.error("http error:", error); + return c.json( + { + type: "validation", + code: ErrorCodes.Validation.INVALID_PARAMETER, + message: "Invalid request", + }, + error.status, + ); + } + console.error("unhandled error:", error); + return c.json( + { + type: "internal", + code: ErrorCodes.Server.INTERNAL_ERROR, + message: "Internal server error", + }, + 500, + ); + }); app.get( - "/doc", - openAPISpecs(routes, { - documentation: { - info: { - title: "Nestri API", - description: "The Nestri API gives you the power to run your own customized cloud gaming platform.", - version: "0.0.1", - }, - components: { - securitySchemes: { - Bearer: { - type: "http", - scheme: "bearer", - bearerFormat: "JWT", - }, - TeamID: { - type: "apiKey", - description: "The steam ID to use for this query", - in: "header", - name: "x-nestri-steam" - }, - }, - }, - security: [{ Bearer: [], TeamID: [] }], - servers: [ - { description: "Production", url: "https://api.nestri.io" }, - { description: "Sandbox", url: "https://api.dev.nestri.io" }, - ], + "/doc", + openAPISpecs(routes, { + documentation: { + info: { + title: "Nestri API", + description: + "The Nestri API gives you the power to run your own customized cloud gaming platform.", + version: "0.0.1", + }, + components: { + securitySchemes: { + Bearer: { + type: "http", + scheme: "bearer", + bearerFormat: "JWT", + }, + SteamID: { + type: "apiKey", + description: "The steam ID to use for this query", + in: "header", + name: "x-nestri-steam", + }, }, - }), + }, + security: [{ Bearer: [], TeamID: [] }], + servers: [ + { description: "Production", url: "https://api.nestri.io" }, + { description: "Sandbox", url: "https://api.dev.nestri.io" }, + ], + }, + }), ); export type Routes = typeof routes; -export const handler = process.env.SST_LIVE ? handle(app) : streamHandle(app); \ No newline at end of file +export default app; diff --git a/package.json b/package.json index a4f9211f..d889626a 100644 --- a/package.json +++ b/package.json @@ -17,21 +17,23 @@ "format": "prettier --write \"**/*.{ts,tsx,md}\"", "sso": "aws sso login --sso-session=nestri --no-browser --use-device-code" }, - "overrides": { - "@openauthjs/openauth": "0.4.3", - "steam-session": "1.9.3" - }, "trustedDependencies": [ "core-js-pure", "esbuild", "protobufjs", "workerd" ], - "workspaces": [ - "apps/*", - "packages/*", - "cloud/packages/*" - ], + "workspaces": { + "packages": [ + "apps/*", + "packages/*", + "cloud/packages/*" + ], + "catalog": { + "@openauthjs/openauth": "0.0.0-20250322224806", + "steam-session": "1.9.3" + } + }, "dependencies": { "sst": "^3.17.13" }