<commit_before># express-custom-response

Create custom response methods for express.js

## Getting Started
Install the module with: `npm install express-custom-response`

##Quick Start
```javascript
require('express-custom-response')();
```


## Documentation
Module contain pre-defined custom responses:

**res.serverError (extra)**
- *mixed* **extra**
 - Any data that have to be returned to user
 
> return reponse with http code 500 and body:```
error: {
    error_message: 'We're sorry, a server error occurred. Please wait a bit and try again',
	error_code: 500,
	error_extra: null or extra
	}
```

**res.forbidden (fields, extra)**
- *object* **fields**
 - Object which contain validation error,  where key is field name and value is message
- *mixed* **extra**
 - Any data that have to be returned to user
 
> return reponse with http code 405 and body:```
error: {
    error_message: 'Validation failed',
	error_code: 405,
	fields: {email: 'Email has to be uniq'},
	error_extra: null or extra
}
```

**res.notFound (name, extra)**
- *string* **name**
 - What server can't find
- *mixed* **extra**
 - Any data that have to be returned to user
 
> return reponse with http code 404 and body:```
error: {
    error_message: 'User not found',
	error_code: 404,
	error_extra: null or extra
}
```

**res.ok (extra)**
- *mixed* **extra**
 - Any data that have to be returned to user
 
> return reponse with http code 404 and body:```
{} or extra
```


## Create own response<commit_msg>upd readme<commit_after># express-custom-response

Create custom response methods for express.js

## Getting Started
Install the module with: `npm install express-custom-response`

##Quick Start
```javascript
require('express-custom-response')();
```


## Documentation
Module contain pre-defined custom responses:

**res.serverError (extra)**
- *mixed* **extra**
 - Any data that have to be returned to user
 
> return reponse with http code 500 and body:```
error: {
    error_message: 'We're sorry, a server error occurred. Please wait a bit and try again',
	error_code: 500,
	error_extra: null or extra
	}
```

**res.validation (message, extra)**
- *string* **message**
 - Message to show user why his request were forbidden
- *mixed* **extra**
 - Any data that have to be returned to user
 
> return reponse with http code 405 and body:```
error: {
    error_message: 'Validation failed',
	error_code: 405,
	fields: {email: 'Email has to be uniq'},
	error_extra: null or extra
}
```

**res.forbidden (fields, extra)**
- *object* **fields**
 - Object which contain validation error,  where key is field name and value is message
- *mixed* **extra**
 - Any data that have to be returned to user
 
> return reponse with http code 405 and body:```
error: {
    error_message: 'Validation failed',
	error_code: 405,
	fields: {email: 'Email has to be uniq'},
	error_extra: null or extra
}
```


**res.notFound (name, extra)**
- *string* **name**
 - What server can't find
- *mixed* **extra**
 - Any data that have to be returned to user
 
> return reponse with http code 404 and body:```
error: {
    error_message: 'User not found',
	error_code: 404,
	error_extra: null or extra
}
```

**res.ok (extra)**
- *mixed* **extra**
 - Any data that have to be returned to user
 
> return reponse with http code 404 and body:```
{} or extra
```


## Create own response
{'fraction_non_alphanumeric': 0.12865671641791046, 'fraction_numerical': 0.014328358208955224, 'mean_word_length': 4.092705167173253, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4164430', 'n_tokens_mistral': 1103, 'n_tokens_neox': 1004, 'n_words': 428}