MCPcopy Index your code
hub / github.com/DarthBenro008/melonpan

github.com/DarthBenro008/melonpan @0.1.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release 0.1.1 ↗ · + Follow
66 symbols 143 edges 17 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

banner release GitHub License PRs Welcome PRs Welcome

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

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

Results

benchmark

Almost an 8x performance, thanks to Bun.

You can find the benchmark suite here

⬇️ Installation

Using Bun

  1. Install Bun
curl https://bun.sh/install | bash
  1. Add Melonpan as dependency using bun
bun add melonpan

Using Yarn

yarn add melonpan

Using NPM

npm install melonpan

🤝 Contributions

  • Feel Free to Open a PR/Issue for any feature or bug(s).
  • Make sure you follow the 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 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

Extension points exported contracts — how you extend this code

IMelonContext (Interface)
(no doc) [2 implementers]
lib/context.ts
RouterEngineInterface (Interface)
(no doc) [2 implementers]
lib/router.ts
MelonpanOptions (Interface)
(no doc)
lib/melopan.ts
MelonQueryParams (Interface)
(no doc)
lib/path_utilities.ts
Data (Interface)
(no doc)
test/helper.ts
IMelonResponseOptions (Interface)
(no doc)
lib/context.ts

Core symbols most depended-on inside this repo

serve
called by 21
lib/melopan.ts
get
called by 20
lib/router.ts
text
called by 16
lib/context.ts
use
called by 14
lib/melopan.ts
json
called by 9
lib/context.ts
log
called by 8
lib/logger.ts
executeMiddlewares
called by 4
lib/melopan.ts
middleware
called by 4
lib/router.ts

Shape

Method 42
Class 12
Interface 6
Function 5
Enum 1

Languages

TypeScript100%

Modules by API surface

lib/router.ts16 symbols
lib/path_utilities.ts12 symbols
lib/melopan.ts12 symbols
lib/context.ts8 symbols
lib/routerHelper.ts6 symbols
lib/logger.ts5 symbols
bench/cannon.mjs4 symbols
test/helper.ts1 symbols
lib/types.ts1 symbols
bench/melon.ts1 symbols

For agents

$ claude mcp add melonpan \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact