@ewizardjs/mini-server
v0.2.1
Published
Mini Server
Keywords
Readme
@ewizardjs/mini-server
A lightweight and simple HTTP server for serving static files, built on top of serve-handler.
Installation
npm install @ewizardjs/mini-serverUsage
import { createServer } from '@ewizardjs/mini-server';
// Create a server serving files from the current directory
createServer(process.cwd())
.then(({ server, url, port }) => {
console.log(`Server is running at ${url}`);
// Server can be stopped if needed
// server.close();
});API
createServer(rootPath: string): Promise
Creates an HTTP server for serving static files from the specified path.
Parameters:
- rootPath: Path to the directory whose files will be served by the server
Returns:
An object containing:
- server: Node.js HTTP server instance
- port: Port number where the server is running
- url: URL for accessing the server (http://127.0.0.1:{port})
Development
# Build the project
npm run build
# Lint check
npm run lint
# Run test server
node test.js