moost 0.0.1-beta.4 → 0.0.1
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/dist/moost.cjs.prod.js +41 -40
- package/dist/moost.d.ts +2 -0
- package/dist/moost.esm-bundler.js +22 -21
- package/dist/src/composables/controller-meta.d.ts.map +1 -1
- package/dist/src/decorators/resolve.decorator.d.ts.map +1 -1
- package/dist/src/moost.d.ts +2 -0
- package/dist/src/moost.d.ts.map +1 -1
- package/dist/src/tests/e2e.spec.d.ts +1 -1
- package/dist/src/tests/e2e.spec.d.ts.map +1 -1
- package/package.json +4 -5
package/dist/moost.cjs.prod.js
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var wooks = require('wooks');
|
|
6
|
-
var
|
|
6
|
+
var eventHttp = require('@wooksjs/event-http');
|
|
7
7
|
var mate = require('@prostojs/mate');
|
|
8
8
|
var infact = require('@prostojs/infact');
|
|
9
9
|
var valido$1 = require('@prostojs/valido');
|
|
10
|
-
var
|
|
10
|
+
var httpBody = require('@wooksjs/http-body');
|
|
11
11
|
|
|
12
12
|
const METADATA_WORKSPACE = 'moost';
|
|
13
13
|
const moostMate = new mate.Mate(METADATA_WORKSPACE, {
|
|
@@ -18,22 +18,21 @@ function getMoostMate() {
|
|
|
18
18
|
return moostMate;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
const STORE = Symbol('__moost__');
|
|
22
21
|
function useControllerMeta() {
|
|
23
|
-
const
|
|
22
|
+
const moostStore = useMoostStore();
|
|
24
23
|
return {
|
|
25
|
-
getClassMeta: () => getMoostMate().read(
|
|
26
|
-
getMethodMeta: () => getMoostMate().read(
|
|
24
|
+
getClassMeta: () => getMoostMate().read(moostStore.value.controller),
|
|
25
|
+
getMethodMeta: () => getMoostMate().read(moostStore.value.controller, moostStore.value.method),
|
|
27
26
|
};
|
|
28
27
|
}
|
|
29
28
|
function setComposableControllerContext(data) {
|
|
30
|
-
const
|
|
31
|
-
set('controller', data.controller);
|
|
32
|
-
set('method', data.method);
|
|
33
|
-
set('pathBuilder', data.pathBuilder);
|
|
29
|
+
const moostStore = useMoostStore();
|
|
30
|
+
moostStore.set('controller', data.controller);
|
|
31
|
+
moostStore.set('method', data.method);
|
|
32
|
+
moostStore.set('pathBuilder', data.pathBuilder);
|
|
34
33
|
}
|
|
35
34
|
function useMoostStore() {
|
|
36
|
-
return
|
|
35
|
+
return eventHttp.useHttpContext().store('moost');
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
async function runPipes(pipes, meta, restoreCtx) {
|
|
@@ -86,7 +85,7 @@ function getNewMoostInfact() {
|
|
|
86
85
|
global: false,
|
|
87
86
|
constructorParams: meta?.params || [],
|
|
88
87
|
provide: meta?.provide,
|
|
89
|
-
scopeId: meta?.injectable === 'FOR_REQUEST' ?
|
|
88
|
+
scopeId: meta?.injectable === 'FOR_REQUEST' ? eventHttp.useRequest().reqId() : undefined,
|
|
90
89
|
};
|
|
91
90
|
return infactMeta;
|
|
92
91
|
},
|
|
@@ -101,8 +100,8 @@ function getNewMoostInfact() {
|
|
|
101
100
|
|
|
102
101
|
function bindHandler(getInstance, method, wooksApp, options) {
|
|
103
102
|
const pathBuilder = wooksApp.on(options.httpMethod, options.path, async () => {
|
|
104
|
-
const { restoreCtx } =
|
|
105
|
-
const { reqId, rawRequest } =
|
|
103
|
+
const { restoreCtx } = eventHttp.useHttpContext();
|
|
104
|
+
const { reqId, rawRequest } = eventHttp.useRequest();
|
|
106
105
|
const infact = getMoostInfact();
|
|
107
106
|
const scopeId = reqId();
|
|
108
107
|
infact.registerScope(scopeId);
|
|
@@ -174,7 +173,7 @@ function bindHandler(getInstance, method, wooksApp, options) {
|
|
|
174
173
|
}
|
|
175
174
|
async function applyPipesToArgs(argsPipes) {
|
|
176
175
|
const args = [];
|
|
177
|
-
const { restoreCtx } =
|
|
176
|
+
const { restoreCtx } = eventHttp.useHttpContext();
|
|
178
177
|
for (let i = 0; i < argsPipes.length; i++) {
|
|
179
178
|
const { pipes, meta } = argsPipes[i];
|
|
180
179
|
args[i] = await runPipes(pipes, meta, restoreCtx);
|
|
@@ -250,7 +249,7 @@ function bindControllerMethods(getInstance, classConstructor, wooksApp, options)
|
|
|
250
249
|
const interceptorMeta = mate.read(handler);
|
|
251
250
|
if (interceptorMeta?.injectable) {
|
|
252
251
|
interceptorHandlers.push(async (...args) => {
|
|
253
|
-
const { restoreCtx } =
|
|
252
|
+
const { restoreCtx } = eventHttp.useHttpContext();
|
|
254
253
|
const targetInstance = await getInstance();
|
|
255
254
|
restoreCtx();
|
|
256
255
|
return (await getCallableFn(targetInstance, handler, restoreCtx))(...args);
|
|
@@ -336,21 +335,21 @@ function Resolve(resolver, label) {
|
|
|
336
335
|
* @decorator
|
|
337
336
|
* @paramType TStatusHook
|
|
338
337
|
*/
|
|
339
|
-
const StatusHook = Resolve(() =>
|
|
338
|
+
const StatusHook = Resolve(() => eventHttp.useStatus(), 'status');
|
|
340
339
|
/**
|
|
341
340
|
* Hook to the Response Header
|
|
342
341
|
* @decorator
|
|
343
342
|
* @param name - header name
|
|
344
343
|
* @paramType THeaderHook
|
|
345
344
|
*/
|
|
346
|
-
const HeaderHook = (name) => Resolve(() =>
|
|
345
|
+
const HeaderHook = (name) => Resolve(() => eventHttp.useSetHeader(name), name);
|
|
347
346
|
/**
|
|
348
347
|
* Hook to the Response Cookie
|
|
349
348
|
* @decorator
|
|
350
349
|
* @param name - header name
|
|
351
350
|
* @paramType TCookieHook
|
|
352
351
|
*/
|
|
353
|
-
const CookieHook = (name) => Resolve(() =>
|
|
352
|
+
const CookieHook = (name) => Resolve(() => eventHttp.useSetCookie(name), name);
|
|
354
353
|
/**
|
|
355
354
|
* Parse Authorisation Header
|
|
356
355
|
* @decorator
|
|
@@ -359,7 +358,7 @@ const CookieHook = (name) => Resolve(() => composables.useSetCookie(name), name)
|
|
|
359
358
|
*/
|
|
360
359
|
function Authorization(name) {
|
|
361
360
|
return Resolve(() => {
|
|
362
|
-
const auth =
|
|
361
|
+
const auth = eventHttp.useAuthorization();
|
|
363
362
|
switch (name) {
|
|
364
363
|
case 'username':
|
|
365
364
|
return auth.isBasic() ? auth.basicCredentials()?.username : undefined;
|
|
@@ -382,7 +381,7 @@ function Authorization(name) {
|
|
|
382
381
|
*/
|
|
383
382
|
function Header(name) {
|
|
384
383
|
return Resolve(() => {
|
|
385
|
-
const headers =
|
|
384
|
+
const headers = eventHttp.useHeaders();
|
|
386
385
|
return headers[name];
|
|
387
386
|
}, 'header: ' + name);
|
|
388
387
|
}
|
|
@@ -393,7 +392,7 @@ function Header(name) {
|
|
|
393
392
|
* @paramType string
|
|
394
393
|
*/
|
|
395
394
|
function Cookie(name) {
|
|
396
|
-
return Resolve(() =>
|
|
395
|
+
return Resolve(() => eventHttp.useCookies().getCookie(name), 'cookie: ' + name);
|
|
397
396
|
}
|
|
398
397
|
/**
|
|
399
398
|
* Get Param Value from url parh
|
|
@@ -402,7 +401,7 @@ function Cookie(name) {
|
|
|
402
401
|
* @paramType string
|
|
403
402
|
*/
|
|
404
403
|
function Param(name) {
|
|
405
|
-
return Resolve(() =>
|
|
404
|
+
return Resolve(() => wooks.useRouteParams().get(name), name);
|
|
406
405
|
}
|
|
407
406
|
/**
|
|
408
407
|
* Get Parsed Params from url parh
|
|
@@ -410,7 +409,7 @@ function Param(name) {
|
|
|
410
409
|
* @paramType object
|
|
411
410
|
*/
|
|
412
411
|
function Params() {
|
|
413
|
-
return Resolve(() =>
|
|
412
|
+
return Resolve(() => wooks.useRouteParams().params, 'params');
|
|
414
413
|
}
|
|
415
414
|
/**
|
|
416
415
|
* Get Query Item value or the whole parsed Query as an object
|
|
@@ -420,7 +419,7 @@ function Params() {
|
|
|
420
419
|
*/
|
|
421
420
|
function Query(name) {
|
|
422
421
|
return Resolve(() => {
|
|
423
|
-
const { jsonSearchParams, urlSearchParams } =
|
|
422
|
+
const { jsonSearchParams, urlSearchParams } = eventHttp.useSearchParams();
|
|
424
423
|
if (name) {
|
|
425
424
|
const p = urlSearchParams();
|
|
426
425
|
const value = p.get(name);
|
|
@@ -437,7 +436,7 @@ function Query(name) {
|
|
|
437
436
|
* @paramType string
|
|
438
437
|
*/
|
|
439
438
|
function Url() {
|
|
440
|
-
return Resolve(() =>
|
|
439
|
+
return Resolve(() => eventHttp.useRequest().url, 'url');
|
|
441
440
|
}
|
|
442
441
|
/**
|
|
443
442
|
* Get Requested HTTP Method
|
|
@@ -445,7 +444,7 @@ function Url() {
|
|
|
445
444
|
* @paramType string
|
|
446
445
|
*/
|
|
447
446
|
function Method() {
|
|
448
|
-
return Resolve(() =>
|
|
447
|
+
return Resolve(() => eventHttp.useRequest().method, 'http_method');
|
|
449
448
|
}
|
|
450
449
|
/**
|
|
451
450
|
* Get Raw Request Instance
|
|
@@ -453,7 +452,7 @@ function Method() {
|
|
|
453
452
|
* @paramType IncomingMessage
|
|
454
453
|
*/
|
|
455
454
|
function Req() {
|
|
456
|
-
return Resolve(() =>
|
|
455
|
+
return Resolve(() => eventHttp.useRequest().rawRequest, 'request');
|
|
457
456
|
}
|
|
458
457
|
/**
|
|
459
458
|
* Get Request Unique Identificator (UUID)
|
|
@@ -461,7 +460,7 @@ function Req() {
|
|
|
461
460
|
* @paramType string
|
|
462
461
|
*/
|
|
463
462
|
function ReqId() {
|
|
464
|
-
return Resolve(() =>
|
|
463
|
+
return Resolve(() => eventHttp.useRequest().reqId(), 'reqId');
|
|
465
464
|
}
|
|
466
465
|
/**
|
|
467
466
|
* Get Request IP Address
|
|
@@ -469,7 +468,7 @@ function ReqId() {
|
|
|
469
468
|
* @paramType string
|
|
470
469
|
*/
|
|
471
470
|
function Ip(opts) {
|
|
472
|
-
return Resolve(() =>
|
|
471
|
+
return Resolve(() => eventHttp.useRequest().getIp(opts), 'ip');
|
|
473
472
|
}
|
|
474
473
|
/**
|
|
475
474
|
* Get Request IP Address list
|
|
@@ -477,7 +476,7 @@ function Ip(opts) {
|
|
|
477
476
|
* @paramType string[]
|
|
478
477
|
*/
|
|
479
478
|
function IpList() {
|
|
480
|
-
return Resolve(() =>
|
|
479
|
+
return Resolve(() => eventHttp.useRequest().getIpList(), 'ipList');
|
|
481
480
|
}
|
|
482
481
|
/**
|
|
483
482
|
* Get Raw Response Object
|
|
@@ -486,7 +485,7 @@ function IpList() {
|
|
|
486
485
|
* @paramType string
|
|
487
486
|
*/
|
|
488
487
|
function Res(options) {
|
|
489
|
-
return Resolve(() =>
|
|
488
|
+
return Resolve(() => eventHttp.useResponse().rawResponse(options), 'response');
|
|
490
489
|
}
|
|
491
490
|
/**
|
|
492
491
|
* Provide Const Value
|
|
@@ -504,7 +503,7 @@ function Const(value, label) {
|
|
|
504
503
|
* @paramType object | string | unknown
|
|
505
504
|
*/
|
|
506
505
|
function Body() {
|
|
507
|
-
return Resolve(() =>
|
|
506
|
+
return Resolve(() => httpBody.useBody().parseBody(), 'body');
|
|
508
507
|
}
|
|
509
508
|
/**
|
|
510
509
|
* Get Raw Request Body Buffer
|
|
@@ -512,7 +511,7 @@ function Body() {
|
|
|
512
511
|
* @paramType Promise<Buffer>
|
|
513
512
|
*/
|
|
514
513
|
function RawBody() {
|
|
515
|
-
return Resolve(() =>
|
|
514
|
+
return Resolve(() => httpBody.useBody().rawBody(), 'body');
|
|
516
515
|
}
|
|
517
516
|
function fillLabel(target, key, index, name) {
|
|
518
517
|
if (name) {
|
|
@@ -650,9 +649,10 @@ class Moost {
|
|
|
650
649
|
this.options = options;
|
|
651
650
|
}
|
|
652
651
|
wooksApp;
|
|
652
|
+
wooksHttp;
|
|
653
653
|
unregisteredControllers = [];
|
|
654
654
|
async listen(port, hostname, cb) {
|
|
655
|
-
this.wooksApp = new wooks.Wooks(
|
|
655
|
+
this.wooksApp = new wooks.Wooks();
|
|
656
656
|
this.setProvideRegistry(infact.createProvideRegistry([wooks.Wooks, () => this.wooksApp], [Moost, () => this]));
|
|
657
657
|
const _port = Number(this.options?.port || port);
|
|
658
658
|
const _hostname = this.options?.hostname || hostname;
|
|
@@ -660,12 +660,13 @@ class Moost {
|
|
|
660
660
|
throw panic('Port is not specified for "listen" method');
|
|
661
661
|
}
|
|
662
662
|
await this.init();
|
|
663
|
-
|
|
663
|
+
this.wooksHttp = new eventHttp.WooksHttp(_port, _hostname, cb);
|
|
664
|
+
await this.wooksApp.subscribe(this.wooksHttp);
|
|
664
665
|
logBright(`🚀 ${mate.getConstructor(this).name} is up and running on port ${_port}`);
|
|
665
666
|
return this.wooksApp;
|
|
666
667
|
}
|
|
667
668
|
close() {
|
|
668
|
-
return this.
|
|
669
|
+
return this.wooksHttp?.close();
|
|
669
670
|
}
|
|
670
671
|
async init() {
|
|
671
672
|
if (this.wooksApp) {
|
|
@@ -838,7 +839,7 @@ const genericTypesCastPipe = (strict) => {
|
|
|
838
839
|
};
|
|
839
840
|
function typeError(value, targetType, label) {
|
|
840
841
|
const prefix = label ? `Argument "${label}" with value ` : '';
|
|
841
|
-
throw new
|
|
842
|
+
throw new eventHttp.WooksError(400, `${prefix}${JSON.stringify(value)} is not a ${targetType} type`);
|
|
842
843
|
}
|
|
843
844
|
|
|
844
845
|
const DEFAULT_ERROR_LIMIT = 10;
|
|
@@ -853,11 +854,11 @@ function firstString(errors) {
|
|
|
853
854
|
}
|
|
854
855
|
const validatePipe = (opts) => {
|
|
855
856
|
const pipe = async (_value, meta) => {
|
|
856
|
-
const { restoreCtx } =
|
|
857
|
+
const { restoreCtx } = eventHttp.useHttpContext();
|
|
857
858
|
const valido = getMoostValido();
|
|
858
859
|
const result = await valido.validateParam(_value, meta, undefined, undefined, undefined, undefined, 0, 0, opts?.errorLimit || DEFAULT_ERROR_LIMIT, restoreCtx);
|
|
859
860
|
if (result !== true) {
|
|
860
|
-
throw new
|
|
861
|
+
throw new eventHttp.WooksError(400, {
|
|
861
862
|
statusCode: 400,
|
|
862
863
|
message: typeof result === 'string' ? result : firstString(result),
|
|
863
864
|
error: 'Validation Error',
|
package/dist/moost.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { validoIsBoolean } from '@prostojs/valido';
|
|
|
10
10
|
import { validoIsNumber } from '@prostojs/valido';
|
|
11
11
|
import { validoIsString } from '@prostojs/valido';
|
|
12
12
|
import { Wooks } from 'wooks';
|
|
13
|
+
import { WooksHttp } from '@wooksjs/event-http';
|
|
13
14
|
|
|
14
15
|
export declare const All: (path?: string) => MethodDecorator;
|
|
15
16
|
|
|
@@ -164,6 +165,7 @@ export declare class Moost {
|
|
|
164
165
|
provide: TProvideRegistry;
|
|
165
166
|
constructor(options?: TMoostOptions | undefined);
|
|
166
167
|
protected wooksApp?: Wooks;
|
|
168
|
+
protected wooksHttp?: WooksHttp;
|
|
167
169
|
protected unregisteredControllers: (TObject | TFunction)[];
|
|
168
170
|
listen(): Promise<Wooks>;
|
|
169
171
|
listen(port: number): Promise<Wooks>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Wooks } from 'wooks';
|
|
2
|
-
import {
|
|
1
|
+
import { useRouteParams, Wooks } from 'wooks';
|
|
2
|
+
import { useHttpContext, useRequest, useStatus, useSetHeader, useSetCookie, useAuthorization, useHeaders, useCookies, useSearchParams, useResponse, WooksHttp, WooksError } from '@wooksjs/event-http';
|
|
3
3
|
import { Mate, getConstructor, isConstructor } from '@prostojs/mate';
|
|
4
4
|
import { Infact, createProvideRegistry } from '@prostojs/infact';
|
|
5
5
|
import { validoIsTypeOf, validoIsString, validoIsNumber, validoIsBoolean, Valido } from '@prostojs/valido';
|
|
6
|
-
import { useBody } from '@wooksjs/body';
|
|
6
|
+
import { useBody } from '@wooksjs/http-body';
|
|
7
7
|
|
|
8
8
|
const METADATA_WORKSPACE = 'moost';
|
|
9
9
|
const moostMate = new Mate(METADATA_WORKSPACE, {
|
|
@@ -14,22 +14,21 @@ function getMoostMate() {
|
|
|
14
14
|
return moostMate;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
const STORE = Symbol('__moost__');
|
|
18
17
|
function useControllerMeta() {
|
|
19
|
-
const
|
|
18
|
+
const moostStore = useMoostStore();
|
|
20
19
|
return {
|
|
21
|
-
getClassMeta: () => getMoostMate().read(
|
|
22
|
-
getMethodMeta: () => getMoostMate().read(
|
|
20
|
+
getClassMeta: () => getMoostMate().read(moostStore.value.controller),
|
|
21
|
+
getMethodMeta: () => getMoostMate().read(moostStore.value.controller, moostStore.value.method),
|
|
23
22
|
};
|
|
24
23
|
}
|
|
25
24
|
function setComposableControllerContext(data) {
|
|
26
|
-
const
|
|
27
|
-
set('controller', data.controller);
|
|
28
|
-
set('method', data.method);
|
|
29
|
-
set('pathBuilder', data.pathBuilder);
|
|
25
|
+
const moostStore = useMoostStore();
|
|
26
|
+
moostStore.set('controller', data.controller);
|
|
27
|
+
moostStore.set('method', data.method);
|
|
28
|
+
moostStore.set('pathBuilder', data.pathBuilder);
|
|
30
29
|
}
|
|
31
30
|
function useMoostStore() {
|
|
32
|
-
return
|
|
31
|
+
return useHttpContext().store('moost');
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
async function runPipes(pipes, meta, restoreCtx) {
|
|
@@ -97,7 +96,7 @@ function getNewMoostInfact() {
|
|
|
97
96
|
|
|
98
97
|
function bindHandler(getInstance, method, wooksApp, options) {
|
|
99
98
|
const pathBuilder = wooksApp.on(options.httpMethod, options.path, async () => {
|
|
100
|
-
const { restoreCtx } =
|
|
99
|
+
const { restoreCtx } = useHttpContext();
|
|
101
100
|
const { reqId, rawRequest } = useRequest();
|
|
102
101
|
const infact = getMoostInfact();
|
|
103
102
|
const scopeId = reqId();
|
|
@@ -170,7 +169,7 @@ function bindHandler(getInstance, method, wooksApp, options) {
|
|
|
170
169
|
}
|
|
171
170
|
async function applyPipesToArgs(argsPipes) {
|
|
172
171
|
const args = [];
|
|
173
|
-
const { restoreCtx } =
|
|
172
|
+
const { restoreCtx } = useHttpContext();
|
|
174
173
|
for (let i = 0; i < argsPipes.length; i++) {
|
|
175
174
|
const { pipes, meta } = argsPipes[i];
|
|
176
175
|
args[i] = await runPipes(pipes, meta, restoreCtx);
|
|
@@ -246,7 +245,7 @@ function bindControllerMethods(getInstance, classConstructor, wooksApp, options)
|
|
|
246
245
|
const interceptorMeta = mate.read(handler);
|
|
247
246
|
if (interceptorMeta?.injectable) {
|
|
248
247
|
interceptorHandlers.push(async (...args) => {
|
|
249
|
-
const { restoreCtx } =
|
|
248
|
+
const { restoreCtx } = useHttpContext();
|
|
250
249
|
const targetInstance = await getInstance();
|
|
251
250
|
restoreCtx();
|
|
252
251
|
return (await getCallableFn(targetInstance, handler, restoreCtx))(...args);
|
|
@@ -398,7 +397,7 @@ function Cookie(name) {
|
|
|
398
397
|
* @paramType string
|
|
399
398
|
*/
|
|
400
399
|
function Param(name) {
|
|
401
|
-
return Resolve(() => useRouteParams().
|
|
400
|
+
return Resolve(() => useRouteParams().get(name), name);
|
|
402
401
|
}
|
|
403
402
|
/**
|
|
404
403
|
* Get Parsed Params from url parh
|
|
@@ -406,7 +405,7 @@ function Param(name) {
|
|
|
406
405
|
* @paramType object
|
|
407
406
|
*/
|
|
408
407
|
function Params() {
|
|
409
|
-
return Resolve(() => useRouteParams().
|
|
408
|
+
return Resolve(() => useRouteParams().params, 'params');
|
|
410
409
|
}
|
|
411
410
|
/**
|
|
412
411
|
* Get Query Item value or the whole parsed Query as an object
|
|
@@ -646,9 +645,10 @@ class Moost {
|
|
|
646
645
|
this.options = options;
|
|
647
646
|
}
|
|
648
647
|
wooksApp;
|
|
648
|
+
wooksHttp;
|
|
649
649
|
unregisteredControllers = [];
|
|
650
650
|
async listen(port, hostname, cb) {
|
|
651
|
-
this.wooksApp = new Wooks(
|
|
651
|
+
this.wooksApp = new Wooks();
|
|
652
652
|
this.setProvideRegistry(createProvideRegistry([Wooks, () => this.wooksApp], [Moost, () => this]));
|
|
653
653
|
const _port = Number(this.options?.port || port);
|
|
654
654
|
const _hostname = this.options?.hostname || hostname;
|
|
@@ -656,12 +656,13 @@ class Moost {
|
|
|
656
656
|
throw panic('Port is not specified for "listen" method');
|
|
657
657
|
}
|
|
658
658
|
await this.init();
|
|
659
|
-
|
|
659
|
+
this.wooksHttp = new WooksHttp(_port, _hostname, cb);
|
|
660
|
+
await this.wooksApp.subscribe(this.wooksHttp);
|
|
660
661
|
logBright(`🚀 ${getConstructor(this).name} is up and running on port ${_port}`);
|
|
661
662
|
return this.wooksApp;
|
|
662
663
|
}
|
|
663
664
|
close() {
|
|
664
|
-
return this.
|
|
665
|
+
return this.wooksHttp?.close();
|
|
665
666
|
}
|
|
666
667
|
async init() {
|
|
667
668
|
if (this.wooksApp) {
|
|
@@ -849,7 +850,7 @@ function firstString(errors) {
|
|
|
849
850
|
}
|
|
850
851
|
const validatePipe = (opts) => {
|
|
851
852
|
const pipe = async (_value, meta) => {
|
|
852
|
-
const { restoreCtx } =
|
|
853
|
+
const { restoreCtx } = useHttpContext();
|
|
853
854
|
const valido = getMoostValido();
|
|
854
855
|
const result = await valido.validateParam(_value, meta, undefined, undefined, undefined, undefined, 0, 0, opts?.errorLimit || DEFAULT_ERROR_LIMIT, restoreCtx);
|
|
855
856
|
if (result !== true) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller-meta.d.ts","sourceRoot":"","sources":["../../../src/composables/controller-meta.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAE7B,OAAO,EAAgB,cAAc,EAAE,MAAM,aAAa,CAAA;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"controller-meta.d.ts","sourceRoot":"","sources":["../../../src/composables/controller-meta.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAE7B,OAAO,EAAgB,cAAc,EAAE,MAAM,aAAa,CAAA;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAQlC,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,cAAc,GAAG,cAAc;;;EAM1E;AAED,wBAAgB,8BAA8B,CAAC,IAAI,EAAE;IACjD,UAAU,EAAE,OAAO,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,WAAW,EAAE,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;CACxC,QAKA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.decorator.d.ts","sourceRoot":"","sources":["../../../src/decorators/resolve.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resolve.decorator.d.ts","sourceRoot":"","sources":["../../../src/decorators/resolve.decorator.ts"],"names":[],"mappings":"AAQA;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,QAAQ,EAAE,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,kBAAkB,CAKnF;AAED;;;;GAIG;AACH,eAAO,MAAM,UAAU,oBAAuC,CAAA;AAE9D;;;;;GAKG;AACH,eAAO,MAAM,UAAU,SAAU,MAAM,uBAA4C,CAAA;AAEnF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,SAAU,MAAM,uBAA4C,CAAA;AAEnF;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,sBAgBtF;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,sBAKlC;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,sBAElC;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,sBAEjC;AAED;;;;GAIG;AACH,wBAAgB,MAAM,uBAErB;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,kBAAkB,CAYvD;AAED;;;;GAIG;AACH,wBAAgB,GAAG,uBAElB;AAED;;;;GAIG;AACH,wBAAgB,MAAM,uBAErB;AAED;;;;GAIG;AACH,wBAAgB,GAAG,uBAElB;AAED;;;;GAIG;AACH,wBAAgB,KAAK,uBAEpB;AAED;;;;GAIG;AACH,wBAAgB,EAAE,CAAC,IAAI,CAAC,EAAE;IAAE,UAAU,EAAE,OAAO,CAAA;CAAE,sBAEhD;AAED;;;;GAIG;AACH,wBAAgB,MAAM,uBAErB;AAED;;;;;GAKG;AACH,wBAAgB,GAAG,CAAC,OAAO,CAAC,EAAE;IAAE,WAAW,EAAE,OAAO,CAAA;CAAE,sBAErD;AAED;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,sBAEnD;AAED;;;;GAIG;AACH,wBAAgB,IAAI,uBAEnB;AAED;;;;GAIG;AACH,wBAAgB,OAAO,uBAEtB"}
|
package/dist/src/moost.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { TInterceptorData } from './metadata';
|
|
|
3
3
|
import { TPipeData, TPipeFn } from './pipes/types';
|
|
4
4
|
import { TFunction, TObject } from './types';
|
|
5
5
|
import { TProvideRegistry } from '@prostojs/infact';
|
|
6
|
+
import { WooksHttp } from '@wooksjs/event-http';
|
|
6
7
|
export interface TMoostOptions {
|
|
7
8
|
globalPrefix?: string;
|
|
8
9
|
port?: number | string;
|
|
@@ -16,6 +17,7 @@ export declare class Moost {
|
|
|
16
17
|
provide: TProvideRegistry;
|
|
17
18
|
constructor(options?: TMoostOptions | undefined);
|
|
18
19
|
protected wooksApp?: Wooks;
|
|
20
|
+
protected wooksHttp?: WooksHttp;
|
|
19
21
|
protected unregisteredControllers: (TObject | TFunction)[];
|
|
20
22
|
listen(): Promise<Wooks>;
|
|
21
23
|
listen(port: number): Promise<Wooks>;
|
package/dist/src/moost.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"moost.d.ts","sourceRoot":"","sources":["../../src/moost.ts"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"","sources":["../../../src/tests/e2e.spec.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "moost",
|
|
3
|
-
"version": "0.0.1
|
|
3
|
+
"version": "0.0.1",
|
|
4
4
|
"description": "Metadata driven Web App Framework",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/moost.esm-bundler.js",
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"@prostojs/infact": "^0.0.13",
|
|
45
45
|
"@prostojs/mate": "^0.1.10",
|
|
46
46
|
"@prostojs/valido": "^0.0.2",
|
|
47
|
-
"@wooksjs/body": "^0.
|
|
48
|
-
"@wooksjs/
|
|
49
|
-
"wooks": "^0.
|
|
47
|
+
"@wooksjs/http-body": "^0.1.0",
|
|
48
|
+
"@wooksjs/event-http": "^0.1.0",
|
|
49
|
+
"wooks": "^0.1.0"
|
|
50
50
|
},
|
|
51
51
|
"gitHooks": {
|
|
52
52
|
"commit-msg": "node scripts/verifyCommit.js"
|
|
@@ -78,7 +78,6 @@
|
|
|
78
78
|
"fs-extra": "^10.0.0",
|
|
79
79
|
"jest": "^29.3.0",
|
|
80
80
|
"minimist": "^1.2.6",
|
|
81
|
-
"node-fetch-native": "^0.1.8",
|
|
82
81
|
"rollup": "^2.58.0",
|
|
83
82
|
"rollup-plugin-terser": "^7.0.2",
|
|
84
83
|
"rollup-plugin-typescript2": "^0.30.0",
|