How to use the micro.createError function in micro

To help you get started, we’ve selected a few micro examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github graphql-editor / ts-api-faker / src / fake.ts View on Github external
.then(body => {
        try {
          return JSON.parse(body)
        } catch (err) {
          createError(400, "Invalid JSON", err)
        }
      })
    )
github graphql-editor / ts-api-faker / src / fake.ts View on Github external
gunzip(body, (err, buf) => {
                if (err) {
                  reject(createError(400, "Invalid gzip", err))
                  return
                }
                resolve(buf.toString())
              })
            })
github styled-components / styled-components / packages / sandbox / server / index.js View on Github external
module.exports = async (req, res) => {
  try {
    await webpackMiddleware(appMiddleware)(req, res);
  } catch (err) {
    throw createError(500, stripAnsi(err.message), err);
  }
};
github electerious / Ackee / src / server.js View on Github external
const notFound = async (req) => {

	const err = new Error(`\`${ req.url }\` not found`)

	throw createError(404, 'Not found', err)

}
github bufferapp / micro-rpc / index.js View on Github external
createError: ({ message, statusCode = 400 }) => {
    const err = createError(statusCode, message);
    err.handled = true;
    return err;
  },
};

micro

Asynchronous HTTP microservices

MIT
Latest version published 2 years ago

Package Health Score

72 / 100
Full package analysis