@ditojs/server 2.26.0 → 2.26.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ditojs/server",
3
- "version": "2.26.0",
3
+ "version": "2.26.2",
4
4
  "type": "module",
5
5
  "description": "Dito.js Server – Dito.js is a declarative and modern web framework, based on Objection.js, Koa.js and Vue.js",
6
6
  "repository": "https://github.com/ditojs/dito/tree/master/packages/server",
@@ -22,10 +22,10 @@
22
22
  "node >= 18"
23
23
  ],
24
24
  "dependencies": {
25
- "@ditojs/admin": "^2.26.0",
26
- "@ditojs/build": "^2.26.0",
27
- "@ditojs/router": "^2.26.0",
28
- "@ditojs/utils": "^2.26.0",
25
+ "@ditojs/admin": "^2.26.2",
26
+ "@ditojs/build": "^2.26.1",
27
+ "@ditojs/router": "^2.26.1",
28
+ "@ditojs/utils": "^2.26.1",
29
29
  "@koa/cors": "^5.0.0",
30
30
  "@koa/multer": "^3.0.2",
31
31
  "@originjs/vite-plugin-commonjs": "^1.0.3",
@@ -38,7 +38,7 @@
38
38
  "data-uri-to-buffer": "^6.0.2",
39
39
  "eventemitter2": "^6.4.9",
40
40
  "file-type": "^19.0.0",
41
- "koa": "^2.15.2",
41
+ "koa": "^2.15.3",
42
42
  "koa-bodyparser": "^4.4.1",
43
43
  "koa-compose": "^4.1.0",
44
44
  "koa-compress": "^5.1.1",
@@ -76,21 +76,21 @@
76
76
  "objection": "^3.0.1"
77
77
  },
78
78
  "devDependencies": {
79
- "@aws-sdk/client-s3": "^3.550.0",
80
- "@aws-sdk/lib-storage": "^3.550.0",
79
+ "@aws-sdk/client-s3": "^3.554.0",
80
+ "@aws-sdk/lib-storage": "^3.554.0",
81
81
  "@types/koa-bodyparser": "^4.3.12",
82
82
  "@types/koa-compress": "^4.0.6",
83
83
  "@types/koa-response-time": "^2.1.5",
84
84
  "@types/koa-session": "^6.4.5",
85
85
  "@types/koa-static": "^4.0.4",
86
86
  "@types/koa__cors": "^5.0.0",
87
- "@types/node": "^20.12.5",
87
+ "@types/node": "^20.12.7",
88
88
  "knex": "^3.1.0",
89
89
  "objection": "^3.1.4",
90
- "typescript": "^5.4.4"
90
+ "typescript": "^5.4.5"
91
91
  },
92
92
  "types": "types",
93
- "gitHead": "da47b5b8b9fca80193a7e93344bdc14cdaada329",
93
+ "gitHead": "7fd7a0b9a8727e1a27a8e78e7381f58c95017499",
94
94
  "scripts": {
95
95
  "types": "tsc --noEmit --esModuleInterop ./types/index.d.ts"
96
96
  },
@@ -51,6 +51,7 @@ import {
51
51
  attachLogger,
52
52
  createTransaction,
53
53
  findRoute,
54
+ extendContext,
54
55
  handleError,
55
56
  handleRoute,
56
57
  handleSession,
@@ -580,6 +581,7 @@ export class Application extends Koa {
580
581
  // This needs to be positioned after the request logger to log the correct
581
582
  // response status.
582
583
  this.use(handleError())
584
+ this.use(extendContext())
583
585
  if (app.helmet !== false) {
584
586
  this.use(helmet(getOptions(app.helmet)))
585
587
  }
@@ -61,18 +61,12 @@ export class CollectionController extends Controller {
61
61
  : path
62
62
  }
63
63
 
64
- extendContext(ctx, object) {
65
- // Create a copy of `ctx` that inherits from the real one, but overrides
66
- // some properties with the ones from the passed `object`.
67
- return Object.setPrototypeOf(object, ctx)
68
- }
69
-
70
64
  getMemberId(ctx) {
71
65
  return this.validateId(ctx.params[this.idParam])
72
66
  }
73
67
 
74
68
  getContextWithMemberId(ctx, memberId = this.getMemberId(ctx)) {
75
- return this.extendContext(ctx, { memberId })
69
+ return ctx.extend({ memberId })
76
70
  }
77
71
 
78
72
  getModelId(model) {
@@ -121,7 +115,7 @@ export class CollectionController extends Controller {
121
115
  this,
122
116
  // Extend `ctx` with a new `query` object, while inheriting the route
123
117
  // params in `ctx.params`, so fining the member by id still works.
124
- this.extendContext(ctx, { query }),
118
+ ctx.extend({ query }),
125
119
  (query, trx) => {
126
120
  this.setupQuery(query, base)
127
121
  query.modify(modify)
@@ -0,0 +1,10 @@
1
+ export function extendContext() {
2
+ return (ctx, next) => {
3
+ ctx.extend = function (object) {
4
+ // Create a copy of this context that inherits from the real one, but
5
+ // overrides some properties with the ones from the passed `object`.
6
+ return Object.setPrototypeOf(object, this)
7
+ }
8
+ return next()
9
+ }
10
+ }
@@ -1,5 +1,6 @@
1
1
  export * from './attachLogger.js'
2
2
  export * from './createTransaction.js'
3
+ export * from './extendContext.js'
3
4
  export * from './findRoute.js'
4
5
  export * from './handleConnectMiddleware.js'
5
6
  export * from './handleError.js'