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

chore: add dev server #16

Merged
merged 1 commit 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
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
1 change: 1 addition & 0 deletions dist/src/server.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 12 additions & 0 deletions src/server.ts
Original file line number Diff line number Diff line change
@@ -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}`);