
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
koa-simple-web
Advanced tools
A simple web server using Koa
$ npm install koa-simple-web
const web = new SimpleWeb({ port: 8080 });
web.route(new (require("koa-router"))());
web.use(async (ctx) => {});
await web.start();
await web.stop();
Koa's listen (which SimpleWeb uses) is itself sugar for
const http = require("http");
const Koa = require("koa");
const app = new Koa();
http.createServer(app.callback()).listen(3000);
Consequently, if you want to configure the underlying server instance (for example to use HTTPS), you can pass in a Node http.Server or https.Server to the constructor and that server will be used instead of a default HTTP configuration.
const fs = require('fs');
const https = require('https');
const options = {
key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem')
};
const server = https.createServer(options);
const web = new SimpleWeb({ port: 8080 }, server);
await web.start();
// curl -v https://localhost:8080/
When developing simple/small node HTTP services (eg: microservices) that don't require a big web framework, a simple web server that can started (and stopped) is needed.
There wasn't one before, so there is now.
MIT
FAQs
A simple web server using Koa
We found that koa-simple-web demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.