From ebccbf270f7ad3eb5f736dd662d503ab707fce1b Mon Sep 17 00:00:00 2001 From: yutent Date: Thu, 2 Jan 2025 18:37:40 +0800 Subject: [PATCH] update --- index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 061afe5..a28406f 100644 --- a/index.js +++ b/index.js @@ -12,6 +12,7 @@ const DEFAULT_CONFIG = { ttl: 3600 * 24 * 7, domain: '', // NODESSID域, 默认等于domain level: 0, // 校验级别, 0: 不校验客户端, 2: ua, 4: ip, 6: ua + ip + secret: 'it_is_secret_key', // jwt密钥, 使用时请修改 db: { host: '127.0.0.1', port: 6379, @@ -23,8 +24,12 @@ const DEFAULT_CONFIG = { export const SessionModule = { name: 'session', install(conf = {}) { - if (!conf.domain) { - throw new Error('Please make sure to set the `domain` field') + if (!conf.secret) { + console.warn( + new Error( + 'You must set a `secret` key for session, or it will use the default key.' + ) + ) } let session = Object.assign({}, DEFAULT_CONFIG, conf) this.set({ session })