Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 .documents: Documented API missing #526

Open
perguth opened this issue Jun 9, 2019 · 1 comment
Open

馃悰 .documents: Documented API missing #526

perguth opened this issue Jun 9, 2019 · 1 comment

Comments

@perguth
Copy link
Contributor

perguth commented Jun 9, 2019

This a 馃悰 bug report.

.documents is not accepting an object as second parameter even though it's documented in the README.

Expected Behavior

var someState = { render: 'me' }

// Documented API:
// `compiler.documents(routename, [opts], done(err, { buffer, hash }))`
compiler.documents('/', {
  state: someState
}, noop)

// Render the document passing `state` to the render function.

Current Behavior

uncaughtException { AssertionError [ERR_ASSERTION]: 'object' == 'function'
    at Bankai.documents (/application/node_modules/bankai/index.js:172:10)
    at Server.http.createServer (/application/server.js:107:17)
    at Server.emit (events.js:189:13)
    at parserOnIncoming (_http_server.js:676:12)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:109:17)
  generatedMessage: true,
  name: 'AssertionError [ERR_ASSERTION]',
  code: 'ERR_ASSERTION',
  actual: 'object',
  expected: 'function',
  operator: '==' }

Possible Solution

Maybe build on #446?

Context

I would like to just prerender the document instead of letting the client wait to receive it's initial state via WebSockets.

Code Sample

const server = http.createServer((request, response) => {
  if (request.url === '/') {
    compilerCli.documents('/', { state }, (error, node) => {
      response.setHeader('content-type', 'text/html')
      gzip(node.buffer, request, response)
    })
  }
  compilerHtml(request, response, function () {
    response.statusCode = 404
    response.end('not found')
  })
})

Your Environment

Software Version(s)
Choo 6.13.3
@perguth
Copy link
Contributor Author

perguth commented Jul 3, 2019

Maybe @yoshuawuyts ? 馃巿

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant