Skip to content

Commit

Permalink
feat(typescript): typescript rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
noamokman committed Jul 26, 2019
1 parent 3efb663 commit fc0be35
Show file tree
Hide file tree
Showing 10 changed files with 7,067 additions and 9,444 deletions.
7 changes: 6 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
"node": 8
}
}
]
],
"@babel/typescript"
],
"plugins": [
"@babel/proposal-class-properties",
"@babel/proposal-object-rest-spread"
]
}
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ language: node_js
node_js:
- '8'
- '10'
- '12'
- 'node'
after_success:
- npm run coveralls
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

Error handler for express JSON APIs


## Installation
## Install
``` bash
$ [sudo] npm install express-json-error-handler --save
$ npm install express-json-error-handler
```

## Usage
Expand Down
16 changes: 8 additions & 8 deletions __tests__/main.spec.js → __tests__/main.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('express-json-error-handler', () => {

const err = new Error('error');

errorHandler(err, null, res);
errorHandler(err, null as any, res as any, null as any);

expect(res.status).toHaveBeenCalledWith(500);
});
Expand All @@ -37,11 +37,11 @@ describe('express-json-error-handler', () => {
status: jest.fn()
};

const err = new Error('error');
const err: Error & { statusCode?: number } = new Error('error');

err.statusCode = 214;

errorHandler(err, null, res);
errorHandler(err, null as any, res as any, null as any);

expect(res.status).toHaveBeenCalledWith(500);
});
Expand All @@ -54,11 +54,11 @@ describe('express-json-error-handler', () => {
status: jest.fn()
};

const err = new Error('error');
const err: Error & { statusCode?: number } = new Error('error');

err.statusCode = 400;

errorHandler(err, null, res);
errorHandler(err, null as any, res as any, null as any);

expect(res.status).toHaveBeenCalledWith(400);
const [[clientErr]] = res.json.mock.calls;
Expand All @@ -79,9 +79,9 @@ describe('express-json-error-handler', () => {
status: jest.fn()
};

const err = new Error('error');
const err: Error & { statusCode?: number } = new Error('error');

errorHandler(err, null, res);
errorHandler(err, null as any, res as any, null as any);

expect(log).toHaveBeenCalledWith({res, req: null, err});
});
Expand All @@ -100,7 +100,7 @@ describe('express-json-error-handler', () => {
status: jest.fn()
};

const err = new Error('error');
const err: Error & { statusCode?: number } = new Error('error');

err.statusCode = 400;

Expand Down
Loading

0 comments on commit fc0be35

Please sign in to comment.