Skip to content

yoshuawuyts/myth-request

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

myth-request

NPM version build status Test coverage Downloads

Wraps a myth instance into an HTTP request handler, performing the minimal amount of rebundling required and pausing requests mid-build to avoid getting old versions of your script on reload.

Installation

$ npm install myth-request

Usage

const mr     = require('myth-request')
const rework = require('rework')
const http   = require('http')
const myth   = require('myth')
const fs     = require('fs')

const css     = fs.readFileSync('index.css', 'utf8')
const handler = mr(rework(css).use(myth()))
const server  = http.createServer()

server.on('request', function(req, res) {
  handler(req, res, function(err, body) {
    if (err) console.log(err)
    res.end(body)
  })
})

server.listen(process.env.PORT || 1337)

Why?

Setting up boilerplate for myth as an http handler can be a bit annoying. This module provides a good entry point for both development and production servers running myth. No gulp, grunt or make needed.

See Also

License

MIT

About

Wraps a myth instance into an HTTP request handler.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published