@dasmeta/event-manager-node-api
Advanced tools
Comparing version 2.0.0 to 2.1.1
{ | ||
"name": "@dasmeta/event-manager-node-api", | ||
"version": "2.0.0", | ||
"version": "2.1.1", | ||
"description": "Extended event publishing PubSub/Kafka package.", | ||
"main": "./dist/index.js", | ||
"typings": "./dist/index.d.ts", | ||
"main": "src/index.js", | ||
"private": false, | ||
"scripts": { | ||
"build": "tsc --outDir dist/", | ||
"prepublishOnly": "yarn build" | ||
"start": "node src/index.js", | ||
"test": "echo 'ok'", | ||
"prettier": "prettier --write 'src/**/*.js'", | ||
"kafkaExample1": "MQ_CLIENT_NAME='Kafka' KAFKA_BROKERS='127.0.0.1:29092' node example1.js", | ||
"kafkaExample2": "MQ_CLIENT_NAME='Kafka' KAFKA_BROKERS='127.0.0.1:29092' node example2.js", | ||
"PubSubExample1": "PUBSUB_EMULATOR_HOST='localhost:8085' PUBSUB_PROJECT_ID='YOUR_GCLOUD_PROJECT_ID' GCLOUD_PROJECT='YOUR_GCLOUD_PROJECT_ID' node example1.js", | ||
"PubSubExample2": "PUBSUB_EMULATOR_HOST='localhost:8085' PUBSUB_PROJECT_ID='YOUR_GCLOUD_PROJECT_ID' GCLOUD_PROJECT='YOUR_GCLOUD_PROJECT_ID' node example2.js" | ||
}, | ||
"dependencies": { | ||
"axios": "^0.21.1" | ||
"@bugsnag/js": "^6.4.0", | ||
"@google-cloud/pubsub": "^2.5.0", | ||
"amqplib": "^0.8.0", | ||
"kafkajs": "^1.15.0", | ||
"mongodb": "^3.3.2", | ||
"uuid": "^3.3.3" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^12.11.5", | ||
"typescript": "^3.6.4" | ||
"prettier": "^1.18.2" | ||
}, | ||
@@ -18,0 +27,0 @@ "keywords": [ |
130
README.md
@@ -1,45 +0,125 @@ | ||
## @ | ||
# @dasmeta/microservice # | ||
This generator creates TypeScript/JavaScript client that utilizes [axios](https://github.com/axios/axios). The generated Node module can be used in the following environments: | ||
Extended event publishing PubSub/Kafka package. | ||
Environment | ||
* Node.js | ||
* Webpack | ||
* Browserify | ||
`yarn add @dasmeta/event-manager-node-api` | ||
Language level | ||
* ES5 - you must have a Promises/A+ library installed | ||
* ES6 | ||
### start local pub/sub | ||
Module system | ||
* CommonJS | ||
* ES6 module system | ||
`$ gcloud beta emulators pubsub start` | ||
`$ DATASTORE_EMULATOR_HOST=localhost:8432 DATASTORE_PROJECT_ID=YOUR_GCLOUD_PROJECT_ID gcloud beta emulators datastore start` | ||
It can be used in both TypeScript and JavaScript. In TypeScript, the definition should be automatically resolved via `package.json`. ([Reference](http://www.typescriptlang.org/docs/handbook/typings-for-npm-packages.html)) | ||
### Building | ||
To build and compile the typescript sources to javascript use: | ||
#### example1.js | ||
``` | ||
npm install | ||
npm run build | ||
const { registerSubscriber, publish } = require("@dasmeta/event-manager-node-api"); | ||
async function test1(data) { | ||
console.log("test1", data); | ||
} | ||
async function test2(data) { | ||
console.log("test2", data); | ||
} | ||
async function test3(data) { | ||
console.log("test3", data); | ||
} | ||
registerSubscriber("dev.test", "dev-test_test1", test1); | ||
registerSubscriber("dev.test", "dev-test_test2", test2); | ||
registerSubscriber("dev.test.other", "dev-test_test3", test3); | ||
setInterval(async () => { | ||
await publish("dev.test", { key: Date.now() }); | ||
}, 300); | ||
setInterval(async () => { | ||
await publish("dev.test.other", { key2: Date.now() }); | ||
}, 500); | ||
``` | ||
### Publishing | ||
`PUBSUB_EMULATOR_HOST="localhost:8085" PUBSUB_PROJECT_ID="YOUR_GCLOUD_PROJECT_ID" GCLOUD_PROJECT="YOUR_GCLOUD_PROJECT_ID" node example1.js` | ||
First build the package then run ```npm publish``` | ||
#### example2.js | ||
``` | ||
const { publish, subscribeMulti } = require("@dasmeta/event-manager-node-api"); | ||
### Consuming | ||
navigate to the folder of your consuming project and run one of the following commands. | ||
function subscribe1() { | ||
subscribeMulti("test", ["dev.test", "dev.test.other"], async (topic, data) => { | ||
console.log('\x1b[31m%s %s\x1b[0m', " 1 ", topic, data); | ||
}); | ||
} | ||
_published:_ | ||
function subscribe2() { | ||
// resubscribe | ||
subscribeMulti("test", ["dev.test"], async (topic, data) => { | ||
console.log('\x1b[32m%s %s\x1b[0m', " 2 ", topic, data); | ||
}); | ||
subscribeMulti("test3", ["dev.test", "dev.test.other"], async (topic, data) => { | ||
console.log('\x1b[33m%s %s\x1b[0m', " 3 ", topic, data); | ||
}); | ||
} | ||
setInterval(async () => { | ||
await publish("dev.test", { key: Date.now() }); | ||
}, 200); | ||
setInterval(async () => { | ||
await publish("dev.test.other", { key2: Date.now() }); | ||
}, 300); | ||
subscribe1(); | ||
setTimeout(async () => { | ||
subscribe2(); | ||
}, 20 * 1000); | ||
``` | ||
npm install @ --save | ||
`PUBSUB_EMULATOR_HOST="localhost:8085" PUBSUB_PROJECT_ID="YOUR_GCLOUD_PROJECT_ID" GCLOUD_PROJECT="YOUR_GCLOUD_PROJECT_ID" node example2.js` | ||
#### example3.js | ||
``` | ||
import { autoStart as AutoStart, subscribe as on, publish } from "@dasmeta/event-manager-node-api"; | ||
_unPublished (not recommended):_ | ||
@AutoStart | ||
class Example { | ||
@on("dev.test") | ||
async test1(data) { | ||
console.log("test1", data); | ||
} | ||
@on("dev.test") | ||
async test2(data) { | ||
console.log("test2", data); | ||
} | ||
@on("dev.test.other") | ||
async test3(data) { | ||
console.log("test3", data); | ||
} | ||
} | ||
setInterval(async () => { | ||
await publish("dev.test", { key: Date.now() }); | ||
}, 300); | ||
setInterval(async () => { | ||
await publish("dev.test.other", { key2: Date.now() }); | ||
}, 500); | ||
``` | ||
npm install PATH_TO_GENERATED_PACKAGE --save | ||
`PUBSUB_EMULATOR_HOST="localhost:8085" PUBSUB_PROJECT_ID="YOUR_GCLOUD_PROJECT_ID" GCLOUD_PROJECT="YOUR_GCLOUD_PROJECT_ID" node example3.js` | ||
#### Kafka : run all examples with env variables | ||
`MQ_CLIENT_NAME='Kafka' KAFKA_BROKERS='127.0.0.1:29092'` | ||
#### PubSub : run all examples with env variables | ||
`PUBSUB_EMULATOR_HOST="localhost:8085" PUBSUB_PROJECT_ID="YOUR_GCLOUD_PROJECT_ID" GCLOUD_PROJECT="YOUR_GCLOUD_PROJECT_ID"` |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 9 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
1
126
79636
6
22
1852
10
+ Added@bugsnag/js@^6.4.0
+ Added@google-cloud/pubsub@^2.5.0
+ Addedamqplib@^0.8.0
+ Addedkafkajs@^1.15.0
+ Addedmongodb@^3.3.2
+ Addeduuid@^3.3.3
+ Added@bugsnag/browser@6.5.2(transitive)
+ Added@bugsnag/js@6.5.2(transitive)
+ Added@bugsnag/node@6.5.2(transitive)
+ Added@google-cloud/paginator@3.0.7(transitive)
+ Added@google-cloud/precise-date@2.0.4(transitive)
+ Added@google-cloud/projectify@2.1.1(transitive)
+ Added@google-cloud/promisify@2.0.4(transitive)
+ Added@google-cloud/pubsub@2.19.4(transitive)
+ Added@grpc/grpc-js@1.6.12(transitive)
+ Added@grpc/proto-loader@0.6.90.7.13(transitive)
+ Added@opentelemetry/api@1.9.0(transitive)
+ Added@opentelemetry/semantic-conventions@1.27.0(transitive)
+ Added@protobufjs/aspromise@1.1.2(transitive)
+ Added@protobufjs/base64@1.1.2(transitive)
+ Added@protobufjs/codegen@2.0.4(transitive)
+ Added@protobufjs/eventemitter@1.1.0(transitive)
+ Added@protobufjs/fetch@1.1.0(transitive)
+ Added@protobufjs/float@1.0.2(transitive)
+ Added@protobufjs/inquire@1.1.0(transitive)
+ Added@protobufjs/path@1.1.2(transitive)
+ Added@protobufjs/pool@1.1.0(transitive)
+ Added@protobufjs/utf8@1.1.0(transitive)
+ Added@types/duplexify@3.6.4(transitive)
+ Added@types/long@4.0.2(transitive)
+ Added@types/node@22.5.5(transitive)
+ Addedabort-controller@3.0.0(transitive)
+ Addedagent-base@6.0.2(transitive)
+ Addedamqplib@0.8.0(transitive)
+ Addedansi-regex@5.0.1(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedarrify@2.0.1(transitive)
+ Addedbase64-js@1.5.1(transitive)
+ Addedbignumber.js@9.1.2(transitive)
+ Addedbitsyntax@0.1.0(transitive)
+ Addedbl@2.2.1(transitive)
+ Addedbluebird@3.7.2(transitive)
+ Addedbson@1.1.6(transitive)
+ Addedbuffer-equal-constant-time@1.0.1(transitive)
+ Addedbuffer-more-ints@1.0.0(transitive)
+ Addedbyline@5.0.0(transitive)
+ Addedcliui@7.0.48.0.1(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addeddebug@2.6.94.3.7(transitive)
+ Addeddenque@1.5.1(transitive)
+ Addedduplexify@4.1.3(transitive)
+ Addedecdsa-sig-formatter@1.0.11(transitive)
+ Addedemoji-regex@8.0.0(transitive)
+ Addedend-of-stream@1.4.4(transitive)
+ Addederror-stack-parser@2.1.4(transitive)
+ Addedescalade@3.2.0(transitive)
+ Addedevent-target-shim@5.0.1(transitive)
+ Addedextend@3.0.2(transitive)
+ Addedfast-text-encoding@1.0.6(transitive)
+ Addedgaxios@4.3.3(transitive)
+ Addedgcp-metadata@4.3.1(transitive)
+ Addedget-caller-file@2.0.5(transitive)
+ Addedgoogle-auth-library@7.14.1(transitive)
+ Addedgoogle-gax@2.30.3(transitive)
+ Addedgoogle-p12-pem@3.1.4(transitive)
+ Addedgtoken@5.3.2(transitive)
+ Addedhttps-proxy-agent@5.0.1(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedis-fullwidth-code-point@3.0.0(transitive)
+ Addedis-stream@2.0.1(transitive)
+ Addedis-stream-ended@0.1.4(transitive)
+ Addedisarray@0.0.11.0.0(transitive)
+ Addediserror@0.0.2(transitive)
+ Addedjson-bigint@1.0.0(transitive)
+ Addedjwa@2.0.0(transitive)
+ Addedjws@4.0.0(transitive)
+ Addedkafkajs@1.16.0(transitive)
+ Addedlodash.camelcase@4.3.0(transitive)
+ Addedlodash.snakecase@4.1.1(transitive)
+ Addedlong@4.0.05.2.3(transitive)
+ Addedlru-cache@6.0.0(transitive)
+ Addedmemory-pager@1.5.0(transitive)
+ Addedmongodb@3.7.4(transitive)
+ Addedms@2.0.02.1.3(transitive)
+ Addednode-fetch@2.7.0(transitive)
+ Addednode-forge@1.3.1(transitive)
+ Addedobject-hash@3.0.0(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedoptional-require@1.1.8(transitive)
+ Addedp-defer@3.0.0(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
+ Addedproto3-json-serializer@0.1.9(transitive)
+ Addedprotobufjs@6.11.27.4.0(transitive)
+ Addedpump@3.0.2(transitive)
+ Addedquerystringify@2.2.0(transitive)
+ Addedreadable-stream@1.1.142.3.83.6.2(transitive)
+ Addedrequire-at@1.0.6(transitive)
+ Addedrequire-directory@2.1.1(transitive)
+ Addedrequires-port@1.0.0(transitive)
+ Addedretry-request@4.2.2(transitive)
+ Addedsafe-buffer@5.1.25.2.1(transitive)
+ Addedsaslprep@1.0.3(transitive)
+ Addedsparse-bitfield@3.0.3(transitive)
+ Addedstack-generator@2.0.10(transitive)
+ Addedstackframe@1.3.4(transitive)
+ Addedstream-shift@1.0.3(transitive)
+ Addedstring-width@4.2.3(transitive)
+ Addedstring_decoder@0.10.311.1.11.3.0(transitive)
+ Addedstrip-ansi@6.0.1(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addedundici-types@6.19.8(transitive)
+ Addedurl-parse@1.5.10(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addeduuid@3.4.0(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwhatwg-url@5.0.0(transitive)
+ Addedwrap-ansi@7.0.0(transitive)
+ Addedwrappy@1.0.2(transitive)
+ Addedy18n@5.0.8(transitive)
+ Addedyallist@4.0.0(transitive)
+ Addedyargs@16.2.017.7.2(transitive)
+ Addedyargs-parser@20.2.921.1.1(transitive)
- Removedaxios@^0.21.1
- Removedaxios@0.21.4(transitive)
- Removedfollow-redirects@1.15.9(transitive)