@domain.js/main 0.1.9 → 0.1.10

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.
@@ -0,0 +1,14 @@
1
+ import * as TypeORM from "typeorm";
2
+ interface Cnf {
3
+ typeorm: {
4
+ [propName: string]: Parameters<typeof TypeORM.createConnection>[0];
5
+ };
6
+ }
7
+ interface Deps {
8
+ TypeORM: typeof TypeORM;
9
+ }
10
+ export declare function Main(cnf: Cnf, deps: Deps): Promise<{
11
+ [propName: string]: TypeORM.Connection;
12
+ }>;
13
+ export declare const Deps: string[];
14
+ export {};
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Deps = exports.Main = void 0;
4
+ async function Main(cnf, deps) {
5
+ // 这里之所以要注入 Sequelize 是为了保证项目自身可以灵活选择自己的 Sequelize 版本, 这样改公共模块就会更加稳定, 避免频繁升级
6
+ const { typeorm: dbs } = cnf;
7
+ const { TypeORM } = deps;
8
+ const links = {};
9
+ for await (const k of Object.keys(dbs)) {
10
+ const db = dbs[k];
11
+ links[k] = await TypeORM.createConnection(db);
12
+ }
13
+ return links;
14
+ }
15
+ exports.Main = Main;
16
+ exports.Deps = ["TypeORM"];
@@ -22,6 +22,8 @@ export interface Profile {
22
22
  userAgent: string;
23
23
  startedAt: Date;
24
24
  requestId: string;
25
+ /** 自由挂载信息的节点 */
26
+ extra: Record<string, any>;
25
27
  revision?: string;
26
28
  uuid?: string;
27
29
  token?: string;
@@ -49,6 +49,7 @@ function Utils(cnf) {
49
49
  userAgent: req.userAgent(),
50
50
  startedAt: new Date(),
51
51
  requestId: req.id(),
52
+ extra: {},
52
53
  };
53
54
  const token = req.headers["x-auth-token"] || req.query.access_token || req.query.accessToken;
54
55
  // token 和签名认证只能二选一
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domain.js/main",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "DDD framework",
5
5
  "main": "dist/index.js",
6
6
  "bin": {