Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sigmasoldi3r/ts-entry-point
A simple typescript decorator that makes OOP-like execution easier for class-contained, asyncrhonous entry points.
https://github.com/sigmasoldi3r/ts-entry-point
Last synced: about 1 month ago
JSON representation
A simple typescript decorator that makes OOP-like execution easier for class-contained, asyncrhonous entry points.
- Host: GitHub
- URL: https://github.com/sigmasoldi3r/ts-entry-point
- Owner: sigmasoldi3r
- License: mit
- Created: 2021-10-05T09:26:23.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2021-10-05T10:31:51.000Z (about 3 years ago)
- Last Synced: 2024-11-16T03:25:44.354Z (about 2 months ago)
- Language: JavaScript
- Size: 14.6 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Entry point ![Typescript][ts]
![Maintained][maintained]
![License][license]
![Version][ver]Zero dependency, simple typescript decorator that makes OOP-like execution easier for class-contained, asyncrhonous entry points.
This is specially oriented to node CLI apps, that need a "main" method that usually is asyncrhonous. But can be synchronous and the environment can be the browser alike.
Also, in case that you're running the process in NodeJS, you'll receive an `args` array, from process.
## Examples
You'll need to enable experimental decorators via `experimentalDecorators` and `Es6` target is recommended (Lower versions might lack builtin `Promise` objects):
```json
{
"compilerOptions": {
"experimentalDecorators": true,
"target": "ES6"
}
}
```Example of usage:
```typescript
import entry from 'ts-entry-point'/**
* Classical entry point main class.
*/
@entry
class Main {
static main(args: string[]) {
console.log(`Hello wordl! arg count = ${args.length}`)
}
}
```See `example.ts` for more insight.
## Contributing
Right now the setup for the TS compiler constraints is quite loose, feel free to open a pull request to make the project more compatible across different setups.
[ts]: https://img.shields.io/badge/TypeScript-007ACC?style=for-the-badge&logo=typescript&logoColor=white
[maintained]: https://img.shields.io/badge/Maintained%3F-yes-green.svg
[license]: https://img.shields.io/github/license/sigmasoldi3r/ts-entry-point.svg
[ver]: https://img.shields.io/npm/v/ts-entry-point.svg