1
1
# Http Status Codes
2
2
3
- A collection of extensive easy access and resuable HTTP status codes as defined by Request for comments (RFC).
3
+ A collection of extensive easy access and reusable HTTP status codes as defined by Request for comments (RFC).
4
4
5
5
## Install
6
6
@@ -10,13 +10,15 @@ A collection of extensive easy access and resuable HTTP status codes as defined
10
10
11
11
## Usage
12
12
13
- ``` javascript
14
- const express = require (' express' );
15
- const { Response } = require (' http-status-codez' );
16
- const User = require (' ./models/user' );
13
+ ``` typescript
14
+ import express , { Request , Response , NextFunction } from ' express' ;
15
+ import { Response } from ' http-status-codez' ;
16
+ import { User } from ' ../models/user'
17
+ import { catchAsync } from ' ../utils/catchAsync' ;
18
+
17
19
const app = express ();
18
20
19
- app .get (' /api/v1/users' , catchAsync (async (req , res , next ) => {
21
+ app .get (' /api/v1/users' , catchAsync (async (req : Request , res : Response , next : NextFunction ) : Promise < void > => {
20
22
const users = await User .find ();
21
23
22
24
res .status (Response .HTTP_OK ).json ({
@@ -29,7 +31,7 @@ app.get('/api/v1/users', catchAsync(async (req, res, next) => {
29
31
30
32
}));
31
33
32
- app .get (' /api/v1/users/:id' , catchAsync (async (req , res , next ) => {
34
+ app .get (' /api/v1/users/:id' , catchAsync (async (req : Request , res : Response , next : NextFunction ) : Promise < void > => {
33
35
const user = await User .findById (req .params .id );
34
36
35
37
if (! user ) {
@@ -114,15 +116,10 @@ app.get('/api/v1/users/:id', catchAsync(async (req, res, next) => {
114
116
| 505 | HTTP_VERSION_NOT_SUPPORTED | HTTP Version Not Supported |
115
117
| 506 | HTTP_VARIANT_ALSO_NEGOTIATES_EXPERIMENTAL | Variant Also Negotiates |
116
118
| 507 | HTTP_INSUFFICIENT_STORAGE | Insufficient Storage |
117
- | 508 | HTTP_LOOP_DETECTED | Loop Detecte |
119
+ | 508 | HTTP_LOOP_DETECTED | Loop Detected |
118
120
| 5010 | HTTP_NOT_EXTENDED | Not Extended |
119
121
| 511 | HTTP_NETWORK_AUTHENTICATION_REQUIRED | Network Authentication Required |
120
122
121
123
## Contributing
122
124
123
125
If you discover a security vulnerability, please create an issue. All security vulnerabilities will be promptly addressed and appreciated.
124
-
125
- ``` shell
126
- npm version [major | minor | patch]
127
- npm publish
128
- ```
0 commit comments