Skip to content

Commit d08b618

Browse files
committed
Merge pull-request #18
2 parents aa316fc + 990cddd commit d08b618

File tree

164 files changed

+38323
-8028
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

164 files changed

+38323
-8028
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@ xcuserdata/
2020
.netrc
2121
.env
2222
.ai/
23+
24+
node_modules/
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
PORT="3000"
2+
3+
TURNKEY_API_URL="https://api.turnkey.com"
4+
TURNKEY_ORGANIZATION_ID="<your_turnkey_organization_id>"
5+
6+
TURNKEY_API_PUBLIC_KEY="<your_turnkey_api_public_key>"
7+
TURNKEY_API_PRIVATE_KEY="<your_turnkey_api_private_key>"
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import express, { Request, Response } from "express";
2+
import cors from "cors";
3+
import dotenv from "dotenv";
4+
import bodyParser from "body-parser";
5+
import {
6+
getSubOrgId,
7+
sendOtp,
8+
verifyOtp,
9+
createSubOrg,
10+
} from "./src/handler.js";
11+
12+
dotenv.config();
13+
14+
const app = express();
15+
const PORT = process.env.PORT || 3000;
16+
17+
// Middleware
18+
app.use(cors());
19+
app.use(bodyParser.json());
20+
21+
async function handleRequest<T>(
22+
req: Request,
23+
res: Response<T>,
24+
handler: (req: Request) => Promise<T>,
25+
) {
26+
try {
27+
const result = await handler(req);
28+
res.json(result);
29+
} catch (error: any) {
30+
console.error("Server error:", error.message);
31+
res.status(500).json({ error: error.message } as any);
32+
}
33+
}
34+
35+
app.post("/auth/getSubOrgId", (req, res) =>
36+
handleRequest(req, res, getSubOrgId),
37+
);
38+
app.post("/auth/sendOtp", (req, res) =>
39+
handleRequest(req, res, sendOtp),
40+
);
41+
app.post("/auth/verifyOtp", (req, res) => handleRequest(req, res, verifyOtp));
42+
app.post("/auth/createSubOrg", (req, res) =>
43+
handleRequest(req, res, createSubOrg),
44+
);
45+
46+
app.listen(PORT, () =>
47+
console.log(`✅ Server running on http://localhost:${PORT}`),
48+
);

0 commit comments

Comments
 (0)