update tsconfig

This commit is contained in:
Philipp Kunz 2024-04-14 18:24:47 +02:00
parent 5ec5d0a928
commit 7def0b01b0
4 changed files with 126 additions and 34 deletions

View File

@ -7,7 +7,18 @@
"gitrepo": "smartstatus",
"shortDescription": "status information in TypeScript",
"npmPackagename": "@push.rocks/smartstatus",
"license": "MIT"
"license": "MIT",
"description": "A TypeScript library for managing HTTP status information, with detailed status classes.",
"keywords": [
"TypeScript",
"HTTP status",
"error handling",
"client errors",
"server errors",
"status codes",
"HTTP response",
"HTTP request"
]
}
},
"npmci": {
@ -15,7 +26,7 @@
"npmRegistryUrl": "verdaccio.lossless.one",
"npmAccessLevel": "public"
},
"tsdocs": {
"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"
}
}

View File

@ -2,7 +2,7 @@
"name": "@push.rocks/smartstatus",
"version": "1.0.12",
"private": false,
"description": "status information in TypeScript",
"description": "A TypeScript library for managing HTTP status information, with detailed status classes.",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"scripts": {
@ -40,5 +40,15 @@
"cli.js",
"npmextra.json",
"readme.md"
],
"keywords": [
"TypeScript",
"HTTP status",
"error handling",
"client errors",
"server errors",
"status codes",
"HTTP response",
"HTTP request"
]
}

1
readme.hints.md Normal file
View File

@ -0,0 +1 @@

132
readme.md
View File

@ -1,47 +1,117 @@
# @pushrocks/smartstatus
# @push.rocks/smartstatus
status information in TypeScript
## 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/)
## Install
## Status for master
To install `@push.rocks/smartstatus`, you can use npm (or yarn, or pnpm) by running the following command in your terminal:
Status Category | Status Badge
-- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/smartstatus/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartstatus/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/smartstatus)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smartstatus)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@pushrocks/smartstatus)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/smartstatus)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/smartstatus)](https://lossless.cloud)
Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud)
```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 add TypeScript and ts-node (for a start) to your project:
```sh
npm install typescript ts-node --save-dev
```
## Usage
Use TypeScript for best in class instellisense.
Using `@push.rocks/smartstatus` allows you to handle HTTP status codes more effectively in TypeScript. Below are examples detailing how to utilize this module in various scenarios.
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)
Ensure you import the module into your TypeScript file:
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://push.rocks)
```typescript
import * as smartstatus from '@push.rocks/smartstatus';
```
### Retrieving a Specific Status
## Contribution
You can retrieve specific HTTP status information by using its respective class or a convenient method for fetching it by the status code string.
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). :)
#### Example: Fetching 404 Not Found Status
For further information read the linked docs at the top of this readme.
```typescript
import { HttpStatus } from '@push.rocks/smartstatus';
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
const notFoundStatus = smartstatus.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.
```
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)
This method `getHttpStatusByString` dynamically returns an instance of the respective status class filled with relevant data such as the HTTP code, text, and a descriptive message.
### Handling Errors with HTTP Statuses
When building a web application or an API, handling different HTTP statuses becomes crucial. Here's an example of how you could use `smartstatus` to enrich error handling in your Express.js app:
```typescript
import express from 'express';
import { HttpStatus } from '@push.rocks/smartstatus';
const app = express();
app.get('/some/endpoint', (req, res) => {
// Some logic that might fail
if (someConditionNotMet) {
const unauthorizedStatus = HttpStatus.getHttpStatusByString('401');
res.status(unauthorizedStatus.code).json({
error: unauthorizedStatus.text,
message: unauthorizedStatus.description,
});
}
});
```
In the above scenario, if a specific condition is not met (implying some authorization failure), we respond with a 401 Unauthorized status, along with a message detailing the issue.
### Extending with Custom Statuses
While `@push.rocks/smartstatus` provides a structured manner to handle known HTTP statuses, there might be scenarios where you need custom statuses for internal signaling or specialized clients.
Extending or adding new statuses is straightforward:
```typescript
import { HttpStatus } from '@push.rocks/smartstatus';
class Status418 extends HttpStatus {
constructor() {
super({ code: 418, text: 'I'm a teapot', description: 'The requested entity body is short and stout. Tip me over and pour me out.' });
}
}
// Register the custom status
HttpStatus.addStatus('418', Status418);
// Retrieve and use the custom status
const customStatus = HttpStatus.getHttpStatusByString('418');
console.log(`${customStatus.code} ${customStatus.text}`); // 418 I'm a teapot
```
This approach ensures that your application can manage both standard and custom status codes effectively, maintaining a clear and expressive way to handle HTTP responses.
### Conclusion
By integrating `@push.rocks/smartstatus` into your TypeScript applications, you gain a powerful tool to manage HTTP status codes, improving the readability and maintainability of your code when dealing with HTTP responses. Whether you are building web applications, APIs, or services, `smartstatus` offers a structured approach to handling success and error states across your application.
## 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.