Skip to content

Commit

Permalink
feat(repo): add .env and DEMO_APP property
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcnk committed Aug 11, 2024
1 parent 8262975 commit d0e27cf
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 3 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DEMO_APP=false
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.env
dist/
tmp/

Expand Down
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"name": "faasade",
"type": "module",
"private": true,
"scripts": {
"build": "tsup-node src/index.ts",
"build": "tsc --noEmit && tsup-node src/index.ts",
"start": "node dist/index.js",
"dev": "tsx watch src/index.ts",
"test": "vitest",
Expand All @@ -13,6 +14,7 @@
"dependencies": {
"@hono/node-server": "1.12.0",
"@open-draft/until": "2.1.0",
"dotenv": "16.4.5",
"esbuild": "0.23.0",
"hono": "4.5.4",
"ofetch": "1.3.4",
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import "dotenv/config";
import { serve } from "@hono/node-server";
import { Hono } from "hono";
import { logger } from "hono/logger";
Expand Down
11 changes: 11 additions & 0 deletions src/routers/gist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,20 @@ const __dirname = getDirname();

export const gistRouter = new Hono();

// biome-ignore lint/complexity/useLiteralKeys: Biome clashes with tsc
const DEMO_APP = process.env?.["DEMO_APP"] === "true";

gistRouter.all("/gist/:gistId/:fileName", async ({ req, json, html }) => {
const gistId = req.param("gistId");
const fileName = req.param("fileName");
if (DEMO_APP && gistId !== "f5b0305f5ded7987a4b6da15f5e35c3c") {
return html(
getErrorHtml({
error: new Error("Demo app only allows a specific gist."),
req,
}),
);
}
const { data: gistData, error: gistFetchError } = await until(() =>
fetchGist(gistId),
);
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"jsx": "react-jsx",
"jsxImportSource": "hono/jsx",
"types": ["vitest/globals"]
}
},
"exclude": ["dist", "node_modules"]
}
1 change: 0 additions & 1 deletion vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { vi } from "vitest";
import { defineConfig } from "vitest/config";

export default defineConfig({
Expand Down

0 comments on commit d0e27cf

Please sign in to comment.