@spinajs/orm-http 1.2.111 → 1.2.118
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/lib/index.d.ts +8 -2
- package/lib/index.js +22 -1
- package/lib/index.js.map +1 -1
- package/package.json +5 -5
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Orm } from '@spinajs/orm';
|
|
2
|
-
import { IRouteArgs, IRouteParameter, IRouteCall, ParameterType } from '@spinajs/http';
|
|
3
|
-
import { AsyncModule, IContainer } from '@spinajs/di';
|
|
2
|
+
import { IRouteArgs, IRouteParameter, IRouteCall, ParameterType, ArgHydrator } from '@spinajs/http';
|
|
3
|
+
import { AsyncModule, IContainer, Bootstrapper } from '@spinajs/di';
|
|
4
4
|
import * as express from 'express';
|
|
5
5
|
export declare class FromDbModel extends AsyncModule implements IRouteArgs {
|
|
6
6
|
protected Container: IContainer;
|
|
@@ -12,4 +12,10 @@ export declare class FromDbModel extends AsyncModule implements IRouteArgs {
|
|
|
12
12
|
Args: any;
|
|
13
13
|
}>;
|
|
14
14
|
}
|
|
15
|
+
export declare class DbModelHydrator extends ArgHydrator {
|
|
16
|
+
hydrate(input: any, parameter: IRouteParameter): Promise<any>;
|
|
17
|
+
}
|
|
15
18
|
export declare function FromDB(field?: string, type?: ParameterType): (target: any, propertyKey?: string | symbol, indexOrDescriptor?: number | PropertyDescriptor) => void;
|
|
19
|
+
export declare class OrmHttpBootstrapper extends Bootstrapper {
|
|
20
|
+
bootstrap(): Promise<void>;
|
|
21
|
+
}
|
package/lib/index.js
CHANGED
|
@@ -9,7 +9,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.FromDB = exports.FromDbModel = void 0;
|
|
12
|
+
exports.OrmHttpBootstrapper = exports.FromDB = exports.DbModelHydrator = exports.FromDbModel = void 0;
|
|
13
13
|
const orm_1 = require("@spinajs/orm");
|
|
14
14
|
const http_1 = require("@spinajs/http");
|
|
15
15
|
const di_1 = require("@spinajs/di");
|
|
@@ -52,8 +52,29 @@ FromDbModel = __decorate([
|
|
|
52
52
|
(0, di_1.Injectable)()
|
|
53
53
|
], FromDbModel);
|
|
54
54
|
exports.FromDbModel = FromDbModel;
|
|
55
|
+
class DbModelHydrator extends http_1.ArgHydrator {
|
|
56
|
+
async hydrate(input, parameter) {
|
|
57
|
+
const model = new parameter.RuntimeType();
|
|
58
|
+
model.hydrate(input);
|
|
59
|
+
return model;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.DbModelHydrator = DbModelHydrator;
|
|
55
63
|
function FromDB(field, type) {
|
|
56
64
|
return (0, http_1.Route)((0, http_1.Parameter)('FromDbModel', null, { field, type }));
|
|
57
65
|
}
|
|
58
66
|
exports.FromDB = FromDB;
|
|
67
|
+
let OrmHttpBootstrapper = class OrmHttpBootstrapper extends di_1.Bootstrapper {
|
|
68
|
+
async bootstrap() {
|
|
69
|
+
const orm = await di_1.DI.resolve(orm_1.Orm);
|
|
70
|
+
// set default route parameter hydrator for all loaded models
|
|
71
|
+
orm.Models.forEach((m) => {
|
|
72
|
+
Reflect.defineMetadata('custom:arg_hydrator', { hydrator: DbModelHydrator }, m.type);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
OrmHttpBootstrapper = __decorate([
|
|
77
|
+
(0, di_1.Injectable)(di_1.Bootstrapper)
|
|
78
|
+
], OrmHttpBootstrapper);
|
|
79
|
+
exports.OrmHttpBootstrapper = OrmHttpBootstrapper;
|
|
59
80
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;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{
|
|
2
2
|
"name": "@spinajs/orm-http",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.118",
|
|
4
4
|
"description": "Orm extensions for HTTP module",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"private": false,
|
|
@@ -41,16 +41,16 @@
|
|
|
41
41
|
"@spinajs/configuration": "^1.2.81",
|
|
42
42
|
"@spinajs/di": "^1.2.81",
|
|
43
43
|
"@spinajs/exceptions": "^1.2.81",
|
|
44
|
-
"@spinajs/http": "^1.2.
|
|
44
|
+
"@spinajs/http": "^1.2.115",
|
|
45
45
|
"@spinajs/log": "^1.2.103",
|
|
46
|
-
"@spinajs/orm": "^1.2.
|
|
46
|
+
"@spinajs/orm": "^1.2.118",
|
|
47
47
|
"lodash": "^4.17.21",
|
|
48
48
|
"luxon": "^2.4.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@spinajs/http": "1.2.108",
|
|
52
52
|
"@spinajs/orm": "1.2.108",
|
|
53
|
-
"@spinajs/orm-sqlite": "^1.2.
|
|
53
|
+
"@spinajs/orm-sqlite": "^1.2.118"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "d19c71703e92e7df2f5dba7f9729ad3dabbaaf80"
|
|
56
56
|
}
|