From 8b296dd8306f1963c252ab732ac7cc72db5d78df Mon Sep 17 00:00:00 2001 From: Tomek Marciniak Date: Sun, 8 Sep 2024 23:30:51 +0200 Subject: [PATCH] feat(klesia): add port override --- apps/klesia/.env.example | 1 + apps/klesia/src/index.ts | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/klesia/.env.example b/apps/klesia/.env.example index bfbef12..0a39e19 100644 --- a/apps/klesia/.env.example +++ b/apps/klesia/.env.example @@ -1,3 +1,4 @@ +PORT=3000 MINA_NETWORK=devnet NODE_API_DEVNET=https://api.minascan.io/node/devnet/v1/graphql NODE_API_MAINNET=https://api.minascan.io/node/mainnet/v1/graphql diff --git a/apps/klesia/src/index.ts b/apps/klesia/src/index.ts index 7c95eb2..91cf9ec 100644 --- a/apps/klesia/src/index.ts +++ b/apps/klesia/src/index.ts @@ -1,7 +1,7 @@ import "dotenv/config"; import { serve } from "@hono/node-server"; import { getConnInfo } from "@hono/node-server/conninfo"; -import { OpenAPIHono, createRoute } from "@hono/zod-openapi"; +import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi"; import { PublicKeySchema } from "@mina-js/shared"; import { rateLimiter } from "hono-rate-limiter"; import { cors } from "hono/cors"; @@ -142,7 +142,12 @@ export const klesiaRpcRoute = api.openapi(rpcRoute, async ({ req, json }) => { .exhaustive(); }); -serve(api); +serve( + { fetch: api.fetch, port: z.coerce.number().parse(process.env.PORT ?? 3000) }, + (info) => { + console.log(`Listening on http://localhost:${info.port}`); + }, +); export type KlesiaRpc = typeof klesiaRpcRoute; export {