diff --git a/bun.lockb b/bun.lockb index 14e10ee..7b5de1b 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 4d78696..cc0bdd0 100644 --- a/package.json +++ b/package.json @@ -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 ." }, @@ -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" diff --git a/scripts/serve.ts b/scripts/serve.ts new file mode 100644 index 0000000..fbeb1f2 --- /dev/null +++ b/scripts/serve.ts @@ -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 }); + } + }, +}); diff --git a/tsconfig.json b/tsconfig.json index cc4ceda..35883c8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,6 +6,7 @@ "preserveConstEnums": true, "sourceMap": true, "esModuleInterop": true, + "types": ["bun-types"], "paths": { "🛠️": ["./helpers/index.ts"], "⌨️": ["./types/index.ts"]