Skip to content
/ uSendFile Public

A minimal static file handler for uWebSocket

Notifications You must be signed in to change notification settings

erf/uSendFile

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

uSendFile

A minimal static file handler for uWebSocket.js

NOTE: Only works for small files. Apps in production should use nginx or similar.

Installation

Add the following to your package.json file:

{
  "dependencies": {
	"uSendFile": "github:erf/uSendFile"
  }
}

Then run npm install.

Usage

// import the modules 
import uWS from 'uWebSockets.js'
import sendFile from 'uSendFile'

// create a new app
const app = uWS.App()

// index.html
app.get('/', (res, req) => sendFile('./public/index.html', res))

// static files
app.get('/*', (res, req) => sendFile(`./public${req.getUrl()}`, res))

Test

node --test

About

A minimal static file handler for uWebSocket

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published