Skip to content

Commit 5511f24

Browse files
authored
Merge pull request #1 from akeren/feature/add-support-for-typescript
Add support for typescript
2 parents 949cf0f + 2f93db3 commit 5511f24

File tree

10 files changed

+2327
-125
lines changed

10 files changed

+2327
-125
lines changed

.eslintrc

Lines changed: 0 additions & 30 deletions
This file was deleted.

.gitignore

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,44 @@
1-
node_modules/
1+
lib-cov
2+
*.seed
3+
*.log
4+
*.csv
5+
*.dat
6+
*.out
7+
*.pid
8+
*.gz
9+
*.swp
10+
11+
pids
12+
logs
13+
results
14+
tmp
15+
16+
# Build
17+
public/css/main.css
18+
19+
# Coverage reports
20+
coverage
21+
22+
# API keys and secrets
23+
.env
24+
25+
# Dependency directory
26+
node_modules
27+
bower_components
28+
dist
29+
30+
# Editors
31+
.idea
32+
*.iml
33+
34+
# OS metadata
35+
.DS_Store
36+
Thumbs.db
37+
38+
# Ignore built ts files
39+
dist/**/*
40+
build/**/*
41+
42+
43+
# ignore yarn.lock
44+
yarn.lock

README.md

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Http Status Codes
22

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).
44

55
## Install
66

@@ -10,13 +10,15 @@ A collection of extensive easy access and resuable HTTP status codes as defined
1010

1111
## Usage
1212

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+
1719
const app = express();
1820

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> => {
2022
const users = await User.find();
2123

2224
res.status(Response.HTTP_OK).json({
@@ -29,7 +31,7 @@ app.get('/api/v1/users', catchAsync(async (req, res, next) => {
2931

3032
}));
3133

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> => {
3335
const user = await User.findById(req.params.id);
3436

3537
if (!user) {
@@ -114,15 +116,10 @@ app.get('/api/v1/users/:id', catchAsync(async (req, res, next) => {
114116
| 505 | HTTP_VERSION_NOT_SUPPORTED | HTTP Version Not Supported |
115117
| 506 | HTTP_VARIANT_ALSO_NEGOTIATES_EXPERIMENTAL | Variant Also Negotiates |
116118
| 507 | HTTP_INSUFFICIENT_STORAGE | Insufficient Storage |
117-
| 508 | HTTP_LOOP_DETECTED | Loop Detecte |
119+
| 508 | HTTP_LOOP_DETECTED | Loop Detected |
118120
| 5010 | HTTP_NOT_EXTENDED | Not Extended |
119121
| 511 | HTTP_NETWORK_AUTHENTICATION_REQUIRED | Network Authentication Required |
120122

121123
## Contributing
122124

123125
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

Comments
 (0)