Skip to content

Commit

Permalink
feat: use cookie@0.7.2 (#39)
Browse files Browse the repository at this point in the history
closes eggjs/egg#5363


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Introduced customizable error handling with multiple response formats
(HTML, JSON, JS).
- Added a new `ErrorView` class for enhanced error reporting in web
applications.
- Updated the README to include installation instructions and a
Contributors section.

- **Bug Fixes**
	- Improved error handling logic in the application.

- **Chores**
	- Updated copyright notice in the LICENSE file.
- Modified CI workflow configurations for better dependency management
and version support.
	- Updated dependency versions in package.json.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
fengmk2 authored Oct 13, 2024
1 parent ecc3405 commit fc57345
Show file tree
Hide file tree
Showing 14 changed files with 20 additions and 125 deletions.
24 changes: 0 additions & 24 deletions .github/PULL_REQUEST_TEMPLATE.md

This file was deleted.

72 changes: 0 additions & 72 deletions .github/workflows/codeql-analysis.yml

This file was deleted.

7 changes: 2 additions & 5 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@ name: CI
on:
push:
branches: [ master ]

pull_request:
branches: [ master ]

workflow_dispatch: {}

jobs:
Job:
name: Node.js
uses: artusjs/github-actions/.github/workflows/node-test.yml@v1
uses: node-modules/github-actions/.github/workflows/node-test.yml@master
with:
os: 'ubuntu-latest, macos-latest, windows-latest'
version: '14, 16, 18'
version: '14, 16, 18, 20, 22'
6 changes: 1 addition & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@ on:
push:
branches: [ master ]

workflow_dispatch: {}

jobs:
release:
name: Node.js
uses: artusjs/github-actions/.github/workflows/node-release.yml@v1
uses: eggjs/github-actions/.github/workflows/node-release.yml@master
secrets:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
with:
checkTest: false
File renamed without changes.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) Alibaba Group Holding Limited and other contributors.
Copyright (c) 2017-present Alibaba Group Holding Limited and other contributors.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ Default error handling plugin for egg.
## Install

```bash
$ npm i egg-onerror
npm i egg-onerror
```

## Usage

`egg-onerror` is on by default in egg. But you still can configure its properties to fits your scenarios.

- `errorPageUrl: String or Function` - If user request html pages in production environment and unexpected error happened, it will redirect user to `errorPageUrl`.
- `accepts: Function` - detect user's request accpet `json` or `html`.
- `accepts: Function` - detect user's request accept `json` or `html`.
- `all: Function` - customize error handler, if `all` present, negotiation will be ignored.
- `html: Function` - customize html error handler.
- `text: Function` - customize text error handler.
Expand All @@ -37,7 +37,7 @@ $ npm i egg-onerror

```js
// config.default.js
// errorPageUrl support funtion
// errorPageUrl support function
exports.onerror = {
errorPageUrl: (err, ctx) => ctx.errorPageUrl || '/500',
};
Expand All @@ -56,3 +56,9 @@ Please open an issue [here](https://github.com/eggjs/egg/issues).
## License

[MIT](https://github.com/eggjs/egg-onerror/blob/master/LICENSE)

## Contributors

[![Contributors](https://contrib.rocks/image?repo=eggjs/egg-onerror)](https://github.com/eggjs/egg-onerror/graphs/contributors)

Made with [contributors-img](https://contrib.rocks).
2 changes: 0 additions & 2 deletions agent.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

module.exports = agent => {
// should watch error event
agent.on('error', err => {
Expand Down
2 changes: 0 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

const http = require('http');
const fs = require('fs');
const onerror = require('koa-onerror');
Expand Down
2 changes: 0 additions & 2 deletions config/config.default.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

const path = require('path');

exports.onerror = {
Expand Down
2 changes: 0 additions & 2 deletions lib/error_view.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

// modify from https://github.com/poppinss/youch/blob/develop/src/Youch/index.js

const fs = require('fs');
Expand Down
2 changes: 0 additions & 2 deletions lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

exports.detectErrorMessage = function(ctx, err) {
// detect json parse error
if (err.status === 400 &&
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"onerror"
],
"dependencies": {
"cookie": "^0.3.1",
"cookie": "^0.7.2",
"koa-onerror": "^4.0.0",
"mustache": "^2.3.0",
"stack-trace": "^0.0.10"
Expand All @@ -34,15 +34,16 @@
"egg-bin": "^5.5.0",
"egg-mock": "^5.3.0",
"eslint": "^8.29.0",
"eslint-config-egg": "^12.1.0"
"eslint-config-egg": "^12.1.0",
"mocha": "^10.7.3"
},
"engines": {
"node": ">=8.0.0"
},
"scripts": {
"test": "npm run lint -- --fix && npm run test-local",
"test-local": "egg-bin test --full-trace",
"cov": "egg-bin cov --full-trace",
"test-local": "egg-bin test",
"cov": "egg-bin cov",
"lint": "eslint .",
"ci": "npm run lint && npm run cov"
},
Expand Down
3 changes: 2 additions & 1 deletion test/onerror.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ describe('test/onerror.test.js', () => {
});
});

if (process.platform !== 'win32') {
if (process.platform === 'linux') {
// ignore Error: write ECONNRESET on windows and macos
it('should log warn 4xx', async () => {
fs.rmSync(path.join(__dirname, 'fixtrues/onerror-4xx/logs'), { force: true, recursive: true });
const app = mm.app({
Expand Down

0 comments on commit fc57345

Please sign in to comment.