1.3.2 • Published 2 years ago

@atz3n/express-utils v1.3.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

express-utils

A utilities library for express servers

Installation

npm install @atz3n/express-utils

you also have to have body-parser, express-async-errors and express-validator installed.

npm install body-parser express-async-errors express-validator

Add the errorHandler function after your routes. Have a look into the test server for an example.

Content

The library contains the following throwable errors:

BadRequestError     : returns status code 400
NotAuthorizedError  : returns status code 401
NotFoundError       : returns status code 404
InternalError       : returns status code 500

It also contains the following middleware functions:

validationRequest   : validates express-validator validation results
validateAuthToken   : validates an auth token
validateOrigin      : validates the origin
errorHandler        : sends error responses to the client

Have a look into the test server for example usage.

Development

To initialize the project just clone this repository and run

npm install

For linting run

npm run lint

You can try to autofix lint errors with

npm run lint:fix

For unit tests run

npm test
1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.2

2 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago