update tsconfig

This commit is contained in:
Philipp Kunz 2024-04-14 17:48:18 +02:00
parent 1c29500a2a
commit fc93cdcbd1
4 changed files with 120 additions and 21 deletions

View File

@ -7,14 +7,23 @@
"shortDescription": "a module handling lifecycle events",
"npmPackagename": "@push.rocks/smartlifecycle",
"license": "MIT",
"projectDomain": "push.rocks"
"projectDomain": "push.rocks",
"description": "a module handling lifecycle events",
"keywords": [
"lifecycle",
"events",
"module",
"typescript",
"development",
"npm package"
]
}
},
"npmci": {
"npmGlobalTools": [],
"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

@ -20,5 +20,13 @@
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0"
},
"dependencies": {}
"dependencies": {},
"keywords": [
"lifecycle",
"events",
"module",
"typescript",
"development",
"npm package"
]
}

1
readme.hints.md Normal file
View File

@ -0,0 +1 @@

117
readme.md
View File

@ -1,26 +1,107 @@
# @pushrocks/smartlifecycle
# @push.rocks/smartlifecycle
a module handling lifecycle events
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartlifecycle)
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartlifecycle)
* [github.com (source mirror)](https://github.com/pushrocks/smartlifecycle)
* [docs (typedoc)](https://pushrocks.gitlab.io/smartlifecycle/)
## Install
## Status for master
[![build status](https://gitlab.com/pushrocks/smartlifecycle/badges/master/build.svg)](https://gitlab.com/pushrocks/smartlifecycle/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartlifecycle/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartlifecycle/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartlifecycle.svg)](https://www.npmjs.com/package/@pushrocks/smartlifecycle)
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartlifecycle/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartlifecycle)
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/)
To install `@push.rocks/smartlifecycle`, use npm:
```sh
npm install @push.rocks/smartlifecycle
```
This will download the package and add it to your project's `node_modules` folder. It will also add an entry to your project's `package.json` file, assuming you have one.
## Usage
For further information read the linked docs at the top of this readme.
The `@push.rocks/smartlifecycle` module is designed to assist in handling various lifecycle events within your application, making it easier to manage startup, shutdown, and other lifecycle states cleanly and effectively. While the module contents are minimal as indicated by the current `index.ts` and `smartlifecycle.plugins.ts` files, we will explore a conceptual use case to demonstrate how you could extend and implement lifecycle management in a TypeScript application.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
### Getting Started
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://maintainedby.lossless.com)
Firstly, ensure that you are importing the module in your TypeScript file:
```typescript
import * as smartLifecycle from '@push.rocks/smartlifecycle';
```
Given the current implementation does not elaborate on specific lifecycle events, lets conceptualize a scenario where our application needs to perform specific actions on startup and shutdown.
### Implementing Lifecycle Management
Consider an application that needs to connect to a database on startup and properly disconnect when shutting down to prevent data loss or corruption. We'll also assume that logging and running some cleanup tasks are part of the requirements.
#### Define Lifecycle Handlers
First, we'll define our lifecycle handlers:
```typescript
import * as fs from 'fs/promises';
import * as db from 'your-favorite-db-client'; // Placeholder for your actual DB client import
// Startup handler
async function onStart(): Promise<void> {
console.log('Application is starting...');
await db.connect();
console.log('Connected to database.');
}
// Shutdown handler
async function onShutdown(): Promise<void> {
console.log('Application is shutting down...');
await db.disconnect();
// Cleanup tasks
await fs.unlink('/path/to/temporary/file');
console.log('Disconnected from database and cleaned up temporary files.');
}
// Usage
onStart().catch(err => console.error('Startup failed:', err));
```
#### Handling Process Signals
To ensure your application reacts to shutdown signals (e.g., `SIGINT` from pressing Ctrl+C), you can catch these and invoke the `onShutdown` method:
```typescript
process.on('SIGINT', () => {
onShutdown()
.then(() => {
console.log('Graceful shutdown completed.');
process.exit(0);
})
.catch(err => {
console.error('Failed to shutdown gracefully:', err);
process.exit(1);
});
});
```
### Extending the Module
While the current implementation of `@push.rocks/smartlifecycle` shown in the source code may not directly expose lifecycle events, you can extend the module by contributing to its Git repository or by wrapping it in your higher-level lifecycle management system within your application.
The conceptual implementation here demonstrates how you might use basic features of the module (as it stands) in conjunction with other application logic to manage your application's lifecycle. Adjust and expand upon these concepts based on your specific use cases and requirements.
### Conclusion
`@push.rocks/smartlifecycle` provides a foundational starting point for managing lifecycle events in your TypeScript applications. By following the practices outlined above, you can ensure that your application handles startup and shutdown processes gracefully, maintaining a robust and efficient operational state. As the module evolves, look to its documentation and source code for new features and improvements that can simplify lifecycle management in your projects even further.
## 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.