npm stats
  • Search
  • About
  • Repo
  • Sponsor
  • more
    • Search
    • About
    • Repo
    • Sponsor

Made by Antonio Ramirez

send-promised

1.2.0

@juliangruber

npmHomeRepoSnykSocket
Downloads:7
$ npm install send-promised
DailyWeeklyMonthlyYearly

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