Now Particularly Misnamed

    @y0x54a/bunda
    TypeScript icon, indicating that this package has built-in type declarations

    0.1.0 • Public • Published

    Bunda

    NPM Version CI

    Bunda (Mother) - A lightweight web framework for the Bun javascript runtime.

    Installing

    bun add @y0x54a/bunda

    Example

    import {Bunda} from "@y0x54a/bunda";
    
    const app = await Bunda.serve();
    
    app.router.get("/", ctx => ctx.text("Hi!"));

    Using StackRouter

    import {Bunda, StackRouter} from "@y0x54a/bunda";
    
    const app = await Bunda.serve({
      services: {
        router: Bunda.classService(StackRouter)
      }
    });
    
    app.router.use(ctx => ctx.text("Hi!"));

    Using PathnameRouter

    import {Bunda, PathnameRouter} from "@y0x54a/bunda";
    
    const app = await Bunda.serve({
      services: {
        router: Bunda.classService(PathnameRouter)
      }
    });
    
    app.router.use((ctx, next) => next(ctx));
    
    app.router.get("/", ctx => ctx.text("Hi!"), [(ctx, next) => next(ctx)]);
    
    app.router.get("/ping", ctx => ctx.text("Pong!"));

    Using FetchHandler

    import {Bunda, FetchHandler} from "@y0x54a/bunda";
    
    const app = await Bunda.serve({
      services: {
        fetchHandler: Bunda.rawService(new FetchHandler({status: 403, message: "Forbidden"}))
      }
    });
    
    app.router.get("/ping", ctx => ctx.text("Pong!"));

    Using ErrorHandler

    import {Bunda, ErrorHandler} from "@y0x54a/bunda";
    
    const app = await Bunda.serve({
      services: {
        errorHandler: Bunda.rawService(new ErrorHandler({message: "Please see your server logs!"}))
      }
    });
    
    app.router.get("/", () => Promise.reject(new Error()));

    API

    • Bunda

      • Props

      • router

      • fetchHandler

      • errorHandler

      • isServed

      • isDevelopment

      • names

      • services

      • Methods

      • constructor({services?})

      • serve()

      • stop()

      • has(name)

      • get(name)

      • getIf(name)

      • raw(name, value)

      • rawIf(name, value)

      • class(name, value)

      • classIf(name, value)

      • factory(name, value)

      • factoryIf(name, value)

      • register(name, service)

      • registers(services)

      • registerIf(name, service)

      • registersIf(services)

      • unregister(name)

      • unregisters(names)

      • unregisterIf(name)

      • unregistersIf(names)

      • resolve(name, args?)

      • resolveIf(name, args?, retval?)

      • create(name, args?)

      • createIf(name, args?, retval?)

      • Static Methods

      • create({services?})

      • serve({services?})

      • rawService(value)

      • classService(value)

      • factoryService(value)

    • Context

      • Props

      • container

      • request

      • state

      • url

      • method

      • headers

      • path

      • pathname

      • query

      • queryParams

      • search

      • searchParams

      • Methods

      • constructor({container, request, state?})

      • redirect(url, status?, headers?, options?)

      • response(body, status?, headers?, options?)

      • json(json, status?, headers?, options?)

      • text(text, status?, headers?, options?)

      • html(html, status?, headers?, options?)

    • Errinfo

      • Props

      • code

      • error

      • context?

      • Methods

      • constructor({code, error, context?})

      • Static Props

      • FETCH

      • ERROR

      • Static Methods

      • fetch(error, context)

      • error(error)

    • Url

      • Props

      • scheme

      • protocol

      • username

      • password

      • host

      • hostname

      • port

      • path

      • pathname

      • query

      • queryParams

      • search

      • searchParams

      • hash

      • fragment

      • origin

      • href

      • Methods

      • constructor(url, base?)

      • toString()

      • toJSON()

    • Container

      • Props

      • names

      • services

      • Methods

      • constructor(services?)

      • has(name)

      • get(name)

      • getIf(name)

      • raw(name, value)

      • rawIf(name, value)

      • class(name, value)

      • classIf(name, value)

      • factory(name, value)

      • factoryIf(name, value)

      • register(name, service)

      • registers(services)

      • registerIf(name, service)

      • registersIf(services)

      • unregister(name)

      • unregisters(names)

      • unregisterIf(name)

      • unregistersIf(names)

      • resolve(name, args?)

      • resolveIf(name, args?, retval?)

      • create(name, args?)

      • createIf(name, args?, retval?)

      • Static Methods

      • rawService(value)

      • classService(value)

      • factoryService(value)

    • Service

      • Props

      • value

      • exports

      • isResolved

      • Methods

      • constructor(value)

      • resolve(args?)

      • create(args?)

    • RawService

      • Props

      • value

      • exports

      • isResolved

      • Methods

      • constructor(value)

      • resolve(args?)

      • create(args?)

    • ClassService

      • Props

      • value

      • exports

      • isResolved

      • Methods

      • constructor(value)

      • resolve(args?)

      • create(args?)

    • FactoryService

      • Props

      • value

      • exports

      • isResolved

      • Methods

      • constructor(value)

      • resolve(args?)

      • create(args?)

    • FetchHandler

      • Props

      • status

      • message

      • Methods

      • constructor({status?, message?})

      • handle(context)

    • ErrorHandler

      • Props

      • status

      • message

      • fallback

      • Methods

      • constructor({status?, message?, fallback?})

      • handle(errinfo)

    • StackRouter

      • Props

      • length

      • factories

      • Methods

      • constructor(factories?)

      • use(factory)

      • uses(factories)

      • unuse(factory)

      • unuses(factories)

      • handle(context, next)

    • PathnameRouter

      • Props

      • path

      • routes

      • middleware

      • Methods

      • constructor({path?, routes?, middleware?})

      • use(factory)

      • uses(factories)

      • unuse(factory)

      • unuses(factories)

      • get(path, factory, middleware?)

      • head(path, factory, middleware?)

      • post(path, factory, middleware?)

      • put(path, factory, middleware?)

      • delete(path, factory, middleware?)

      • connect(path, factory, middleware?)

      • options(path, factory, middleware?)

      • trace(path, factory, middleware?)

      • patch(path, factory, middleware?)

      • register(route)

      • registers(routes)

      • unregister(route)

      • unregisters(routes)

      • handle(context, next)

    • PathnameRoute

      • Props

      • path

      • method

      • factory

      • middleware

      • Methods

      • constructor({path, method, factory, middleware?})

      • use(factory)

      • uses(factories)

      • unuse(factory)

      • unuses(factories)

      • handle(context)

    Install

    npm i @y0x54a/bunda

    DownloadsWeekly Downloads

    8

    Version

    0.1.0

    License

    Apache-2.0

    Unpacked Size

    50.8 kB

    Total Files

    36

    Last publish

    Collaborators

    • y0x54a