mirror of
https://github.com/steedos/steedos-platform
synced 2024-11-22 00:01:52 +00:00
add test object services #1505
This commit is contained in:
parent
fa152ee5fd
commit
71e2392bd1
1
.gitignore
vendored
1
.gitignore
vendored
@ -46,3 +46,4 @@ packages/project-template-empty/.env.local
|
||||
apps/contracts/src/_test/**
|
||||
packages/accounts/webapp/build/**
|
||||
packages/react/.env.local
|
||||
services/service-metadata-objects/.env.local
|
||||
|
1
services/service-metadata-objects/.env
Normal file
1
services/service-metadata-objects/.env
Normal file
@ -0,0 +1 @@
|
||||
TRANSPORTER=redis://localhost:6379
|
@ -103,7 +103,6 @@ module.exports = {
|
||||
|
||||
// Define a cacher.
|
||||
// More info: https://moleculer.services/docs/0.14/caching.html
|
||||
cacher: "redis://192.168.3.17:6379",
|
||||
|
||||
// Define a serializer.
|
||||
// Available values: "JSON", "Avro", "ProtoBuf", "MsgPack", "Notepack", "Thrift".
|
||||
|
@ -9,6 +9,7 @@
|
||||
"cli": "moleculer connect redis://192.168.3.17:6379",
|
||||
"ci": "jest --watch",
|
||||
"test": "jest --coverage",
|
||||
"testObject": "node test/object.services.js",
|
||||
"lint": "eslint services",
|
||||
"dc:up": "docker-compose up --build -d",
|
||||
"dc:logs": "docker-compose logs -f",
|
||||
|
34
services/service-metadata-objects/test/object.services.js
Normal file
34
services/service-metadata-objects/test/object.services.js
Normal file
@ -0,0 +1,34 @@
|
||||
const { ServiceBroker } = require("moleculer");
|
||||
require('dotenv-flow').config(process.cwd());
|
||||
|
||||
const broker = new ServiceBroker({
|
||||
namespace: "steedos",
|
||||
nodeID: "$test",
|
||||
logLevel: "debug",
|
||||
requestTimeout: 5 * 1000,
|
||||
preferLocal: false,
|
||||
transporter: process.env.TRANSPORTER,
|
||||
});
|
||||
|
||||
broker.createService({
|
||||
name: "ObjectFind",
|
||||
|
||||
settings: {
|
||||
|
||||
},
|
||||
events: {
|
||||
"#accounts.created"(ctx) {
|
||||
broker.call("#accounts.find", {query: {filters: ['_id', '=', ctx.params.recordId]}}).then(res => console.log(ctx.eventName, res));
|
||||
},
|
||||
"#accounts.updated"(ctx) {
|
||||
broker.call("#accounts.find", {query: {filters: ['_id', '=', ctx.params.recordId]}}).then(res => console.log(ctx.eventName, res));
|
||||
},
|
||||
"#accounts.deleted"(ctx) {
|
||||
console.log("#accounts.deleted ctx:", ctx);
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
broker.start().then((a, b, c, d) => {
|
||||
broker.repl();
|
||||
}, 5000)
|
Loading…
Reference in New Issue
Block a user