From 40a1e7b4796485f940c6e1c1a7e31cf43b5a7bc4 Mon Sep 17 00:00:00 2001 From: Kat Michaela Date: Mon, 18 Sep 2023 16:06:49 -0400 Subject: [PATCH] chore: add dev server --- README.md | 15 +++++++++++++++ dist/src/server.d.ts | 1 + package.json | 1 + src/server.ts | 12 ++++++++++++ 4 files changed, 29 insertions(+) create mode 100644 dist/src/server.d.ts create mode 100644 src/server.ts diff --git a/README.md b/README.md index 5f3157d..4e27a5b 100644 --- a/README.md +++ b/README.md @@ -14,3 +14,18 @@ We use [bun](https://bun.sh/) as a package manager and runtime. Ensure it is fir bun install ``` +**To run the dev server, you will need a `BUNGIE_API_KEY` in your `.env`** + +Then, run + +```bash +bun run dev +``` + +## Building + +To build the package for production, run + +```bash +bun run build +``` diff --git a/dist/src/server.d.ts b/dist/src/server.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/dist/src/server.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/package.json b/package.json index 5bbf52f..eebfe7d 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "main": "./dist/index.js", "typings": "./dist/index.d.ts", "scripts": { + "dev": "bun run ./src/server.ts", "build": "tsc && bun build ./src/index.ts --outdir ./dist --target browser --minify", "lint": "bunx eslint && bun run prettier-format", "prettier-format": "prettier --config .prettierrc 'src/**/*.{ts,js}' --write" diff --git a/src/server.ts b/src/server.ts new file mode 100644 index 0000000..0e770c7 --- /dev/null +++ b/src/server.ts @@ -0,0 +1,12 @@ +import { getSearchDbFromDestinyApi } from "@/"; + +const server = Bun.serve({ + port: 3000, + async fetch(_) { + const res = await getSearchDbFromDestinyApi(); + const sliced = res.slice(0, 4); + return new Response(JSON.stringify(sliced)); + }, +}); + +console.log(`Listening on localhost: ${server.port}`);