@ti-engine/core 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -1
- package/bin/start-instance.js +7 -7
- package/components/service-provider.js +4 -2
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -29,7 +29,17 @@ In order to run the basic ti-engine framework you will need a couple of things:
|
|
|
29
29
|
To get the framework itself, use the command `npm install @ti-engine/core`. And to include it directly in your package.json dependencies execute `npm install @ti-engine/core --save-prod`.
|
|
30
30
|
|
|
31
31
|
## getting started
|
|
32
|
-
To start using the ti-engine
|
|
32
|
+
To start using the **ti-engine**, you will have to make sure that all prerequisites are available and operational. If you are working under Windows OS and you need to install Redis, take a look at this [guide](https://redis.com/blog/redis-on-windows-10/).
|
|
33
|
+
|
|
34
|
+
Once you have all this setup and ready, you should download the **ti-engine** tester module with the command `npm install @ti-engine/tester`. The tester module packages an example microservice that shows the basic approach for using the framework. To make sure everything is working properly, you should try and start the tester service:
|
|
35
|
+
1. Open a command prompt and navigate to the directory of the tester module; it should be something like that `<path to your project>/node_modules/@ti-engine/tester`
|
|
36
|
+
2.
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
the framework is properly configured and able to run. More details and instructions will be provided in the next version of this documentation. For now please take a look at the included file `start-instance.js`. It should give you an idea of how the engine operates and what to do in order to create and run your own microservice instance.
|
|
41
|
+
|
|
42
|
+
|
|
33
43
|
|
|
34
44
|
Under development...
|
|
35
45
|
|
package/bin/start-instance.js
CHANGED
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
-
// load any ENV variables defined in a .env file:
|
|
9
|
-
require( "dotenv" ).config();
|
|
10
|
-
|
|
11
8
|
const _ = require( "lodash" );
|
|
12
|
-
const
|
|
9
|
+
const path = require( "path" );
|
|
13
10
|
const tools = require( "#tools" );
|
|
14
11
|
const logger = require( "#logger" );
|
|
15
12
|
|
|
13
|
+
// load any ENV variables defined in a .env file:
|
|
14
|
+
require( "dotenv" ).config( { path: path.join( process.cwd(), ".env" ) } );
|
|
15
|
+
|
|
16
16
|
// configure the current instance variables before requiring any platform modules and store the necessary ones in memory cache:
|
|
17
17
|
process.env.TI_INSTANCE_ID = "ti-" + tools.getUUID();
|
|
18
18
|
process.env.TI_INSTANCE_CLASS = process.env.TI_INSTANCE_CLASS || "";
|
|
@@ -75,11 +75,11 @@ try {
|
|
|
75
75
|
logger.log( `Starting new instance of type '${ process.env.TI_INSTANCE_NAME }' with instance ID '${ process.env.TI_INSTANCE_ID }'.`, logger.logSeverity.NOTICE );
|
|
76
76
|
|
|
77
77
|
/** @type ServiceInstance */
|
|
78
|
-
const serviceConstructor = require( process.env.TI_INSTANCE_CLASS );
|
|
78
|
+
const serviceConstructor = require( path.join( process.cwd(), process.env.TI_INSTANCE_CLASS ) );
|
|
79
79
|
const serviceConfigPath = process.env.TI_INSTANCE_CONFIG;
|
|
80
80
|
let serviceConfig = {};
|
|
81
|
-
if (
|
|
82
|
-
serviceConfig = require( process.env.TI_INSTANCE_CONFIG );
|
|
81
|
+
if ( serviceConfigPath ) {
|
|
82
|
+
serviceConfig = require( path.join( process.cwd(), process.env.TI_INSTANCE_CONFIG ) );
|
|
83
83
|
}
|
|
84
84
|
const mainInstance = new serviceConstructor( process.env.TI_INSTANCE_NAME, serviceConfig );
|
|
85
85
|
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
const ServiceConsumer = require( "#service-consumer" );
|
|
7
7
|
const _ = require( "lodash" );
|
|
8
|
+
const path = require( "path" );
|
|
8
9
|
const exceptions = require( "#exceptions" );
|
|
9
10
|
const logger = require( "#logger" );
|
|
10
11
|
const messageDispatcher = require( "#message-dispatcher" );
|
|
@@ -136,10 +137,11 @@ class ServiceProvider extends ServiceConsumer {
|
|
|
136
137
|
/** @type {ServiceHandlerMethod} */
|
|
137
138
|
let serviceHandler = null;
|
|
138
139
|
if ( serviceDefinition.serviceFile ) {
|
|
140
|
+
let serviceFilePath = path.join( process.cwd(), serviceDefinition.serviceFile );
|
|
139
141
|
try {
|
|
140
|
-
serviceHandler = require(
|
|
142
|
+
serviceHandler = require( serviceFilePath ).service;
|
|
141
143
|
} catch ( error ) {
|
|
142
|
-
logger.log( `Specified service handler file '${
|
|
144
|
+
logger.log( `Specified service handler file '${ serviceFilePath }' could not be loaded!`, logger.logSeverity.ERROR, error );
|
|
143
145
|
}
|
|
144
146
|
} else {
|
|
145
147
|
if ( typeof ( defaultServiceHandler ) === "function" ) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ti-engine/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "The ti-engine is an open source, free to use - both for personal and commercial projects - framework for the creation of microservice-based solutions using node.js.",
|
|
5
5
|
"author": "Boris Kostadinov <kostadinov.boris@gmail.com>",
|
|
6
6
|
"license": "ISC",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"#tools": "./utils/tools.js"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
+
"blake2": "^4.0.2",
|
|
44
45
|
"dotenv": "^10.0.0",
|
|
45
46
|
"fs-extra": "^10.0.0",
|
|
46
47
|
"lodash": "^4.17.21",
|