Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
3244bc9bf4 | |||
29d813bc14 | |||
5b1c917137 | |||
7c4140800b | |||
32577ade65 | |||
7def0b01b0 | |||
5ec5d0a928 | |||
aa9a731910 | |||
d28b7d16cd | |||
36d26f6ff8 | |||
cbbf90f6f1 | |||
935ea4386c | |||
df430fa033 | |||
acbe290526 | |||
98f99bd18d |
66
.gitea/workflows/default_nottags.yaml
Normal file
66
.gitea/workflows/default_nottags.yaml
Normal file
@ -0,0 +1,66 @@
|
||||
name: Default (not tags)
|
||||
|
||||
on:
|
||||
push:
|
||||
tags-ignore:
|
||||
- '**'
|
||||
|
||||
env:
|
||||
IMAGE: code.foss.global/host.today/ht-docker-node:npmci
|
||||
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{gitea.repository}}.git
|
||||
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||
|
||||
jobs:
|
||||
security:
|
||||
runs-on: ubuntu-latest
|
||||
continue-on-error: true
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install pnpm and npmci
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @ship.zone/npmci
|
||||
|
||||
- name: Run npm prepare
|
||||
run: npmci npm prepare
|
||||
|
||||
- name: Audit production dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --prod
|
||||
continue-on-error: true
|
||||
|
||||
- name: Audit development dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --dev
|
||||
continue-on-error: true
|
||||
|
||||
test:
|
||||
if: ${{ always() }}
|
||||
needs: security
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Test stable
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm test
|
||||
|
||||
- name: Test build
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm build
|
124
.gitea/workflows/default_tags.yaml
Normal file
124
.gitea/workflows/default_tags.yaml
Normal file
@ -0,0 +1,124 @@
|
||||
name: Default (tags)
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
env:
|
||||
IMAGE: code.foss.global/host.today/ht-docker-node:npmci
|
||||
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{gitea.repository}}.git
|
||||
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||
|
||||
jobs:
|
||||
security:
|
||||
runs-on: ubuntu-latest
|
||||
continue-on-error: true
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @ship.zone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Audit production dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --prod
|
||||
continue-on-error: true
|
||||
|
||||
- name: Audit development dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --dev
|
||||
continue-on-error: true
|
||||
|
||||
test:
|
||||
if: ${{ always() }}
|
||||
needs: security
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @ship.zone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Test stable
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm test
|
||||
|
||||
- name: Test build
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm build
|
||||
|
||||
release:
|
||||
needs: test
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @ship.zone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Release
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm publish
|
||||
|
||||
metadata:
|
||||
needs: test
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
continue-on-error: true
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @ship.zone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Code quality
|
||||
run: |
|
||||
npmci command npm install -g typescript
|
||||
npmci npm install
|
||||
|
||||
- name: Trigger
|
||||
run: npmci trigger
|
||||
|
||||
- name: Build docs and upload artifacts
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
pnpm install -g @git.zone/tsdoc
|
||||
npmci command tsdoc
|
||||
continue-on-error: true
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -3,7 +3,6 @@
|
||||
# artifacts
|
||||
coverage/
|
||||
public/
|
||||
pages/
|
||||
|
||||
# installs
|
||||
node_modules/
|
||||
@ -17,4 +16,4 @@ node_modules/
|
||||
dist/
|
||||
dist_*/
|
||||
|
||||
# custom
|
||||
#------# custom
|
137
.gitlab-ci.yml
137
.gitlab-ci.yml
@ -1,137 +0,0 @@
|
||||
# gitzone ci_default
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
|
||||
cache:
|
||||
paths:
|
||||
- .npmci_cache/
|
||||
key: '$CI_BUILD_STAGE'
|
||||
|
||||
stages:
|
||||
- security
|
||||
- test
|
||||
- release
|
||||
- metadata
|
||||
|
||||
# ====================
|
||||
# security stage
|
||||
# ====================
|
||||
mirror:
|
||||
stage: security
|
||||
script:
|
||||
- npmci git mirror
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
auditProductionDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --production --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high --only=prod --production
|
||||
tags:
|
||||
- docker
|
||||
|
||||
auditDevDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high --only=dev
|
||||
tags:
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
# ====================
|
||||
# test stage
|
||||
# ====================
|
||||
|
||||
testStable:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
|
||||
testBuild:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci command npm run build
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci node install stable
|
||||
- npmci npm publish
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
# ====================
|
||||
# metadata stage
|
||||
# ====================
|
||||
codequality:
|
||||
stage: metadata
|
||||
allow_failure: true
|
||||
only:
|
||||
- tags
|
||||
script:
|
||||
- npmci command npm install -g tslint typescript
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- priv
|
||||
|
||||
trigger:
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci trigger
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
pages:
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci node install lts
|
||||
- npmci command npm install -g @gitzone/tsdoc
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command tsdoc
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
only:
|
||||
- tags
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- public
|
||||
allow_failure: true
|
24
.vscode/launch.json
vendored
24
.vscode/launch.json
vendored
@ -2,28 +2,10 @@
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "current file",
|
||||
"type": "node",
|
||||
"command": "npm test",
|
||||
"name": "Run npm test",
|
||||
"request": "launch",
|
||||
"args": [
|
||||
"${relativeFile}"
|
||||
],
|
||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
||||
"cwd": "${workspaceRoot}",
|
||||
"protocol": "inspector",
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
},
|
||||
{
|
||||
"name": "test.ts",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"args": [
|
||||
"test/test.ts"
|
||||
],
|
||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
||||
"cwd": "${workspaceRoot}",
|
||||
"protocol": "inspector",
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
"type": "node-terminal"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
35
changelog.md
Normal file
35
changelog.md
Normal file
@ -0,0 +1,35 @@
|
||||
# Changelog
|
||||
|
||||
## 2024-12-25 - 1.1.1 - fix(smartstatus)
|
||||
Remove all tslint:disable-next-line comments for max-classes-per-file rule
|
||||
|
||||
- Code cleanup by removing unnecessary tslint comments for disabling max-classes-per-file rule.
|
||||
|
||||
## 2024-12-25 - 1.1.0 - feat(ci)
|
||||
Set up GitHub Actions workflows for CI/CD
|
||||
|
||||
- Replaced GitLab CI with GitHub Actions for both tag and non-tag pushes.
|
||||
- Implemented npm audit for security checks on both production and development dependencies.
|
||||
- Enabled npm test and build steps as part of the CI workflow.
|
||||
|
||||
## 2024-05-29 - 1.0.12 - Documentation & Configuration
|
||||
Minor updates focusing on project configuration and descriptive metadata.
|
||||
|
||||
- Updated project description.
|
||||
- Updated tsconfig multiple times for improved TypeScript configurations.
|
||||
- Adjusted npmextra.json configuration for host consistency.
|
||||
|
||||
## 2021-08-19 to 2024-04-14 - 1.0.11 to 1.0.12 - Core Fixes & Maintenance
|
||||
A range of updates focused on core functionality and essential maintenance fixes across versions.
|
||||
|
||||
- Multiple core updates distributed across versions 1.0.7 to 1.0.12.
|
||||
|
||||
## 2019-01-02 to 2021-08-19 - 1.0.5 to 1.0.10 - Core Updates
|
||||
Core functionality was reviewed and updated multiple times to ensure stability and improved performance.
|
||||
|
||||
## 2017-04-06 to 2019-01-02 - 1.0.0 to 1.0.4 - Initial Development & Feature Implementations
|
||||
The initial stages of development including major feature implementations across status codes and basic framework setup.
|
||||
|
||||
- Initial setup completed with basic framework and configuration.
|
||||
- Implemented handling of 1xx to 5xx range of status codes.
|
||||
- Added continuous integration and initial testing protocols.
|
@ -1,33 +0,0 @@
|
||||
# smartstatus
|
||||
|
||||
status information in TypeScript
|
||||
|
||||
## Availabililty
|
||||
|
||||
[](https://www.npmjs.com/package/smartstatus)
|
||||
[](https://GitLab.com/pushrocks/smartstatus)
|
||||
[](https://github.com/pushrocks/smartstatus)
|
||||
[](https://pushrocks.gitlab.io/smartstatus/)
|
||||
|
||||
## Status for master
|
||||
|
||||
[](https://GitLab.com/pushrocks/smartstatus/commits/master)
|
||||
[](https://GitLab.com/pushrocks/smartstatus/commits/master)
|
||||
[](https://www.npmjs.com/package/smartstatus)
|
||||
[](https://david-dm.org/pushrocks/smartstatus)
|
||||
[](https://www.bithound.io/github/pushrocks/smartstatus/master/dependencies/npm)
|
||||
[](https://www.bithound.io/github/pushrocks/smartstatus)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](http://standardjs.com/)
|
||||
|
||||
## Usage
|
||||
|
||||
Use TypeScript for best in class instellisense.
|
||||
|
||||
For further information read the linked docs at the top of this README.
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||
|
||||
[](https://push.rocks)
|
@ -2,17 +2,36 @@
|
||||
"gitzone": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "gitlab.com",
|
||||
"gitscope": "pushrocks",
|
||||
"githost": "code.foss.global",
|
||||
"gitscope": "push.rocks",
|
||||
"gitrepo": "smartstatus",
|
||||
"shortDescription": "status information in TypeScript",
|
||||
"npmPackagename": "@pushrocks/smartstatus",
|
||||
"license": "MIT"
|
||||
"npmPackagename": "@push.rocks/smartstatus",
|
||||
"license": "MIT",
|
||||
"description": "A TypeScript library for managing HTTP status codes, providing detailed classes for each status to enhance HTTP error and response handling.",
|
||||
"keywords": [
|
||||
"TypeScript",
|
||||
"HTTP",
|
||||
"status codes",
|
||||
"error handling",
|
||||
"client errors",
|
||||
"server errors",
|
||||
"response management",
|
||||
"error management",
|
||||
"API development",
|
||||
"express.js",
|
||||
"web applications",
|
||||
"network services",
|
||||
"custom status codes"
|
||||
]
|
||||
}
|
||||
},
|
||||
"npmci": {
|
||||
"globalNpmTools": [],
|
||||
"npmRegistryUrl": "verdaccio.lossless.one",
|
||||
"npmAccessLevel": "public"
|
||||
},
|
||||
"tsdoc": {
|
||||
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
|
||||
}
|
||||
}
|
25862
package-lock.json
generated
25862
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
45
package.json
45
package.json
@ -1,30 +1,32 @@
|
||||
{
|
||||
"name": "@pushrocks/smartstatus",
|
||||
"version": "1.0.9",
|
||||
"name": "@push.rocks/smartstatus",
|
||||
"version": "1.1.1",
|
||||
"private": false,
|
||||
"description": "status information in TypeScript",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"description": "A TypeScript library for managing HTTP status codes, providing detailed classes for each status to enhance HTTP error and response handling.",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": "./dist_ts/index.js"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "(tstest test/)",
|
||||
"build": "tsbuild"
|
||||
"build": "tsbuild --web",
|
||||
"buildDocs": "tsdoc"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@gitlab.com/pkunz/smartstatus.git"
|
||||
"url": "git+https://code.foss.global/push.rocks/smartstatus.git"
|
||||
},
|
||||
"author": "Lossless GmbH",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://gitlab.com/pkunz/smartstatus/issues"
|
||||
"url": "https://code.foss.global/push.rocks/smartstatus/issues"
|
||||
},
|
||||
"homepage": "https://gitlab.com/pkunz/smartstatus#README",
|
||||
"homepage": "https://code.foss.global/push.rocks/smartstatus#readme",
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.25",
|
||||
"@gitzone/tstest": "^1.0.54",
|
||||
"@pushrocks/tapbundle": "^3.2.14",
|
||||
"tslint": "^6.1.3",
|
||||
"tslint-config-prettier": "^1.18.0"
|
||||
"@git.zone/tsbuild": "^2.1.25",
|
||||
"@git.zone/tsrun": "^1.3.3",
|
||||
"@git.zone/tstest": "^1.0.54",
|
||||
"@push.rocks/tapbundle": "^5.5.3"
|
||||
},
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
@ -40,5 +42,20 @@
|
||||
"cli.js",
|
||||
"npmextra.json",
|
||||
"readme.md"
|
||||
],
|
||||
"keywords": [
|
||||
"TypeScript",
|
||||
"HTTP",
|
||||
"status codes",
|
||||
"error handling",
|
||||
"client errors",
|
||||
"server errors",
|
||||
"response management",
|
||||
"error management",
|
||||
"API development",
|
||||
"express.js",
|
||||
"web applications",
|
||||
"network services",
|
||||
"custom status codes"
|
||||
]
|
||||
}
|
||||
|
9627
pnpm-lock.yaml
generated
Normal file
9627
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
1
readme.hints.md
Normal file
1
readme.hints.md
Normal file
@ -0,0 +1 @@
|
||||
|
237
readme.md
237
readme.md
@ -1,47 +1,220 @@
|
||||
# @pushrocks/smartstatus
|
||||
status information in TypeScript
|
||||
# @push.rocks/smartstatus
|
||||
|
||||
## Availabililty and Links
|
||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartstatus)
|
||||
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartstatus)
|
||||
* [github.com (source mirror)](https://github.com/pushrocks/smartstatus)
|
||||
* [docs (typedoc)](https://pushrocks.gitlab.io/smartstatus/)
|
||||
A TypeScript library for managing HTTP status information, with detailed status classes.
|
||||
|
||||
## Status for master
|
||||
## Install
|
||||
|
||||
Status Category | Status Badge
|
||||
-- | --
|
||||
GitLab Pipelines | [](https://lossless.cloud)
|
||||
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||
npm | [](https://lossless.cloud)
|
||||
Snyk | [](https://lossless.cloud)
|
||||
TypeScript Support | [](https://lossless.cloud)
|
||||
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
Code Style | [](https://lossless.cloud)
|
||||
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
||||
To install `@push.rocks/smartstatus`, use npm (or yarn, or pnpm) by running the following command in your terminal:
|
||||
|
||||
```sh
|
||||
npm install @push.rocks/smartstatus --save
|
||||
```
|
||||
|
||||
Ensure you have TypeScript and a package to work with TypeScript in your project. If not, you might want to install TypeScript and ts-node (for development purposes) to your project:
|
||||
|
||||
```sh
|
||||
npm install typescript ts-node --save-dev
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Use TypeScript for best in class instellisense.
|
||||
The `@push.rocks/smartstatus` library provides a structured and comprehensive way to handle HTTP status codes in TypeScript, enhancing your ability to manage HTTP responses effectively. Below, we outline an extensive set of scenarios demonstrating how you can leverage this module's capabilities to streamline and enrich your response handling from server-side applications to API endpoints.
|
||||
|
||||
For further information read the linked docs at the top of this README.
|
||||
### Getting Started
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||
To start using `@push.rocks/smartstatus`, ensure you import the module into your TypeScript files. Here's a basic import statement you can use:
|
||||
|
||||
[](https://push.rocks)
|
||||
```typescript
|
||||
import * as smartstatus from '@push.rocks/smartstatus';
|
||||
```
|
||||
|
||||
For more specific imports, such as obtaining particular HTTP status code classes, you may use:
|
||||
|
||||
## Contribution
|
||||
```typescript
|
||||
import { HttpStatus, Status404, Status200 } from '@push.rocks/smartstatus';
|
||||
```
|
||||
|
||||
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
|
||||
### Retrieving a Specific Status
|
||||
|
||||
For further information read the linked docs at the top of this readme.
|
||||
The library allows you to retrieve any HTTP status code with its corresponding information quickly. You can do this by using either a class representation for known statuses or using a method that fetches the status by its status code string.
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||
#### Example: Fetching 404 Not Found Status
|
||||
|
||||
[](https://maintainedby.lossless.com)
|
||||
Let's say you wish to work with the HTTP 404 "Not Found" status. You can retrieve its details as follows:
|
||||
|
||||
```typescript
|
||||
import { HttpStatus } from '@push.rocks/smartstatus';
|
||||
|
||||
const notFoundStatus = HttpStatus.getHttpStatusByString('404');
|
||||
console.log(notFoundStatus.code); // 404
|
||||
console.log(notFoundStatus.text); // Not Found
|
||||
console.log(notFoundStatus.description); // The requested resource could not be found but may be available in the future. Subsequent requests by the client are permissible.
|
||||
```
|
||||
|
||||
The `getHttpStatusByString` function dynamically returns an instance of the respective status class with fields like HTTP code, textual representation, and an insightful description of the status.
|
||||
|
||||
### Handling Errors Using HTTP Statuses
|
||||
|
||||
One of the most valuable features of `@push.rocks/smartstatus` is enriching error handling protocols in web applications or APIs. Let's illustrate how smartstatus can be used with an Express.js framework to enhance HTTP response management, specifically handling different HTTP error statuses.
|
||||
|
||||
#### Example: Implementing with Express.js
|
||||
|
||||
Imagine you are developing a web service, and a specific operation fails due to an authorization issue. Here's how you might use smartstatus to handle this error gracefully:
|
||||
|
||||
```typescript
|
||||
import express from 'express';
|
||||
import { HttpStatus } from '@push.rocks/smartstatus';
|
||||
|
||||
const app = express();
|
||||
|
||||
app.get('/secure/data', (req, res) => {
|
||||
// Simulating an authorization failure condition
|
||||
const userIsAuthorized = false;
|
||||
|
||||
if (!userIsAuthorized) {
|
||||
const unauthorizedStatus = HttpStatus.getHttpStatusByString('401');
|
||||
res.status(unauthorizedStatus.code).json({
|
||||
error: unauthorizedStatus.text,
|
||||
message: unauthorizedStatus.description,
|
||||
});
|
||||
} else {
|
||||
res.status(200).send('Secure Data');
|
||||
}
|
||||
});
|
||||
|
||||
app.listen(3000, () => {
|
||||
console.log('Server running on port 3000');
|
||||
});
|
||||
```
|
||||
|
||||
In this express app endpoint, if the user is not authorized to access the resource, it responds with a 401 Unauthorized status. This status code is enriched with a detailed message derived from smartstatus, providing a helpful explanation to API consumers.
|
||||
|
||||
### Extending with Custom Statuses
|
||||
|
||||
While `@push.rocks/smartstatus` covers standard HTTP statuses, the library also allows you to define and manage custom status codes tailored to specific application needs. This is particularly useful for internal APIs requiring bespoke statuses.
|
||||
|
||||
#### Example: Creating a Custom HTTP Status
|
||||
|
||||
Let's say you want to create a unique status for indicating a special condition encountered by your application, such as a "Processing Error" that is represented by code 499. Define a custom status class as follows:
|
||||
|
||||
```typescript
|
||||
import { HttpStatus } from '@push.rocks/smartstatus';
|
||||
|
||||
class Status499 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
code: 499,
|
||||
text: 'Processing Error',
|
||||
description:
|
||||
'The server encountered a processing error which prevented it from completing the request.',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Register the custom status for use
|
||||
HttpStatus.addStatus('499', Status499);
|
||||
|
||||
// Usage of the custom status
|
||||
const processingErrorStatus = HttpStatus.getHttpStatusByString('499');
|
||||
console.log(`${processingErrorStatus.code} ${processingErrorStatus.text}`); // 499 Processing Error
|
||||
```
|
||||
|
||||
This custom status can then be used in the same way as predefined statuses in the library, allowing you to handle unique responses efficiently.
|
||||
|
||||
### Comprehensive Examples Across HTTP Status Ranges
|
||||
|
||||
The `smartstatus` library classifies statuses across different ranges (1xx, 2xx, 3xx, 4xx, and 5xx). Here, we will demonstrate how to handle each of these categories to provide robustness in response management.
|
||||
|
||||
#### Informational Responses (1xx)
|
||||
|
||||
Status codes in the 1xx range inform the client about the progress of the request. These are mostly used in scenarios involving continuation or switching protocols.
|
||||
|
||||
```typescript
|
||||
import { Status100 } from '@push.rocks/smartstatus';
|
||||
|
||||
// Handling 100 Continue status
|
||||
const continueStatus = new Status100();
|
||||
console.log(continueStatus.code, continueStatus.text, continueStatus.description);
|
||||
```
|
||||
|
||||
#### Successful Responses (2xx)
|
||||
|
||||
The 2xx successes indicate that the client's request was received, understood, and accepted. Utilizing these codes effectively can aid in confirming successful API operations.
|
||||
|
||||
```typescript
|
||||
import { Status200, Status201 } from '@push.rocks/smartstatus';
|
||||
|
||||
// 200 OK status for successfully processed requests
|
||||
const okStatus = new Status200();
|
||||
console.log(okStatus.code, okStatus.text, okStatus.description);
|
||||
|
||||
// 201 Created status for resource creation
|
||||
const createdStatus = new Status201();
|
||||
console.log(createdStatus.code, createdStatus.text, createdStatus.description);
|
||||
```
|
||||
|
||||
#### Redirection Messages (3xx)
|
||||
|
||||
Statuses in the 3xx range indicate redirection, offering guidance on how the client can access different resources or follow up with another request.
|
||||
|
||||
```typescript
|
||||
import { Status301, Status302 } from '@push.rocks/smartstatus';
|
||||
|
||||
// Permanent and Temporary redirects
|
||||
const movedPermanentlyStatus = new Status301();
|
||||
console.log(movedPermanentlyStatus.text); // Moved Permanently
|
||||
|
||||
const foundStatus = new Status302();
|
||||
console.log(foundStatus.text); // Found
|
||||
```
|
||||
|
||||
#### Client Error Responses (4xx)
|
||||
|
||||
This class of status codes is intended to inform the client that the error seems to have been caused by the client, such as a malformed request.
|
||||
|
||||
```typescript
|
||||
import { Status400, Status404 } from '@push.rocks/smartstatus';
|
||||
|
||||
// Using 400 Bad Request for malformed requests
|
||||
const badRequestStatus = new Status400();
|
||||
console.log(badRequestStatus.description);
|
||||
|
||||
// Handling 404 Not Found for missing resources
|
||||
const notFoundStatus = new Status404();
|
||||
console.log(notFoundStatus.description);
|
||||
```
|
||||
|
||||
#### Server Error Responses (5xx)
|
||||
|
||||
5xx indicates server-side errors, signaling the server is aware it encountered an error or is otherwise incapable of performing the request.
|
||||
|
||||
```typescript
|
||||
import { Status500, Status503 } from '@push.rocks/smartstatus';
|
||||
|
||||
// Internal server error handling
|
||||
const internalServerErrorStatus = new Status500();
|
||||
console.log(internalServerErrorStatus.text);
|
||||
|
||||
// Service unavailable handling with a 503 response
|
||||
const serviceUnavailableStatus = new Status503();
|
||||
console.log(serviceUnavailableStatus.description);
|
||||
```
|
||||
|
||||
## License and Legal Information
|
||||
|
||||
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
|
||||
|
||||
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
||||
|
||||
### Trademarks
|
||||
|
||||
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
|
||||
|
||||
### Company Information
|
||||
|
||||
Task Venture Capital GmbH
|
||||
Registered at District court Bremen HRB 35230 HB, Germany
|
||||
|
||||
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
||||
|
||||
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
import { expect, tap } from '@push.rocks/tapbundle';
|
||||
|
||||
import * as smartstatus from '../ts/index';
|
||||
import * as smartstatus from '../ts/index.js';
|
||||
|
||||
tap.test('should get a status by codeString', async () => {
|
||||
const status = smartstatus.HttpStatus.getHttpStatusByString('404');
|
||||
|
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @push.rocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartstatus',
|
||||
version: '1.1.1',
|
||||
description: 'A TypeScript library for managing HTTP status codes, providing detailed classes for each status to enhance HTTP error and response handling.'
|
||||
}
|
@ -1 +1,7 @@
|
||||
export * from './smartstatus.classes.http';
|
||||
export * from './smartstatus.classes.http.1xx.js';
|
||||
export * from './smartstatus.classes.http.2xx.js';
|
||||
export * from './smartstatus.classes.http.3xx.js';
|
||||
export * from './smartstatus.classes.http.4xx.js';
|
||||
export * from './smartstatus.classes.http.5xx.js';
|
||||
|
||||
export * from './smartstatus.classes.http.js';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { HttpStatus, TStatusGroup } from './smartstatus.classes.http';
|
||||
import { HttpStatus, type TStatusGroup } from './smartstatus.classes.http.js';
|
||||
|
||||
export class Status100 extends HttpStatus {
|
||||
constructor() {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { HttpStatus, TStatusGroup } from './smartstatus.classes.http';
|
||||
import { HttpStatus, type TStatusGroup } from './smartstatus.classes.http.js';
|
||||
|
||||
export class Status200 extends HttpStatus {
|
||||
constructor() {
|
||||
@ -14,7 +14,6 @@ export class Status200 extends HttpStatus {
|
||||
}
|
||||
HttpStatus.addStatus('200', Status200);
|
||||
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status201 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
@ -26,7 +25,6 @@ export class Status201 extends HttpStatus {
|
||||
}
|
||||
HttpStatus.addStatus('201', Status201);
|
||||
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status202 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
@ -39,7 +37,6 @@ export class Status202 extends HttpStatus {
|
||||
}
|
||||
HttpStatus.addStatus('202', Status202);
|
||||
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status203 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
@ -52,7 +49,6 @@ export class Status203 extends HttpStatus {
|
||||
}
|
||||
HttpStatus.addStatus('203', Status203);
|
||||
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status204 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
@ -64,7 +60,6 @@ export class Status204 extends HttpStatus {
|
||||
}
|
||||
HttpStatus.addStatus('204', Status204);
|
||||
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status205 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
@ -77,7 +72,6 @@ export class Status205 extends HttpStatus {
|
||||
}
|
||||
HttpStatus.addStatus('205', Status205);
|
||||
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status206 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
@ -92,7 +86,6 @@ export class Status206 extends HttpStatus {
|
||||
}
|
||||
HttpStatus.addStatus('206', Status206);
|
||||
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status207 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
@ -106,7 +99,6 @@ export class Status207 extends HttpStatus {
|
||||
}
|
||||
HttpStatus.addStatus('207', Status207);
|
||||
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status208 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
@ -120,7 +112,6 @@ export class Status208 extends HttpStatus {
|
||||
}
|
||||
HttpStatus.addStatus('208', Status208);
|
||||
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status226 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { HttpStatus, TStatusGroup } from './smartstatus.classes.http';
|
||||
import { HttpStatus, type TStatusGroup } from './smartstatus.classes.http.js';
|
||||
|
||||
export class Status300 extends HttpStatus {
|
||||
constructor() {
|
||||
@ -14,7 +14,6 @@ export class Status300 extends HttpStatus {
|
||||
}
|
||||
HttpStatus.addStatus('300', Status300);
|
||||
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status301 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
@ -26,7 +25,6 @@ export class Status301 extends HttpStatus {
|
||||
}
|
||||
HttpStatus.addStatus('301', Status301);
|
||||
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status302 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
@ -43,7 +41,6 @@ export class Status302 extends HttpStatus {
|
||||
}
|
||||
HttpStatus.addStatus('302', Status302);
|
||||
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status303 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
@ -58,7 +55,6 @@ export class Status303 extends HttpStatus {
|
||||
}
|
||||
HttpStatus.addStatus('303', Status303);
|
||||
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status304 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
@ -73,7 +69,6 @@ export class Status304 extends HttpStatus {
|
||||
}
|
||||
HttpStatus.addStatus('304', Status304);
|
||||
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status305 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
@ -88,7 +83,6 @@ export class Status305 extends HttpStatus {
|
||||
}
|
||||
HttpStatus.addStatus('305', Status305);
|
||||
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status306 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
@ -100,7 +94,6 @@ export class Status306 extends HttpStatus {
|
||||
}
|
||||
HttpStatus.addStatus('306', Status306);
|
||||
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status307 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
@ -116,7 +109,6 @@ export class Status307 extends HttpStatus {
|
||||
}
|
||||
HttpStatus.addStatus('307', Status307);
|
||||
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status308 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { HttpStatus, TStatusGroup } from './smartstatus.classes.http';
|
||||
import { HttpStatus, type TStatusGroup } from './smartstatus.classes.http.js';
|
||||
|
||||
export class Status400 extends HttpStatus {
|
||||
constructor() {
|
||||
@ -11,7 +11,6 @@ export class Status400 extends HttpStatus {
|
||||
}
|
||||
HttpStatus.addStatus('400', Status400);
|
||||
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status401 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
@ -24,7 +23,6 @@ export class Status401 extends HttpStatus {
|
||||
}
|
||||
HttpStatus.addStatus('401', Status401);
|
||||
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status402 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
@ -36,7 +34,6 @@ export class Status402 extends HttpStatus {
|
||||
}
|
||||
HttpStatus.addStatus('402', Status402);
|
||||
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status403 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
@ -48,7 +45,6 @@ export class Status403 extends HttpStatus {
|
||||
}
|
||||
HttpStatus.addStatus('403', Status403);
|
||||
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status404 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
@ -60,7 +56,6 @@ export class Status404 extends HttpStatus {
|
||||
}
|
||||
HttpStatus.addStatus('404', Status404);
|
||||
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status429 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { HttpStatus, TStatusGroup } from './smartstatus.classes.http';
|
||||
import { HttpStatus, type TStatusGroup } from './smartstatus.classes.http.js';
|
||||
|
||||
export class Status500 extends HttpStatus {
|
||||
constructor() {
|
||||
@ -12,7 +12,6 @@ export class Status500 extends HttpStatus {
|
||||
}
|
||||
HttpStatus.addStatus('500', Status500);
|
||||
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status501 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
@ -24,7 +23,6 @@ export class Status501 extends HttpStatus {
|
||||
}
|
||||
HttpStatus.addStatus('501', Status501);
|
||||
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status502 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
@ -36,7 +34,6 @@ export class Status502 extends HttpStatus {
|
||||
}
|
||||
HttpStatus.addStatus('502', Status502);
|
||||
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status503 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
@ -48,7 +45,6 @@ export class Status503 extends HttpStatus {
|
||||
}
|
||||
HttpStatus.addStatus('503', Status503);
|
||||
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status504 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
@ -61,7 +57,6 @@ export class Status504 extends HttpStatus {
|
||||
}
|
||||
HttpStatus.addStatus('504', Status504);
|
||||
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status505 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
@ -73,7 +68,6 @@ export class Status505 extends HttpStatus {
|
||||
}
|
||||
HttpStatus.addStatus('505', Status505);
|
||||
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status506 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
@ -86,7 +80,6 @@ export class Status506 extends HttpStatus {
|
||||
|
||||
HttpStatus.addStatus('506', Status506);
|
||||
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status507 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
@ -99,7 +92,6 @@ export class Status507 extends HttpStatus {
|
||||
|
||||
HttpStatus.addStatus('507', Status507);
|
||||
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status508 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
@ -111,7 +103,6 @@ export class Status508 extends HttpStatus {
|
||||
}
|
||||
HttpStatus.addStatus('508', Status508);
|
||||
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status510 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
@ -122,7 +113,6 @@ export class Status510 extends HttpStatus {
|
||||
}
|
||||
}
|
||||
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class Status511 extends HttpStatus {
|
||||
constructor() {
|
||||
super({
|
||||
|
@ -6,7 +6,17 @@ export class HttpStatus {
|
||||
HttpStatus.statusMap[statusStringArg] = statusArg;
|
||||
}
|
||||
public static getHttpStatusByString(codeStringArg: string): HttpStatus {
|
||||
const statusInstance = new HttpStatus.statusMap[codeStringArg]();
|
||||
let statusInstance: HttpStatus;
|
||||
try {
|
||||
statusInstance = new HttpStatus.statusMap[codeStringArg]();
|
||||
} catch {
|
||||
console.log('unknown status');
|
||||
return new HttpStatus({
|
||||
code: 0,
|
||||
text: 'unknown status',
|
||||
description: `The status ${codeStringArg} is not known.`,
|
||||
});
|
||||
}
|
||||
return statusInstance;
|
||||
}
|
||||
public code: number;
|
||||
@ -18,9 +28,3 @@ export class HttpStatus {
|
||||
this.description = optionsArg.description;
|
||||
}
|
||||
}
|
||||
|
||||
export * from './smartstatus.classes.http.1xx';
|
||||
export * from './smartstatus.classes.http.2xx';
|
||||
export * from './smartstatus.classes.http.3xx';
|
||||
export * from './smartstatus.classes.http.4xx';
|
||||
export * from './smartstatus.classes.http.5xx';
|
||||
|
16
tsconfig.json
Normal file
16
tsconfig.json
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"baseUrl": ".",
|
||||
"paths": {}
|
||||
},
|
||||
"exclude": [
|
||||
"dist_*/**/*.d.ts"
|
||||
]
|
||||
}
|
17
tslint.json
17
tslint.json
@ -1,17 +0,0 @@
|
||||
{
|
||||
"extends": ["tslint:latest", "tslint-config-prettier"],
|
||||
"rules": {
|
||||
"semicolon": [true, "always"],
|
||||
"no-console": false,
|
||||
"ordered-imports": false,
|
||||
"object-literal-sort-keys": false,
|
||||
"member-ordering": {
|
||||
"options":{
|
||||
"order": [
|
||||
"static-method"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"defaultSeverity": "warning"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user