Skip to content

Commit 21230c3

Browse files
author
Jonathan
committed
Release 1.0.0-alpha.18 🚀
- Fixed app starting before the right time - Fixed async issues on booting
1 parent 090f69b commit 21230c3

File tree

4 files changed

+29
-20
lines changed

4 files changed

+29
-20
lines changed

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@onixjs/core",
3-
"version": "1.0.0-alpha.17.1",
3+
"version": "1.0.0-alpha.18",
44
"description": "The High-Performance SOA Real-Time Framework for Node.JS",
55
"main": "dist/src/index.js",
66
"scripts": {
@@ -48,11 +48,12 @@
4848
"node": ">=8.10.0"
4949
},
5050
"dependencies": {
51+
"@onixjs/enumerable": "^1.0.0-alpha.7",
5152
"@onixjs/sdk": "^1.0.0-alpha.4.4",
52-
"uws": "^9.14.0",
53-
"router": "^1.3.2",
5453
"finalhandler": "^1.1.1",
55-
"reflect-metadata": "^0.1.12"
54+
"reflect-metadata": "^0.1.12",
55+
"router": "^1.3.2",
56+
"uws": "^9.14.0"
5657
},
5758
"devDependencies": {
5859
"@types/mongodb": "^3.0.5",

src/core/app.factory.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export class AppFactory {
9999
*/
100100
public async setup() {
101101
// Iterate list of module classes
102-
return promiseSeries(
102+
const result = await promiseSeries(
103103
this.config.modules.map((Module: Constructor) => async () => {
104104
//this.config.modules.forEach(async (Module: Constructor) => {
105105
console.log('Module Name: ', Module.name);
@@ -129,13 +129,15 @@ export class AppFactory {
129129
this.app.modules[Module.name],
130130
Module,
131131
);
132-
if (process.send)
133-
process.send({
134-
type: OperationType.APP_CREATE_RESPONSE,
135-
message: this.schema(),
136-
});
137132
}),
138133
);
134+
if (process.send)
135+
process.send({
136+
type: OperationType.APP_CREATE_RESPONSE,
137+
message: this.schema(),
138+
});
139+
140+
return result;
139141
}
140142
/**
141143
* @method setupComponents
@@ -361,13 +363,17 @@ export class AppFactory {
361363
}),
362364
);
363365
}
364-
// read file from file system
365-
const data = await AsyncReadFile(pathname);
366-
// Potentially get cookies and headers
367-
const result = await instance[method](req, data);
368-
// Set response headers
369-
res.setHeader('Content-type', map[ext] || 'text/plain');
370-
res.end(Utils.IsJsonString(result) ? JSON.stringify(result) : result);
366+
try {
367+
// read file from file system
368+
const data = await AsyncReadFile(pathname);
369+
// Potentially get cookies and headers
370+
const result = await instance[method](req, data);
371+
// Set response headers
372+
res.setHeader('Content-type', map[ext] || 'text/plain');
373+
res.end(Utils.IsJsonString(result) ? JSON.stringify(result) : result);
374+
} catch (e) {
375+
next();
376+
}
371377
}
372378
}
373379
/**

src/core/host.boot.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {OnixJS} from '../index';
1+
import {OnixJS, promiseSeries} from '../index';
22
import * as path from 'path';
33
import {OnixConfig, BootConfig} from '../interfaces';
44
/**
@@ -56,7 +56,9 @@ export class HostBoot {
5656
}
5757

5858
async run() {
59-
this.bc.apps.forEach(async app => await this.host.load(app));
59+
await promiseSeries(
60+
this.bc.apps.map(app => async () => this.host.load(app)),
61+
);
6062
await this.host.start();
6163
}
6264
}

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class OnixJS {
3333
* @description Current Onix Version.
3434
*/
3535
get version(): string {
36-
return '1.0.0-alpha.17.1';
36+
return '1.0.0-alpha.18';
3737
}
3838
/**
3939
* @property server

0 commit comments

Comments
 (0)