Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

vyder/bunbox

Repository files navigation

Bun Box

Installation

  1. Install bun & create a new project
❯ mkdir bunbox-example && cd bunbox-example
❯ bun init
# work through prompts
❯ bun install
  1. Install bunbox
❯ bun add bunbox

Usage

My goal with this project is to hideaway as much of the boiler plate import crud as I can, following in the footsteps of frameworks like Rails.

By default, this is the directory structure bunbox expects:

|
|- index.ts
|- controllers/
 |- hello.ts
  1. Create a controller:
// controllers/hello.ts
import { Controller } from "bunbox"
import type { Context } from "bunbox"
class HelloController implements Controller {
 route: string
 method: string
 constructor() {
 this.method = "GET"
 this.route = "/hello"
 }
 run = (c: Context) => c.text("Hello!")
}
export default HelloController

or in vanilla JavaScript:

// controllers/hello.js
class HelloController {
 constructor() {
 this.method = "GET"
 this.route = "/hello"
 }
 run = c => c.text("Hello")
}
  1. Update your index.ts:
import BunBox from "bunbox"
const box = new BunBox()
box.serve()
  1. Run with bun run index.ts:
❯ curl localhost:3000/hello
Hello!

About

A framework to build APIs with bun

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

AltStyle によって変換されたページ (->オリジナル) /