@keltoi/hydra 2.3.7 → 2.4.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/index.js +23 -10
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -57,6 +57,22 @@ class Result {
|
|
|
57
57
|
.status(this.#code)
|
|
58
58
|
.json(this.#data);
|
|
59
59
|
}
|
|
60
|
+
|
|
61
|
+
static createInstance = (err)=>
|
|
62
|
+
(err instanceof Result)
|
|
63
|
+
? Promise.reject(err)
|
|
64
|
+
: Promise.reject(
|
|
65
|
+
!!err.message
|
|
66
|
+
? new Result({
|
|
67
|
+
code:500,
|
|
68
|
+
message:err.message
|
|
69
|
+
})
|
|
70
|
+
: new Result({
|
|
71
|
+
code:500,
|
|
72
|
+
data:err,
|
|
73
|
+
message:'Server error'
|
|
74
|
+
})
|
|
75
|
+
)
|
|
60
76
|
}
|
|
61
77
|
|
|
62
78
|
class Entity{
|
|
@@ -222,7 +238,7 @@ class Traceable extends Entity{
|
|
|
222
238
|
}
|
|
223
239
|
|
|
224
240
|
class Status extends Entity{
|
|
225
|
-
static build=({ id=1,description='' })=>new Status({id,description})
|
|
241
|
+
static build=({ id=1,description='',data={} })=>new Status({id,description,data})
|
|
226
242
|
|
|
227
243
|
static structMe(
|
|
228
244
|
db=knex(),
|
|
@@ -249,8 +265,8 @@ class Status extends Entity{
|
|
|
249
265
|
)
|
|
250
266
|
}
|
|
251
267
|
|
|
252
|
-
constructor({ id=1, description=''}){
|
|
253
|
-
super({ id }, { status:description });
|
|
268
|
+
constructor({ id=1, description='', data={}}){
|
|
269
|
+
super({ id }, { status:description, ...data });
|
|
254
270
|
}
|
|
255
271
|
|
|
256
272
|
get description(){ return this.data.status }
|
|
@@ -374,11 +390,11 @@ class Migration{
|
|
|
374
390
|
|
|
375
391
|
if (iteration >= listSize) return
|
|
376
392
|
|
|
377
|
-
|
|
393
|
+
for (let index = iteration; index < listSize; index++) await migrations[index]();
|
|
378
394
|
|
|
379
395
|
await this.#update({ iteration:listSize,name });
|
|
380
396
|
} catch(err){
|
|
381
|
-
|
|
397
|
+
|
|
382
398
|
console.error(err);
|
|
383
399
|
}
|
|
384
400
|
}
|
|
@@ -785,8 +801,7 @@ class Service {
|
|
|
785
801
|
|
|
786
802
|
get context(){return this.#context}
|
|
787
803
|
|
|
788
|
-
handleError = (code,message)=>Promise.reject(new Result({code,message}))
|
|
789
|
-
handleFailure = (err)=> this.handleError({code:500,message:err.message})
|
|
804
|
+
handleError = ({code,message})=> Promise.reject(new Result({code,message}))
|
|
790
805
|
}
|
|
791
806
|
|
|
792
807
|
class Handler {
|
|
@@ -800,9 +815,7 @@ class Handler {
|
|
|
800
815
|
}
|
|
801
816
|
|
|
802
817
|
handle(){}
|
|
803
|
-
handleError({ code, message }) {
|
|
804
|
-
return Promise.reject(new Result({ code, message }));
|
|
805
|
-
}
|
|
818
|
+
handleError = ({ code, message }) => Promise.reject(new Result({ code, message }));
|
|
806
819
|
}
|
|
807
820
|
|
|
808
821
|
let Context$1 = class Context{
|