Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

koa-mount-html

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-mount-html

Mount all GET requests for text/html content types to a given KOA application

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

koa-mount-html

NPM version Build status Dependency Status License Downloads

Catch-all mounting of koa apps and middleware for HTML GET requests.

Installation

$ npm install koa-mount-html

API

Deferred fallback for all HTML requests

const koa = require('koa');
const mountHtml = require('koa-mount-html');
const serve = require('koa-static');
const app = koa();

// with `defer: true`, koa-mount-html will only catch requests that are not
// answered by other middleware
app.use(mountHtml(function *sendHtml() {
  yield send(this, '/index.html', { root: __dirname + '/public' });
}, { defer: true }));

app.use(serve('public/static_pages'));

Webpack dev middleware - html catch-all

const koa = require('koa');
const mountHtml = require('koa-mount-html');
const webpackConfig = require('./webpack.conf');
const compiler = webpack(webpackConfig);
const publicPath = webpackConfig.output.publicPath;
const app = koa();

app.use(mountHtml(
    rewrite('/*', publicPath + '/index.html')
));

app.use(mount(
  publicPath, webpackDevMiddleware(compiler, serverOptions)
));

Options

  • defer If true, serves after yield next, allowing any downstream middleware to respond first.
  • includeDotPaths If true, then paths including a dot (i.e. '/staticPage.html') will be cought as well.

Keywords

FAQs

Package last updated on 24 Dec 2015

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc