Skip to content

Commit

Permalink
Merge pull request #12 from StatelessStudio/v2.1.0
Browse files Browse the repository at this point in the history
V2.1.0
  • Loading branch information
DrewImm authored Apr 29, 2022
2 parents a833d40 + 94cbb91 commit 9833516
Show file tree
Hide file tree
Showing 11 changed files with 6,324 additions and 904 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
}
],
"rules": {
"no-console": 1,
"no-debugger": 1,
"curly": 2,
"indent": [2, "tab"],
"max-len": [1, 80],
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: node_js
node_js:
- "12.13.0"
- 16
install:
- npm install --ignore-scripts
after_success:
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# ts-async-bootstrap

## [2.1.0]

### Additions
- [Issue #11] onComplete should accept functions that return Promise
- [Issue #10] BootstrapFunction should accept return type void or Promise<void>
- [Issue #9] Add bootstrap class for cleaner extension
- [Issue #8] Add teardown method and handlers
- [Issue #7] Add onFinally method

### Fixes
- [Issue #6] Readme example should show import

## [2.0.0]

### Breaking Changes
Expand Down
32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ When writing node applications, it's a good idea to split up your initialization

`npm i ts-async-bootstrap`

**Usage**
**Usage (Option 1)**

```typescript
import { bootstrap } from '../src';

async function setup(): Promise<void> {
// TODO: Setup some stuff!
}
Expand All @@ -37,6 +39,30 @@ bootstrap({
});
```

**Usage (Option 2)**

```typescript
import { Bootstrap } from 'ts-async-bootstrap';

class AppBootstrap extends Bootstrap {
register = () => {
// TODO: Setup some stuff!
}

onError = (e: Error) => {
// TODO: Log some stuff!
}
}

async function main(): Promise<void> {
// TODO: Run some stuff!
}

export const app = new AppBootstrap();
app.boot(main);

```

## Lifecycle

### Register
Expand All @@ -57,3 +83,7 @@ If an exception is thrown or a promise is rejected during register or run, the e
- If `shouldExitOnError` is true (default), the application will exit with a non-zero exit code
- If `errorHandler` is not set, `console.error` will be used to log the error
- If the error occured in the register function, the run function will not be called

### Finally

Regardless of success or fail, `onFinally` will run after `onComplete` or `errorHandler`.
2 changes: 1 addition & 1 deletion nodemon.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"dist"
],
"watch": [ "src/", "*.*", ".env" ],
"exec": "npm start",
"exec": "node_modules/.bin/ts-node src",
"ext": "*"
}
Loading

0 comments on commit 9833516

Please sign in to comment.