-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
33 changed files
with
1,009 additions
and
16 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
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
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
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,6 +1,6 @@ | ||
{ | ||
"name": "@powership/boilerplate", | ||
"version": "3.1.5", | ||
"version": "3.1.7", | ||
"author": "antoniopresto <[email protected]>", | ||
"sideEffects": false, | ||
"#type": "module", | ||
|
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
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
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
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,6 +1,6 @@ | ||
{ | ||
"name": "logstorm", | ||
"version": "3.1.5", | ||
"version": "3.1.7", | ||
"typings": "out", | ||
"author": "antoniopresto <[email protected]>", | ||
"#type": "module", | ||
|
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
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('@powership/boilerplate/babel-config.cjs') |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('@powership/boilerplate/eslintrc.cjs') |
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 |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# See https://help.github.com/ignore-files/ for more about ignoring files. | ||
|
||
.idea | ||
/lib | ||
|
||
# VisualStudioCode.gitignore | ||
# See https://github.com/github/gitignore/blob/master/Global/VisualStudioCode.gitignore | ||
.vscode/* | ||
!.vscode/settings.json | ||
!.vscode/tasks.json | ||
!.vscode/launch.json | ||
!.vscode/extensions.json | ||
/generated | ||
|
||
# dependencies | ||
/node_modules | ||
|
||
# testing | ||
/coverage | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Xcode | ||
# | ||
build/ | ||
*.pbxuser | ||
!default.pbxuser | ||
*.mode1v3 | ||
!default.mode1v3 | ||
*.mode2v3 | ||
!default.mode2v3 | ||
*.perspectivev3 | ||
!default.perspectivev3 | ||
xcuserdata | ||
*.xccheckout | ||
*.moved-aside | ||
DerivedData | ||
*.hmap | ||
*.ipa | ||
*.xcuserstate | ||
project.xcworkspace | ||
|
||
# Android/IJ | ||
# | ||
.gradle | ||
local.properties | ||
|
||
# node.js | ||
# | ||
npm-debug.log | ||
yarn-error.log | ||
|
||
# BUCK | ||
buck-out/ | ||
\.buckd/ | ||
android/app/libs | ||
android/keystores/debug.keystore | ||
|
||
lib/ | ||
webpack-assets.json | ||
webpack-stats.json | ||
*.swp | ||
|
||
# Modern Relay | ||
__generated__ |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
18 |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"singleQuote": true, | ||
"printWidth": 80 | ||
} |
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# PluginEngine | ||
|
||
PluginEngine is a TypeScript library designed for extensible application architecture. | ||
It employs a Publish-Subscribe pattern with middleware support, allowing for a decoupled, | ||
event-driven architecture. | ||
|
||
```typescript | ||
import { PluginEngine, Plugin } from 'plugin-engine'; | ||
|
||
// Initialize PluginEngine | ||
const engine = new PluginEngine<{ httpRequest: { request: string } }>(); | ||
|
||
// Define a logging plugin with 'enter' hook | ||
const logPlugin: Plugin<{ request: string }> = { | ||
name: 'Log', | ||
enter: (data, context) => { | ||
console.log(`Request: ${data.request}`); | ||
// 'context.abortWith' can be used to short-circuit the event chain | ||
}, | ||
}; | ||
|
||
// Register the plugin to an 'httpRequest' event | ||
engine.on('httpRequest', logPlugin); | ||
|
||
// Define a modification plugin with 'enter' hook | ||
const modifyPlugin: Plugin<{ request: string }> = { | ||
name: 'Modify', | ||
enter: (data) => { | ||
data.request = `Modified: ${data.request}`; | ||
return data; | ||
}, | ||
}; | ||
|
||
// Register the modification plugin | ||
engine.on('httpRequest', modifyPlugin); | ||
|
||
// Execute the 'httpRequest' event | ||
engine.exec('httpRequest', { request: 'GET /home' }).then((result) => { | ||
console.log(`Final Request: ${result.request}`); | ||
}); | ||
// Output: "Request: GET /home", "Request: Modified: GET /home", "Final Request: Modified: GET /home" | ||
``` | ||
|
||
### Key Concepts: | ||
|
||
- **enter and exit hooks:** Plugins can have `enter` and `exit` hooks that run when an event is executed. | ||
|
||
- **abortWith:** Within the `context` argument in the plugin, you can use `abortWith` to | ||
immediately stop the processing of subsequent plugins and return the current state of the event data. | ||
|
||
- **Asynchronous Execution:** The `exec` method returns a promise, allowing for asynchronous event handling. | ||
|
||
- **Error Handling:** Plugins can define an `error` method to handle exceptions gracefully. | ||
PluginEngine? |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testRegex: '(spec|test)\\.tsx?$', | ||
modulePathIgnorePatterns: ['node_modules', 'testing.d.ts'], | ||
testEnvironment: 'node', | ||
testTimeout: +(process.env.TEST_TIMEOUT || 30000), | ||
setupFilesAfterEnv: ['<rootDir>/setupTests.cjs'], | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,97 @@ | ||
{ | ||
"name": "plugin-engine", | ||
"version": "3.1.7", | ||
"#type": "module", | ||
"main": "./out/index.cjs", | ||
"module": "./out/module/index.mjs", | ||
"types": "./out/index.d.ts", | ||
"exports": { | ||
".": { | ||
"types": "./out/index.d.ts", | ||
"import": "./out/module/index.mjs", | ||
"require": "./out/index.cjs" | ||
} | ||
}, | ||
"browser": { | ||
"out/module/index.mjs": "./out/browser/module/index.mjs", | ||
"out/index.cjs": "./out/browser/index.cjs" | ||
}, | ||
"author": "antoniopresto <[email protected]>", | ||
"license": "MIT", | ||
"sideEffects": false, | ||
"scripts": { | ||
"test": "jest", | ||
"build": "run-s clear && run-p declarations build:*", | ||
"clear": "rimraf out", | ||
"fix": "run-s fix:* ", | ||
"fix:prettier": "prettier \"src/**/*.ts\" --write", | ||
"fix:lint": "eslint src --ext .ts --fix", | ||
"prepublishOnly": "run-s build fix && run-p test", | ||
"build-targets": "run-p build:*", | ||
"build:browser": "TARGET=browser npm run babild -- --out-dir out/browser --out-file-extension .cjs", | ||
"build:module-browser": "TARGET=module-browser npm run babild -- --out-dir out/browser/module --out-file-extension .mjs", | ||
"build:node": "TARGET=node npm run babild -- --out-dir out --out-file-extension .cjs", | ||
"build:module-node": "TARGET=module-node npm run babild -- --out-dir out/module --out-file-extension .mjs", | ||
"declarations": "tsc -p tsconfig.declarations.json", | ||
"babild": "babel 'src' --extensions '.ts,.tsx' --source-maps=true --ignore '**/__tests__'" | ||
}, | ||
"description": "Powership server-utils", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/antoniopresto/powership/tree/master/packages/" | ||
}, | ||
"keywords": [ | ||
"typescript", | ||
"schema", | ||
"graphql", | ||
"validation", | ||
"type", | ||
"inference" | ||
], | ||
"dependencies": { | ||
"@powership/utils": "workspace:*", | ||
"@powership/schema": "workspace:*", | ||
"@powership/entity": "workspace:*", | ||
"highlight.js": "11.7.0" | ||
}, | ||
"devDependencies": { | ||
"@powership/boilerplate": "workspace:*", | ||
"@babel/cli": "7.19.3", | ||
"@babel/plugin-transform-typescript": "7.19.3", | ||
"@babel/preset-env": "7.19.3", | ||
"@babel/preset-typescript": "7.18.6", | ||
"@powership/babel-plugins": "workspace:*", | ||
"@powership/mongo": "workspace:*", | ||
"@types/jest": "29.5.3", | ||
"@types/node": "16.18.3", | ||
"@typescript-eslint/eslint-plugin": "5.39.0", | ||
"@typescript-eslint/parser": "5.39.0", | ||
"conditional-type-checks": "1.0.6", | ||
"eslint": "8.25.0", | ||
"eslint-config-prettier": "8.5.0", | ||
"eslint-plugin-eslint-comments": "3.2.0", | ||
"eslint-plugin-import": "2.26.0", | ||
"eslint-plugin-sort-keys-fix": "1.1.2", | ||
"eslint-plugin-typescript-sort-keys": "2.1.0", | ||
"graphql": "16.6.0", | ||
"jest": "29.6.2", | ||
"npm-run-all": "4.1.5", | ||
"prettier": "2.8.8", | ||
"prettier-plugin-multiline-arrays": "^1.1.3", | ||
"rimraf": "3.0.2", | ||
"ts-jest": "29.1.0", | ||
"typedoc": "^0.23.24", | ||
"typescript": "4.9.3" | ||
}, | ||
"files": [ | ||
"package.json", | ||
"out/*", | ||
"README.md" | ||
], | ||
"typedoc": { | ||
"entryPoint": "./src/index.ts", | ||
"readmeFile": "./README.md", | ||
"displayName": ".", | ||
"tsconfig": "./tsconfig.module.json" | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// const { MongoMemoryServer } = require('mongodb-memory-server-core'); | ||
|
||
process.env.LOG_LEVEL = '1'; | ||
process.env.NODE_ENV = 'test'; | ||
process.env.IS_LOCAL = 'true'; | ||
|
||
beforeAll(async () => { | ||
// ensure mongo bins are downloaded | ||
// await MongoMemoryServer.create(); | ||
}); |
Oops, something went wrong.