Skip to content

Commit

Permalink
add hostname
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisCarriere committed Sep 30, 2023
1 parent 5d306e0 commit 66aa490
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Server } from "bun";
import { Database } from "bun:sqlite";
import { PORT, PUBLIC_KEY } from "./src/config.js";
import { HOSTNAME, PORT, PUBLIC_KEY } from "./src/config.js";
import { verify } from "./src/verify.js";
import { banner } from "./src/banner.js";
import * as sqlite from "./src/sqlite.js";
Expand All @@ -19,6 +19,7 @@ sqlite.create(db, "traceId");

Bun.serve<{key: string}>({
port: PORT,
hostname: HOSTNAME,
async fetch(req: Request, server: Server) {
// Bun automatically returns a 101 Switching Protocols
// if the upgrade succeeds
Expand Down
3 changes: 2 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ import "dotenv/config";

if (!process.env.PUBLIC_KEY) throw new Error("PUBLIC_KEY is required");
export const PUBLIC_KEY = process.env.PUBLIC_KEY;
export const PORT = parseInt(process.env.PORT || "3000");
export const PORT = parseInt(process.env.PORT || "3000");
export const HOSTNAME = process.env.HOSTNAME || "localhost";

0 comments on commit 66aa490

Please sign in to comment.