Skip to content

Commit

Permalink
fix: should export sessionStore
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Jan 21, 2025
1 parent 1909d44 commit 72b3ed8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ egg-session support external store, you can store your sessions in redis, memcac

For example, if you want to store session in redis, you must:

1. Dependent [egg-redis](https://github.com/eggjs/egg-redis)
1. Dependent [@eggjs/redis](https://github.com/eggjs/redis)

```bash
npm i --save egg-redis
npm i --save @eggjs/redis
```

2. Import egg-redis as a plugin and set the configuration
2. Import `@eggjs/redis` as a plugin and set the configuration

```js
// config/plugin.js
exports.redis = {
enable: true,
package: 'egg-redis',
package: '@eggjs/redis',
};
```

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@
"node": ">= 18.19.0"
},
"dependencies": {
"@eggjs/core": "^6.2.13",
"@eggjs/core": "^6.3.1",
"koa-session": "^7.0.2",
"zod": "^3.24.1"
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.17.1",
"@eggjs/bin": "7",
"@eggjs/mock": "^6.0.5",
"@eggjs/redis": "^3.0.0",
"@eggjs/supertest": "^8.2.0",
"@eggjs/tsconfig": "1",
"@types/mocha": "10",
"@types/node": "22",
"egg": "^4.0.1",
"egg-redis": "^2.6.0",
"egg": "^4.0.3",
"eslint": "8",
"eslint-config-egg": "14",
"rimraf": "6",
Expand Down
7 changes: 7 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import type { SessionConfig } from './config/config.default.js';
import type { SessionStoreOrAppSessionStoreClass, SessionStore } from './app/extend/application.js';

declare module '@eggjs/core' {
// add EggAppConfig overrides types
interface EggAppConfig {
session: SessionConfig;
}

interface EggCore {
// add EggCore instance property
set sessionStore(store: SessionStoreOrAppSessionStoreClass | null | undefined);
get sessionStore(): SessionStore | undefined;
}
}
4 changes: 1 addition & 3 deletions test/fixtures/redis-session/config/plugin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
'use strict';

exports.redis = {
enable: true,
package: 'egg-redis',
package: '@eggjs/redis',
};

0 comments on commit 72b3ed8

Please sign in to comment.