Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

uwebsocket-serve

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uwebsocket-serve

Static file serving for uWebSockets.js

latest
Source
npmnpm
Version
1.0.8
Version published
Weekly downloads
41
36.67%
Maintainers
1
Weekly downloads
 
Created
Source

Static file serving for uWebSockets.js http server.

Example

import path from 'path';
import { App } from 'uWebSockets.js';
import { serveDir } from 'uwebsocket-serve';

const publicPath = path.resolve(__dirname, '../public');
const serveStatic = serveDir(publicPath);

App().get('/*', serveStatic);

API

const serveDir = (directoryPath: string) => (res: HttpResponse, req: HttpRequest) => void

serveDir(directoryPath: string)

Create a new middleware function to serve files from within a given root directory. The file to serve will be determined by combining req.getUrl() with provided directory. When a file is not found sending a 404 response.

Cache

This module supports the Last-Modified HTTP header

Source

This library is based on an example from a uWebSockets.js repository.

Support

uwebsocket-serve is an MIT-licensed open source project. Feel free to fork and contribute.

Keywords

socket

FAQs

Package last updated on 22 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts