JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q59441F
  • License MIT

DOZ server-side rendering

Package Exports

  • doz-ssr

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 (doz-ssr) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

doz-ssr

DOZ server-side rendering

Installation

npm install doz-ssr --save

Example with Koa

server.js

const Koa = require('koa');
const serve = require('koa-static');
const body = require('koa-body');
const DozSSR = require('doz-ssr');

const dozSSR = new DozSSR('./public/index.html');

new Koa()
    .use(serve('./public', {index: false}))
    .use(body())
    .use(async ctx => {
        ctx.body = await dozSSR.render(ctx.path);
    })
    .listen(3000);

index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <title>MyApp</title>
</head>
<body>
<div id="app"></div>
<script id="bundle" src="/dist/bundle.js"></script>
</body>
</html>

API

DozSSR

Kind: global class

new DozSSR(entryFile, [opt])

ParamTypeDefaultDescription
entryFilestring

file index

[opt]object

options

[opt.bundleId]string"bundle"

bundle id selector

[opt.docTypeString]string"<!DOCTYPE html>"

document type

[opt.delayRender]int0

delay render in ms

dozSSR.setContent(entryContent)

Set document content

Kind: instance method of DozSSR

Param
entryContent

dozSSR.getContent() ⇒ string

Get document content

Kind: instance method of DozSSR

dozSSR.getBundleEl() ⇒ HTMLElement | null

Get bundle HTMLElement

Kind: instance method of DozSSR

dozSSR.getBundlePath() ⇒ string

Get bundle path from src attribute

Kind: instance method of DozSSR

dozSSR.render(routePath) ⇒ Promise.<any>

Render app

Kind: instance method of DozSSR

Param
routePath

Changelog

You can view the changelog here

License

doz-ssr is open-sourced software licensed under the MIT license

Author

Fabio Ricali