forked from odavid/typeorm-transactional-cls-hooked
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Remove `bindEmitter` call After doing research on what `bindEmitter` does, I could not see the benefits of using it. At the time the hooks run, the transaction is already over. There seem to be no reason to preserve store context for userland use. All current tests pass. There is no mention of preserved context in the README, therefore this should be treated as internal change. This change is motivated by the fact AsyncLocalStorage does not support `bindEmitter` out of the box and without understanding the end goal it is not feasible to properly reimplement it. If at any point in the future a viable use-case is provided, the bindEmitter can easily be restored. * Add StorageLayer interface and implementations This change introduces a concept of StorageLayer, an interface which can be implemented using various storage providers. Currently the implementations include AsyncLocalStorage and cls-hooked. * Abstract direct cls-hooked use with StorageLayer This commit abstracts the use of cls-hooked to StorageLayer. It also updates the StorageLayer provider to always use cls-hooked implementation, as AsyncLocalStorage implementation does not pass tests yet. * Implement AsyncLocalStorage The change implements AsyncLocalStorage driver, which passes all existing tests. As the actual logic relies on cls-hooked behavior a Store class is introduces to emulate it within AsyncLocalStorage. * Rename `implementation` to `driver`. Separating name refactor out of previous commit for readability * Allow users to specify StorageDriver * Add env to determine StorageDriver in test * Default to CLS_HOOKED when no option specified * Uninstall cross-env * Typo in getBestSupportedDriverConstructor * Remove TODO from error message * Update comment * fix: remove unsupported node: protocol * cicd: add matrix strategy to ci pipeline * docs: describe StorageDriver enum in the readme --------- Co-authored-by: aliheym <aliheym.dev@gmail.com>
- Loading branch information
Showing
17 changed files
with
2,892 additions
and
1,116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,41 @@ | ||
name: main | ||
on: [push] | ||
|
||
jobs: | ||
main: | ||
tests: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
version: ['12.x', '18.x', '20.x'] | ||
storageDriver: ['ASYNC_LOCAL_STORAGE', 'CLS_HOOKED'] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Check If Tag | ||
id: check-tag | ||
run: |- | ||
if [[ ${{ github.event.ref }} =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
echo ::set-output name=match::true | ||
fi | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/setup-node@v1 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: '12.x' | ||
node-version: ${{ matrix.version }} | ||
registry-url: 'https://registry.npmjs.org' | ||
|
||
- name: Install | ||
run: npm install | ||
|
||
- name: Test | ||
run: npm test | ||
env: | ||
TEST_STORAGE_DRIVER: ${{ matrix.storageDriver }} | ||
|
||
publish: | ||
if: startsWith(github.event.ref, 'refs/tags/v') | ||
needs: tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Install | ||
run: npm install | ||
|
||
- name: Build | ||
run: npm run build | ||
|
||
- name: Publish | ||
if: steps.check-tag.outputs.match == 'true' | ||
run: npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.