Package Exports
- herver
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (herver) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
herver
Introduction
herver
is a modern server lib which aims at being versatile but lightweight.
Features
- 💡
Promise
-based APIs - 📦 Built-in router support
- 🚀 High extensibility
- 🔧 Useful utilities
- 📚 TypeScript support
Links
Example
// import APIs
const { App, Router, createStaticHandler } = require('herver');
// create an app and a router
const app = new App(),
router = new Router();
// handle POST requests to `/echo` (e.g.: `POST /echo?msg=test`)
router.post('/echo', async (context, next) => {
// end the response with the query parameter `msg`
context.endWithContent('' + context.queries.get('msg'));
});
// serve all GET requests with corresponding static files in the public folder
router.get(/^\//, createStaticHandler('/path/to/public'));
// apply the router to the app and starts the app at port 8080
app.use(router.handler)
.listen(8080);