JSPM

@opengalaxium/tinyhttp

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 10
  • Score
    100M100P100Q16660F
  • License MIT

Light, fast, compact web framework

Package Exports

  • @opengalaxium/tinyhttp

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@opengalaxium/tinyhttp) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

tinyhttp

Light, fast, compact web framework

GitHub repo: https://github.com/OpenGalaxium/tinyhttp

npm package: https://www.npmjs.com/package/@opengalaxium/tinyhttp

Installation

npm i @opengalaxium/tinyhttp

Example usage

index.ts

import tinyhttp from '@opengalaxium/tinyhttp'
import { parser } from '@opengalaxium/tinyhttp'
import routes from './routes'

const app = new tinyhttp()

app.use(parser.json)
app.use(parser.urlencoded)

app.get('/', (req, res) => {
  res.send('working!')
})

routes(app)

app.run(80, 'localhost').then((port) => {
  console.log(`tinyhttp is running on port ${port}`)
})

routes.ts

import tinyhttp from 'tinyhttp'

function routes(app: tinyhttp) {
    app.get('/json', (req, res) => {
        res.json({ status: 'working' })
    })

    app.post('/post', (req, res) => {
        res.send(req.body)
    })

    app.get('/render', (req, res) => {
        res.render('index.html', { title: 'res.render example', msg: 'render' })
    })

    app.static('/www')
}

export default routes;