Skip to content

Commit 873d8e4

Browse files
committed
Refactor helper and remove webpack
1 parent 2ed9d19 commit 873d8e4

File tree

9 files changed

+71
-496
lines changed

9 files changed

+71
-496
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,5 @@ ehthumbs_vista.db
3636
.AppleDouble
3737
.LSOverride
3838

39+
# build
40+
dist

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "ts-http-status-utils",
33
"version": "0.1.2",
44
"description": "HTTP status code declarations, descriptions and utils",
5-
"main": "src/index.d.ts",
5+
"main": "src/index.ts",
66
"homepage": "https://github.com/thejfreitas/ts-http-status-utils",
77
"bugs": "https://github.com/thejfreitas/ts-http-status-utils/issues",
88
"repository": "[email protected]:thejfreitas/ts-http-status-utils.git",
@@ -18,13 +18,14 @@
1818
"http-error",
1919
"http-error-message"
2020
],
21+
"scripts": {
22+
"build": "rm -rf dist && tsc"
23+
},
2124
"devDependencies": {
2225
"@types/jest": "^27.4.0",
2326
"jest": "^27.5.1",
2427
"ts-jest": "^27.1.3",
2528
"ts-loader": "^9.2.6",
26-
"typescript": "^4.5.5",
27-
"webpack": "^5.69.1",
28-
"webpack-cli": "^4.9.2"
29+
"typescript": "^4.5.5"
2930
}
3031
}

src/StatusDescription/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/**
2+
* Status Description
3+
*
4+
* @export
5+
* @enum {number}
6+
*/
17
export enum StatusDescription {
28
/**
39
* @description - StatusCode 100

src/StatusLabel/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/**
2+
* Status Label
3+
*
4+
* @export
5+
* @enum {number}
6+
*/
17
export enum StatusLabel {
28
CONTINUE,
39
SWITCHING_PROTOCOLS,

src/StatusPhrase/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/**
2+
* Status Phrase
3+
*
4+
* @export
5+
* @enum {number}
6+
*/
17
export enum StatusPhrase {
28
CONTINUE = "Continue",
39
SWITCHING_PROTOCOLS = "Switching Protocols",

src/helpers.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,25 @@ import { StatusDescription } from "./StatusDescription";
44
import { StatusLabel } from "./StatusLabel";
55
import { IHttpResponsesDictionary } from "./Interfaces";
66

7-
export const makeHttpResponsesDictionary = (): IHttpResponsesDictionary => {
8-
let dictionary = {};
7+
export const makeHttpResponsesDictionary = () => {
8+
let dictionary: IHttpResponsesDictionary = {};
99

1010
for (const statusCode in StatusLabel) {
1111
if (Number.isNaN(Number(StatusLabel[statusCode]))) {
1212
continue;
1313
}
1414

15+
// @ts-ignore
16+
const phrase = StatusPhrase[statusCode];
17+
// @ts-ignore
18+
const description = StatusDescription[statusCode];
19+
1520
dictionary = {
1621
...dictionary,
1722
[StatusCode[statusCode]]: {
1823
code: StatusCode[statusCode],
19-
phrase: StatusPhrase[statusCode],
20-
description: StatusDescription[statusCode],
24+
phrase: phrase,
25+
description: description,
2126
},
2227
};
2328
}

src/index.d.ts renamed to src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,3 @@ export * from "./StatusLabel";
55
export * from "./StatusPhrase";
66
export * from "./RequestMethod";
77
export * from "./Interfaces/";
8-
9-
export as namespace TsHttpStatusUtils;

tsconfig.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
"module": "es6",
5+
"strict": true,
6+
"esModuleInterop": true,
7+
"declaration": true,
8+
"moduleResolution": "node",
9+
10+
"noEmit": true
11+
},
12+
"include": ["src/**/*"],
13+
"exclude": ["node_modules", "dist", "tests"]
14+
}

0 commit comments

Comments
 (0)