Installations
npm install @midwayjs/express-session
Developer Guide
Typescript
No
Module System
CommonJS
Min. Node Version
>=12
Node Version
18.20.4
NPM Version
lerna/7.4.2/node@v18.20.4+arm64 (darwin)
Score
69.2
Supply Chain
97.8
Quality
94.3
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Languages
TypeScript (62.09%)
Shell (34.75%)
JavaScript (2.97%)
CSS (0.15%)
HTML (0.03%)
Developer
Download Statistics
Total Downloads
24,243
Last Day
10
Last Week
166
Last Month
356
Last Year
5,350
GitHub Statistics
7,460 Stars
4,080 Commits
578 Forks
100 Watching
33 Branches
172 Contributors
Bundle Size
38.55 kB
Minified
11.52 kB
Minified + Gzipped
Package Meta Information
Latest Version
3.20.0
Package Id
@midwayjs/express-session@3.20.0
Unpacked Size
13.93 kB
Size
4.48 kB
File Count
14
NPM Version
lerna/7.4.2/node@v18.20.4+arm64 (darwin)
Node Version
18.20.4
Publised On
14 Jan 2025
Total Downloads
Cumulative downloads
Total Downloads
24,243
Last day
-47.4%
10
Compared to previous day
Last week
191.2%
166
Compared to previous week
Last month
3.2%
356
Compared to previous month
Last year
-49.8%
5,350
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
2
Dev Dependencies
4
@midwayjs/express-session
Session component for @midwayjs/express
Install
1$ npm i @midwayjs/express-session --save 2$ npm i @types/express-session --save-dev
Usage
@midwayjs/express has enabled this component by default.
We use cookie-session to keep session by default and use express-session when set custom session store.
Config
You can configure session in your config.*.ts
.
default value.
1export const session = { 2 secret: undefined, // must be set in application 3 name: 'MW_SESS', 4 cookie: { 5 maxAge: 24 * 3600 * 1000, // ms 6 httpOnly: true, 7 // sameSite: null, 8 }, 9};
You can set 'session.cookie' for cookie-session config.
Custom Session Store
You can use compatible session store here.
Let's give an example for memorystore.
1import { Configuration, Inject } from '@midwayjs/core'; 2import * as session from '@midwayjs/express-session'; 3import MemoryStore = require('memorystore'); 4 5@Configuration({ 6 imports: [ 7 express, 8 session, 9 ], 10 //... 11}) 12export class AutoConfiguration { 13 @Inject() 14 sessionStoreManager: session.SessionStoreManager; 15 16 async onReady() { 17 this.sessionStoreManager.setSessionStore(MemoryStore, { 18 checkPeriod: 86400000 // prune expired entries every 24h 19 }); 20 } 21}
Another example for connect-redis.
1import { Configuration, Inject } from '@midwayjs/core'; 2import * as session from '@midwayjs/express-session'; 3import RedisStore from "connect-redis" 4import {createClient} from "redis" 5 6// Initialize client. 7let redisClient = createClient() 8redisClient.connect().catch(console.error) 9 10@Configuration({ 11 imports: [ 12 express, 13 session, 14 ], 15 //... 16}) 17export class AutoConfiguration { 18 @Inject() 19 sessionStoreManager: session.SessionStoreManager; 20 21 async onReady() { 22 // Initialize store. 23 this.sessionStoreManager.setSessionStore(RedisStore, { 24 client: redisClient, 25 prefix: "myapp:", 26 // ... 27 }); 28 } 29}
Questions & Suggestions
Please open an issue here.
License
MIT
No vulnerabilities found.
Reason
30 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
no binaries found in the repo
Reason
Found 4/11 approved changesets -- score normalized to 3
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/benchmark.yml:1
- Warn: no topLevel permission defined: .github/workflows/nodejs.yml:1
- Warn: no topLevel permission defined: .github/workflows/precheck.yml:1
- Warn: no topLevel permission defined: .github/workflows/site.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 26 are checked with a SAST tool
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/benchmark.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/midwayjs/midway/benchmark.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/benchmark.yml:27: update your workflow using https://app.stepsecurity.io/secureworkflow/midwayjs/midway/benchmark.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/benchmark.yml:31: update your workflow using https://app.stepsecurity.io/secureworkflow/midwayjs/midway/benchmark.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/lock.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/midwayjs/midway/lock.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:87: update your workflow using https://app.stepsecurity.io/secureworkflow/midwayjs/midway/nodejs.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:90: update your workflow using https://app.stepsecurity.io/secureworkflow/midwayjs/midway/nodejs.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/nodejs.yml:95: update your workflow using https://app.stepsecurity.io/secureworkflow/midwayjs/midway/nodejs.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/nodejs.yml:115: update your workflow using https://app.stepsecurity.io/secureworkflow/midwayjs/midway/nodejs.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/precheck.yml:76: update your workflow using https://app.stepsecurity.io/secureworkflow/midwayjs/midway/precheck.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/precheck.yml:79: update your workflow using https://app.stepsecurity.io/secureworkflow/midwayjs/midway/precheck.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/precheck.yml:84: update your workflow using https://app.stepsecurity.io/secureworkflow/midwayjs/midway/precheck.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/site.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/midwayjs/midway/site.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/site.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/midwayjs/midway/site.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/site.yml:29: update your workflow using https://app.stepsecurity.io/secureworkflow/midwayjs/midway/site.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/site.yml:51: update your workflow using https://app.stepsecurity.io/secureworkflow/midwayjs/midway/site.yml/main?enable=pin
- Warn: npmCommand not pinned by hash: benchmark/ready.sh:5
- Warn: npmCommand not pinned by hash: benchmark/ready.sh:15
- Warn: npmCommand not pinned by hash: scripts/install_npm.sh:10
- Warn: npmCommand not pinned by hash: .github/workflows/benchmark.yml:49
- Warn: npmCommand not pinned by hash: .github/workflows/benchmark.yml:51
- Warn: npmCommand not pinned by hash: .github/workflows/nodejs.yml:101
- Warn: npmCommand not pinned by hash: .github/workflows/nodejs.yml:101
- Warn: npmCommand not pinned by hash: .github/workflows/precheck.yml:89
- Warn: npmCommand not pinned by hash: .github/workflows/site.yml:34
- Warn: npmCommand not pinned by hash: .github/workflows/site.yml:43
- Info: 0 out of 9 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 6 third-party GitHubAction dependencies pinned
- Info: 0 out of 10 npmCommand dependencies pinned
Reason
34 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-4w2v-q235-vp99
- Warn: Project is vulnerable to: GHSA-cph5-m8f7-6c5x
- Warn: Project is vulnerable to: GHSA-wf5p-g6vw-rhxx
- Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-rv95-896h-c2vc
- Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx
- Warn: Project is vulnerable to: GHSA-jchw-25xp-jwwc
- Warn: Project is vulnerable to: GHSA-cxjh-pqwp-8mfp
- Warn: Project is vulnerable to: GHSA-74fj-2j2h-c42q
- Warn: Project is vulnerable to: GHSA-pw2r-vq6v-hr8c
- Warn: Project is vulnerable to: GHSA-pfrx-2q88-qq97
- Warn: Project is vulnerable to: GHSA-rc47-6667-2j5j
- Warn: Project is vulnerable to: GHSA-c7qv-q95q-8v27
- Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
- Warn: Project is vulnerable to: GHSA-rp65-9cf3-cjxr
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
- Warn: Project is vulnerable to: GHSA-rhx6-c78j-4q9w
- Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-325j-24f4-qv5x
- Warn: Project is vulnerable to: GHSA-vx3p-948g-6vhq
- Warn: Project is vulnerable to: GHSA-w5p7-h5w8-2hfq
- Warn: Project is vulnerable to: GHSA-4vvj-4cpr-p986
- Warn: Project is vulnerable to: GHSA-wr3j-pwj9-hqq6
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
Score
4.1
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More