Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

✨ Bootstrap apps/api with Hono and @hono/node-server (RAL-1173) (#2367)

Luke Vella756b48ff6a90
diff --git a/apps/api/.gitignore b/apps/api/.gitignore
new file mode 100644
index 000000000..849ddff3b
--- /dev/null
+++ b/apps/api/.gitignore
@@ -0,0 +1 @@
+dist/
diff --git a/apps/api/package.json b/apps/api/package.json
new file mode 100644
index 000000000..e28301209
--- /dev/null
+++ b/apps/api/package.json
@@ -0,0 +1,32 @@
+{
+ "name": "@rallly/api",
+ "version": "0.0.0",
+ "private": true,
+ "main": "dist/index.js",
+ "scripts": {
+ "dev": "portless api.local.rallly tsx watch src/index.ts",
+ "build": "tsc",
+ "start": "node dist/index.js",
+ "type-check": "tsc --noEmit"
+ },
+ "dependencies": {
+ "@hono-rate-limiter/redis": "^0.1.4",
+ "@hono/node-server": "^1.19.9",
+ "@hono/zod-openapi": "^1.2.0",
+ "@rallly/api-core": "workspace:*",
+ "@rallly/database": "workspace:*",
+ "@rallly/logger": "workspace:*",
+ "@rallly/utils": "workspace:*",
+ "@scalar/hono-api-reference": "^0.9.30",
+ "@upstash/redis": "^1.36.2",
+ "hono": "^4.11.1",
+ "hono-openapi": "^1.1.2",
+ "hono-rate-limiter": "^0.2.1"
+ },
+ "devDependencies": {
+ "@rallly/tsconfig": "workspace:*",
+ "@types/node": "^24.1.0",
+ "tsx": "^4.6.2",
+ "typescript": "^5.8.2"
+ }
+}
diff --git a/apps/api/src/app.ts b/apps/api/src/app.ts
new file mode 100644
index 000000000..cf0ccb0ad
--- /dev/null
+++ b/apps/api/src/app.ts
@@ -0,0 +1,28 @@
+import { Scalar } from "@scalar/hono-api-reference";
+import { Hono } from "hono";
+import { openAPIRouteHandler } from "hono-openapi";
+
+export const app = new Hono();
+
+app.get("/health", (c) => c.json({ ok: true }));
+
+app.get(
+ "/openapi",
+ openAPIRouteHandler(app, {
+ documentation: {
+ info: {
+ title: "Rallly API",
+ version: "0.0.1",
+ },
+ },
+ }),
+);
+
+app.get(
+ "/docs",
+ Scalar({
+ url: "/openapi",
+ pageTitle: "Rallly API Documentation",
+ theme: "purple",
+ }),
+);
diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts
new file mode 100644
index 000000000..95e8c0bf8
--- /dev/null
+++ b/apps/api/src/index.ts
@@ -0,0 +1,4 @@
+import { serve } from "@hono/node-server";
+import { app } from "./app";
+
+serve({ fetch: app.fetch, port: Number(process.env.PORT ?? 4000) });
diff --git a/apps/api/src/lib/redis.ts b/apps/api/src/lib/redis.ts
new file mode 100644
index 000000000..0772c2b9c
--- /dev/null
+++ b/apps/api/src/lib/redis.ts
@@ -0,0 +1,25 @@
+import { createLogger } from "@rallly/logger";
+import { Redis } from "@upstash/redis";
+
+const logger = createLogger("api/lib/redis");
+
+function createRedis() {
+ if (!process.env.KV_REST_API_URL || !process.env.KV_REST_API_TOKEN) {
+ return null;
+ }
+
+ try {
+ return new Redis({
+ url: process.env.KV_REST_API_URL,
+ token: process.env.KV_REST_API_TOKEN,
+ });
+ } catch (error) {
+ logger.error(
+ { error },
+ "Redis has been configured but failed to initialize Redis client",
+ );
+ return null;
+ }
+}
+
+export const redis = createRedis();
diff --git a/apps/api/tsconfig.json b/apps/api/tsconfig.json
new file mode 100644
index 000000000..8c563dfca
--- /dev/null
+++ b/apps/api/tsconfig.json
@@ -0,0 +1,11 @@
+{
+ "extends": "@rallly/tsconfig/node.json",
+ "compilerOptions": {
+ "lib": ["es2023"],
+ "target": "es2023",
+ "types": ["node"],
+ "outDir": "dist",
+ "rootDir": "src"
+ },
+ "include": ["src/**/*"]
+}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 4c40c1def..bb40b33dc 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -42,6 +42,58 @@ importers:
specifier: ^4.0.16
+ apps/api:
+ dependencies:
+ '@hono-rate-limiter/redis':
+ specifier: ^0.1.4
+ '@hono/node-server':
+ specifier: ^1.19.9
+ version: 1.19.9([email protected])
+ '@hono/zod-openapi':
+ specifier: ^1.2.0
+ '@rallly/api-core':
+ specifier: workspace:*
+ version: link:../../packages/api-core
+ '@rallly/database':
+ specifier: workspace:*
+ version: link:../../packages/database
+ '@rallly/logger':
+ specifier: workspace:*
+ version: link:../../packages/logger
+ '@rallly/utils':
+ specifier: workspace:*
+ version: link:../../packages/utils
+ '@scalar/hono-api-reference':
+ specifier: ^0.9.30
+ version: 0.9.40([email protected])
+ '@upstash/redis':
+ specifier: ^1.36.2
+ version: 1.36.2
+ hono:
+ specifier: ^4.11.1
+ version: 4.11.7
+ hono-openapi:
+ specifier: ^1.1.2
+ hono-rate-limiter:
+ specifier: ^0.2.1
+ version: 0.2.3([email protected])
+ devDependencies:
+ '@rallly/tsconfig':
+ specifier: workspace:*
+ version: link:../../packages/tsconfig
+ '@types/node':
+ specifier: ^24.1.0
+ version: 24.10.11
+ tsx:
+ specifier: ^4.6.2
+ version: 4.21.0
+ typescript:
+ specifier: ^5.8.2
+ version: 5.9.3
+
apps/docs:
dependencies:
mint:
@@ -92,7 +144,7 @@ importers:
version: 8.1.0([email protected])
'@vercel/analytics':
specifier: ^1.5.0
dayjs:
specifier: ^1.11.13
version: 1.11.19
@@ -131,7 +183,7 @@ importers:
version: 6.0.0(@types/[email protected])([email protected])
next-seo:
specifier: ^6.1.0
pg:
specifier: ^8.17.1
version: 8.18.0
@@ -13201,6 +13253,10 @@ snapshots:
dependencies:
hono: 4.11.4
+ dependencies:
+ hono: 4.11.7
+
dependencies:
'@standard-schema/spec': 1.1.0
@@ -17835,7 +17891,7 @@ snapshots:
dependencies:
uncrypto: 0.1.3
optionalDependencies:
react: 19.2.4
@@ -21607,7 +21663,7 @@ snapshots:
react: 19.2.4
react-dom: 19.2.4([email protected])
dependencies:
react: 19.2.4