Nutritious Potato Munchies

    @lggruspe/fragment-router
    TypeScript icon, indicating that this package has built-in type declarations

    1.4.7 • Public • Published

    fragment-router

    GitHub Workflow Status codecov npm (scoped) GitHub

    Router for dynamically-generated HTML fragments.

    Installation

    npm install @lggruspe/fragment-router

    Example

    import { check, matches, DomAppender, Router } from '@lggruspe/fragment-router'
    
    const router = new Router()
    const appender = new DomAppender(router)
    
    router.route(
      check(matches(/^hello\/(?<name>[a-z]+)$/)),
      req => {
        // print hello/<name> in console
        console.log(req.id)
        router.defer(() => {
          // append p element after processing request
          appender.renderHtml(`<p>Hello, ${req.params.name}!</p>`)
        })
      }
    )
    
    router.listen()

    See examples/.

    License

    MIT

    Install

    npm i @lggruspe/fragment-router

    DownloadsWeekly Downloads

    4

    Version

    1.4.7

    License

    MIT

    Unpacked Size

    198 kB

    Total Files

    40

    Last publish

    Collaborators

    • lggruspe