Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
interval: "weekly"
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
node-version: [20.x, 22.x, 24.x]
steps:
- uses: actions/checkout@v4
- name: Setup Node
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20
22
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# slay-error

Standard, sane defaults for HTTP errors in slay apps.

## Usage

You should use this within your `middlewares.js` in your Slay app

**middlewares.js**
## middlewares

``` js
module.exports = function (app, opts, done) {
//
Expand All @@ -18,10 +20,12 @@ module.exports = function (app, opts, done) {
app.use(require('slay-error')(app, { disableLog: false }));
};
```

In your application, when you pass an error to the `next(error)`
callback of a request handler, this middleware will handle the reporting
and response for that error in your application.
```

``` js
module.exports = function handler(req, res, next) {
// if error
next(new Error('let the middleware handle this'));
Expand All @@ -39,6 +43,7 @@ property. So, if `level: 'info'` only `app.log.info` will be invoked
with the log message and metadata.

### Hint

In your application you can use a tool like [errs](https://www.npmjs.com/package/errs) that
will allow you to define the structure of errors, either with
pre-defined/registered errors or by passing all of the properties of the
Expand Down
6 changes: 6 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const GDConfig = import('eslint-config-godaddy').then(module => module?.default || module);
const { defineConfig } = require('eslint/config');

module.exports = defineConfig({
extends: [GDConfig]
});
1 change: 0 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable max-statements */
const { decycle } = require('json-decycle');

module.exports = function (app, opts) {
Expand Down
Loading