npm.io
1.2.0 • Published 9 years ago

send-promised

Licence
MIT
Version
1.2.0
Deps
1
Vulns
1
Weekly
0

send-promised

development sponsored by voltra.co

Handy promise wrapper for the send static file server.

Usage

send-promised returns whether a request could be handled by static file serving, so you can use it as the first part of your http handler function.

const send = require('send-promised')
const http = require('http')

const serve = (req, res) =>
  send({
    root: `${__dirname}/static` // and other options for `send`
  })

http.createServer(async (req, res) => {
  const served = await serve(req, res)
  if (served) return

  // handle other routes
})

Installation

$ npm install send-promised

License

MIT