@adonisjs/session 6.2.1 → 6.2.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.
@@ -90,36 +90,42 @@ function defineTestsBindings(ApiRequest, ApiResponse, ApiClient, SessionManager)
90
90
  this.assert.notProperty(this.flashMessages(), name);
91
91
  });
92
92
  /**
93
- * Hook into request and persist session data to be available
94
- * on the server during the request.
93
+ * Adding hooks directly on the request object moves the hooks to
94
+ * the end of the queue (basically after the globally hooks)
95
95
  */
96
- ApiClient.setup(async (request) => {
96
+ ApiClient.onRequest((req) => {
97
97
  /**
98
- * Persist session data and set the session id within the
99
- * cookie
98
+ * Hook into request and persist session data to be available
99
+ * on the server during the request.
100
100
  */
101
- const { cookieName, sessionId } = await request.sessionClient.commit();
102
- request.cookie(cookieName, sessionId);
101
+ req.setup(async (request) => {
102
+ /**
103
+ * Persist session data and set the session id within the
104
+ * cookie
105
+ */
106
+ const { cookieName, sessionId } = await request.sessionClient.commit();
107
+ request.cookie(cookieName, sessionId);
108
+ /**
109
+ * Cleanup if request has error. Otherwise the teardown
110
+ * hook will clear
111
+ */
112
+ return async (error) => {
113
+ if (error) {
114
+ await request.sessionClient.forget();
115
+ }
116
+ };
117
+ });
103
118
  /**
104
- * Cleanup if request has error. Otherwise the teardown
105
- * hook will clear
119
+ * Load messages from the session store and keep a reference to it
120
+ * inside the response object.
121
+ *
122
+ * We also destroy the session after getting a copy of the session
123
+ * data
106
124
  */
107
- return async (error) => {
108
- if (error) {
109
- await request.sessionClient.forget();
110
- }
111
- };
112
- });
113
- /**
114
- * Load messages from the session store and keep a reference to it
115
- * inside the response object.
116
- *
117
- * We also destroy the session after getting a copy of the session
118
- * data
119
- */
120
- ApiClient.teardown(async (response) => {
121
- response.sessionJar = await response.request.sessionClient.load();
122
- await response.request.sessionClient.forget();
125
+ req.teardown(async (response) => {
126
+ response.sessionJar = await response.request.sessionClient.load();
127
+ await response.request.sessionClient.forget();
128
+ });
123
129
  });
124
130
  }
125
131
  exports.defineTestsBindings = defineTestsBindings;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adonisjs/session",
3
- "version": "6.2.1",
3
+ "version": "6.2.2",
4
4
  "description": "Session provider for AdonisJS",
5
5
  "typings": "./build/adonis-typings/index.d.ts",
6
6
  "main": "build/providers/SessionProvider.js",
@@ -12,19 +12,19 @@
12
12
  "build/instructions.md"
13
13
  ],
14
14
  "dependencies": {
15
- "@poppinss/utils": "^4.0.3",
15
+ "@poppinss/utils": "^4.0.4",
16
16
  "fs-extra": "^10.0.1"
17
17
  },
18
18
  "peerDependencies": {
19
19
  "@adonisjs/core": "^5.5.0"
20
20
  },
21
21
  "devDependencies": {
22
- "@adonisjs/core": "^5.7.1",
22
+ "@adonisjs/core": "^5.7.3",
23
23
  "@adonisjs/mrm-preset": "^5.0.3",
24
24
  "@adonisjs/redis": "^7.2.0",
25
25
  "@adonisjs/require-ts": "^2.0.11",
26
26
  "@japa/assert": "^1.3.4",
27
- "@japa/preset-adonis": "^1.0.14",
27
+ "@japa/preset-adonis": "^1.0.15",
28
28
  "@japa/run-failed-tests": "^1.0.7",
29
29
  "@japa/runner": "^2.0.7",
30
30
  "@japa/spec-reporter": "^1.1.12",
@@ -35,7 +35,7 @@
35
35
  "copyfiles": "^2.4.1",
36
36
  "cz-conventional-changelog": "^3.3.0",
37
37
  "del-cli": "^4.0.1",
38
- "eslint": "^8.12.0",
38
+ "eslint": "^8.13.0",
39
39
  "eslint-config-prettier": "^8.5.0",
40
40
  "eslint-plugin-adonis": "^2.1.0",
41
41
  "eslint-plugin-prettier": "^4.0.0",