-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RCS-17 Use timestamps from incoming messages
- Loading branch information
Showing
15 changed files
with
166 additions
and
123 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 |
---|---|---|
|
@@ -10,5 +10,6 @@ | |
/package-lock.json | ||
/tmp/ | ||
/var/*.pid | ||
/var/sw_cache.zip | ||
/var/store/** | ||
/web/download/ |
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,60 +1,62 @@ | ||
#!/usr/bin/env node | ||
'use strict'; | ||
/** Main script to create and to run TeqFW backend application. */ | ||
/** Main script to create and run the backend teq-app. */ | ||
// IMPORT | ||
import Container from '@teqfw/di'; | ||
import {dirname, join} from 'node:path'; | ||
import {fileURLToPath} from 'node:url'; | ||
import {platform} from "node:process"; | ||
import {readFileSync} from 'node:fs'; | ||
import Container from '@teqfw/di'; | ||
|
||
// VARS | ||
/* Resolve paths to main folders */ | ||
const url = new URL(import.meta.url); | ||
const script = fileURLToPath(url); | ||
const script = url.pathname; | ||
const bin = dirname(script); | ||
const root = join(bin, '..'); | ||
const path = join(bin, '..'); | ||
|
||
// FUNCS | ||
/** | ||
* Create and setup DI container. | ||
* @param {string} root | ||
* @returns {TeqFw_Di_Shared_Container} | ||
* Create and manually set up the DI container. | ||
* @param {string} root - The root folder of the app (where the `node_modules` folder is located). | ||
* @returns {Promise<TeqFw_Di_Api_Container>} | ||
*/ | ||
function initContainer(root) { | ||
/** @type {TeqFw_Di_Shared_Container} */ | ||
async function initContainer(root) { | ||
/** @type {TeqFw_Di_Api_Container} */ | ||
const res = new Container(); | ||
res.getNsResolver().isWindows = (platform === 'win32'); | ||
const pathDi = join(root, 'node_modules/@teqfw/di/src'); | ||
const pathCore = join(root, 'node_modules/@teqfw/core/src'); | ||
res.addSourceMapping('TeqFw_Di', pathDi, true, 'mjs'); | ||
res.addSourceMapping('TeqFw_Core', pathCore, true, 'mjs'); | ||
res.setDebug(false); | ||
// add path mapping for @teqfw/core to the DI resolver | ||
const resolver = res.getResolver(); | ||
const pathDi = join(root, 'node_modules', '@teqfw', 'di', 'src'); | ||
const pathCore = join(root, 'node_modules', '@teqfw', 'core', 'src'); | ||
resolver.addNamespaceRoot('TeqFw_Di_', pathDi, 'js'); | ||
resolver.addNamespaceRoot('TeqFw_Core_', pathCore, 'mjs'); | ||
// setup parser for the legacy code | ||
/** @type {TeqFw_Core_Shared_App_Di_Parser_Legacy} */ | ||
const parserLegacy = await res.get('TeqFw_Core_Shared_App_Di_Parser_Legacy$'); | ||
res.getParser().addChunk(parserLegacy); | ||
// add pre-processors: replace | ||
const pre = res.getPreProcessor(); | ||
const preReplace = await res.get(`TeqFw_Core_Shared_App_Di_PreProcessor_Replace$`); | ||
pre.addChunk(preReplace); | ||
// add post-processors: Factory, Proxy, Logger | ||
const post = res.getPostProcessor(); | ||
/** @type {TeqFw_Core_Shared_App_Di_PostProcessor_Factory} */ | ||
const postFactory = await res.get('TeqFw_Core_Shared_App_Di_PostProcessor_Factory$'); | ||
post.addChunk(postFactory); | ||
/** @type {TeqFw_Core_Shared_App_Di_PostProcessor_Proxy} */ | ||
const postProxy = await res.get('TeqFw_Core_Shared_App_Di_PostProcessor_Proxy$'); | ||
post.addChunk(postProxy); | ||
/** @type {TeqFw_Core_Shared_App_Di_PostProcessor_Logger} */ | ||
const postLogger = await res.get('TeqFw_Core_Shared_App_Di_PostProcessor_Logger$'); | ||
post.addChunk(postLogger); | ||
return res; | ||
} | ||
|
||
/** | ||
* Read project version from './package.json' or use default one. | ||
* @param root | ||
* @returns {*|string} | ||
*/ | ||
function readVersion(root) { | ||
const filename = join(root, 'package.json'); | ||
const buffer = readFileSync(filename); | ||
const content = buffer.toString(); | ||
const json = JSON.parse(content); | ||
return json?.version ?? '0.1.0'; | ||
} | ||
|
||
// MAIN | ||
try { | ||
const container = initContainer(root); | ||
const version = readVersion(root); | ||
/** Construct backend app instance using Container then init app & run it */ | ||
// Initialize the DI container, then create and run the backend teq-app. | ||
const container = await initContainer(path); | ||
/** @type {TeqFw_Core_Back_App} */ | ||
const app = await container.get('TeqFw_Core_Back_App$'); | ||
await app.init({path: root, version}); | ||
await app.run(); | ||
await app.run({path}); | ||
} catch (e) { | ||
console.error('Cannot create or run TeqFW application.'); | ||
console.dir(e); | ||
} | ||
console.error(e); | ||
} |
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,26 @@ | ||
/** | ||
* Plugin constants (hardcoded configuration) for backend code. | ||
*/ | ||
export default class Remote_Console_Back_Defaults { | ||
|
||
/** @type {TeqFw_Web_Back_Defaults} */ | ||
MOD_WEB; | ||
|
||
/** @type {Remote_Console_Shared_Defaults} */ | ||
SHARED; | ||
|
||
/** | ||
* @param {TeqFw_Web_Back_Defaults} MOD_WEB | ||
* @param {Remote_Console_Shared_Defaults} SHARED | ||
*/ | ||
constructor( | ||
{ | ||
TeqFw_Web_Back_Defaults$: MOD_WEB, | ||
Remote_Console_Shared_Defaults$: SHARED, | ||
} | ||
) { | ||
this.MOD_WEB = MOD_WEB; | ||
this.SHARED = SHARED; | ||
Object.freeze(this); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.