Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added local server for changes testing #33

Merged
merged 3 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified bun.lockb
Binary file not shown.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "",
"scripts": {
"dle": "rimraf dist; bun ./index.ts",
"watch": "concurrently \"bun --watch ./index.ts;\" \"bun ./scripts/serve.ts\"",
"lint": "eslint --ext .ts .",
"lint:fix": "eslint --fix --ext .ts ."
},
Expand All @@ -21,8 +22,12 @@
"@types/node": "^20.5.9",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"bun": "^1.0.2",
"bun-types": "^1.0.2",
"concurrently": "^8.2.1",
"eslint": "^8.1.0",
"eslint-plugin-sort-imports-es6-autofix": "^0.6.0",
"http-server": "^14.1.1",
"kleur": "^4.1.5",
"rimraf": "^5.0.1",
"typescript": "^5.2.2"
Expand Down
31 changes: 31 additions & 0 deletions scripts/serve.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { constants } from "../helpers/constants";
import { file, serve } from "bun";
import { getConfigMainModules } from "../helpers/get-config-main-modules";

getConfigMainModules().then((modules) => {
console.log("Available configs:");
const { environments } = constants;
modules.forEach((module) => {
environments.forEach((env) => {
console.log(`http://localhost:8080/${module}/${module}-${env}.json`);
});
});
});

serve({
port: 8080,
fetch(req) {
const url = new URL(req.url);
const path = url.pathname;
if (!path.includes("json")) {
return;
}
try {
const fileData = file(`./dist/${path}`);
return new Response(fileData);
} catch (error) {
console.error(error);
return new Response("File not found", { status: 404 });
}
},
});
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"preserveConstEnums": true,
"sourceMap": true,
"esModuleInterop": true,
"types": ["bun-types"],
"paths": {
"🛠️": ["./helpers/index.ts"],
"⌨️": ["./types/index.ts"]
Expand Down
Loading