https://github.com/darthbenro008/melonpan
⚡️A minimalistic and sweet router for blazing fast bun
https://github.com/darthbenro008/melonpan
bun hacktoberfest hacktoberfest2022 router typescript
Last synced: about 1 year ago
JSON representation
⚡️A minimalistic and sweet router for blazing fast bun
- Host: GitHub
- URL: https://github.com/darthbenro008/melonpan
- Owner: DarthBenro008
- License: mit
- Created: 2022-07-14T13:29:25.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-10-18T19:50:14.000Z (over 3 years ago)
- Last Synced: 2025-04-06T23:34:05.023Z (about 1 year ago)
- Topics: bun, hacktoberfest, hacktoberfest2022, router, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/melonpan
- Size: 432 KB
- Stars: 72
- Watchers: 3
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README


[](https://github.com/DarthBenro008/melonpan/blob/master/LICENSE)
[](https://www.npmjs.com/package/melonpan)
[](https://github.com/DarthBenro008/melonpan/issues/new/choose)
Melonpan is a simple and minimalistic web-router designed to work with Bun, keeping performance in mind.
## 🤔 Why Melonpan?
- **no/minimal** learning curve
- **Developer focused**, you just need to focus on buisness logic
- **0 bloat functions**
- **0 dependencies**
- **100% Typescript code**
- Blazing fast performance than node webframework alternatives
## ⚡️ Quickstart
```typescript
import { Melonpan, MelonRouter } from "melonpan";
const melonpan = new Melonpan();
// Simple middleware definitions
melonpan.middleware((_req, ctx, next) => {
console.log("A middleware has been hit!")
})
// Easy query params parsing!
melonpan.get("/api/:id", (_req, ctx) => {
return ctx.json({"id": ctx.params.id}, 200);
})
// Routing done in very simple manner
melonpan.get("/" , (_req, ctx) => ctx.text("Hello world!"));
// Easy definitions of routers and handlers!
const melonRouter = new MelonRouter();
melonRouter.get("/bar", (_req, ctx) => ctx.text("this is a router", 200));
melonpan.use("/foo", melonRouter);
export default {
port: 3000,
fetch(req: Request){
return melonpan.serve(req);
}
}
```
## 🤖 Benchmarks
The following results are of:
- **Test:** Bun `(v0.1.11)` + Melonpan `(v0.1.0)` **Vs** NodeJS `(v16.13.0)` + Express `(v4.18.1)`
- **Machine:** MacBook M1 Pro 16GB RAM
- **Benchmarking tool used:** [Autocannon](https://github.com/mcollina/autocannon)
### Results

> **Almost an 8x performance, thanks to Bun.**
You can find the [benchmark suite here](https://github.com/DarthBenro008/melonpan/tree/main/bench)
## ⬇️ Installation
### Using Bun
1. Install Bun
```bash
curl https://bun.sh/install | bash
```
2. Add Melonpan as dependency using bun
```bash
bun add melonpan
```
### Using Yarn
```bash
yarn add melonpan
```
### Using NPM
```bash
npm install melonpan
```
## 🤝 Contributions
- Feel Free to Open a PR/Issue for any feature or bug(s).
- Make sure you follow the [community guidelines](https://docs.github.com/en/github/site-policy/github-community-guidelines).
- Feel free to open an issue to ask a question/discuss anything about melonpan.
- Have a feature request? Open an Issue!
- Please ensure to run `bun test` before submitting your PRs!
### 📢 Shoutouts
Shoutout to [Khyati Gupta](https://www.behance.net/khyatigupta267) for amazing logo and banner illustrations
## ⚖ License
Copyright 2022 Hemanth Krishna
Licensed under MIT License : https://opensource.org/licenses/MIT
Made with ❤ , multiple cups of coffee and some chaii