FAQ

How do I render plain HTML?

const { HttpConnector, Reshuffle } = require('reshuffle')

const app = new Reshuffle()

const connector = new HttpConnector(app)

connector.on({ method: 'GET', path: '/html' }, (event, app) => {
  event.res.send(`<!doctype html>
<html>
<head>
  <meta charset="utf-8">
</head>
<body>
    <h1>Hello World</h1>
</body>
</html>
  `)
})

app.start()

How do I handle errors?

const { HttpConnector, Reshuffle } = require('reshuffle')

const app = new Reshuffle()

const connector = new HttpConnector(app)

connector.on({ method: 'GET', path: '/error-test' }, (event, app) => {
  try {
    throw new Error('Error')
  } catch (error) {
    event.res.send('Error handled!')
  }
})

app.start()

How do serve a static file?

There is an example of how to serve a static file in the examples folder

What is the order of preference for routes?

Route preference works as follows:

  • All routes not using parameters (not containing ':') are processed first.

  • When using routes with parameters (e.g. path is /foo/:id), handlers associated to this path will only be executed if no specific routes matched.

Can I use my own express middleware?

We currently don't support this, but we are looking at adding this feature in the future.