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

5.0.6 • Public • Published

An minimal, heavily-optimized router for Stric.

import { Router, macro } from '@stricjs/router';

// Create a router and serve using Bun
export default new Router()
  // Handle GET request to `/`
  .get('/', macro('Hi'))
  // Handle POST request to `/json`
  .post('/json', ctx => ctx.data, { body: 'json', wrap: 'json' })
  // Return 90 for requests to `/id/90` for instance
  .get('/id/:id', ctx => ctx.params.id, { wrap: true })
  // Use the default 404 handler
  .use(404);

See the docs for more details.

Readme

Keywords

Package Sidebar

Install

npm i @stricjs/router

Weekly Downloads

120

Version

5.0.6

License

none

Unpacked Size

38.3 kB

Total Files

20

Last publish

Collaborators

  • leithen
  • reve-node