Skip to content

Commit

Permalink
add SQLITE_FILENAME
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisCarriere committed Oct 2, 2023
1 parent f987757 commit 2fc1db6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
PORT=3000
PUBLIC_KEY=a3cb7366ee8ca77225b4d41772e270e4e831d171d1de71d91707c42e7ba82cc9
PUBLIC_KEY=a3cb7366ee8ca77225b4d41772e270e4e831d171d1de71d91707c42e7ba82cc9
SQLITE_FILENAME=db.sqlite
5 changes: 3 additions & 2 deletions 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 { HOSTNAME, PORT, PUBLIC_KEY } from "./src/config.js";
import { HOSTNAME, PORT, PUBLIC_KEY, SQLITE_FILENAME } 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 @@ -9,9 +9,10 @@ import { checkHealth } from "./src/health.js";
import { toJSON } from "./src/http.js";
console.log(`Server listening on http://${HOSTNAME || "0.0.0.0"}:${PORT}`);
console.log("Verifying with PUBLIC_KEY", PUBLIC_KEY);
console.log("Reading SQLITE_FILENAME", SQLITE_FILENAME);

// Create SQLite DB
const db = new Database("./sqlite/db.sqlite", {create: true}); // TO-DO as .env variable
const db = new Database(SQLITE_FILENAME, {create: true}); // TO-DO as .env variable
sqlite.create(db, "moduleHash");
sqlite.create(db, "traceId");

Expand Down
3 changes: 2 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,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 HOSTNAME = process.env.HOSTNAME || "";
export const HOSTNAME = process.env.HOSTNAME || "";
export const SQLITE_FILENAME = process.env.SQLITE_FILENAME || "db.sqlite";

0 comments on commit 2fc1db6

Please sign in to comment.