-
Notifications
You must be signed in to change notification settings - Fork 1
feat: make Redis session store optional #255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,29 @@ const apostrophe = require('apostrophe'); | |
| require('dotenv').config({ path: '../.env' }); | ||
| const { getEnv } = require('./utils/env'); | ||
|
|
||
| /** | ||
| * Creates the Apostrophe CMS configuration object. | ||
| * Configures session (with optional Redis store), base URL, CORS, and all | ||
| * modules (express, template, widgets, pieces, etc.). | ||
| * | ||
| * @returns {object} Apostrophe configuration with shortName, baseUrl, and modules. | ||
| */ | ||
| function createAposConfig() { | ||
| const redisUri = process.env.REDIS_URI; | ||
|
|
||
| const sessionConfig = { | ||
| secret: getEnv('SESSION_SECRET'), | ||
| }; | ||
|
|
||
| if (redisUri) { | ||
| sessionConfig.store = { | ||
| connect: require('connect-redis'), | ||
| options: { | ||
| url: redisUri, | ||
| }, | ||
| }; | ||
| } | ||
|
Comment on lines
+13
to
+26
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # Check the current state of the code files mentioned
head -30 website/app.jsRepository: speedandfunction/website Length of output: 882 🏁 Script executed: # Check the test file to see what it expects
sed -n '60,75p' website/app.test.jsRepository: speedandfunction/website Length of output: 485 🏁 Script executed: # Find package.json to check `@apostrophecms/express` version
find . -name "package.json" -type f | head -5Repository: speedandfunction/website Length of output: 117 🏁 Script executed: # Search for `@apostrophecms/express` in dependencies
rg "@apostrophecms/express" --type jsonRepository: speedandfunction/website Length of output: 50 🏁 Script executed: cat website/package.json | grep -A 5 "@apostrophecms"Repository: speedandfunction/website Length of output: 732 🏁 Script executed: # Search for any documentation or comments about session behavior in the codebase
rg "session" -t js -i | head -20Repository: speedandfunction/website Length of output: 1211 🏁 Script executed: # Look for the full test context to understand expectations
sed -n '50,80p' website/app.test.jsRepository: speedandfunction/website Length of output: 926 🏁 Script executed: # Search for any configuration or setup that might define session defaults
rg "MemoryStore|sessionConfig" -t js -B 2 -A 2Repository: speedandfunction/website Length of output: 639 🏁 Script executed: # Check if there's an express module configuration
cat website/modules/@apostrophecms/express/index.jsRepository: speedandfunction/website Length of output: 280 🏁 Script executed: # Look for any documentation files or comments about session handling
find . -type f \( -name "*.md" -o -name "*.txt" \) | xargs rg -l "session" 2>/dev/null | head -5Repository: speedandfunction/website Length of output: 50 🏁 Script executed: # Check if there are any other session-related configurations
rg "store.*:" website/app.js -B 3 -A 3Repository: speedandfunction/website Length of output: 50 🏁 Script executed: # Search for any comments or documentation about the default session behavior
rg "MongoDB|MemoryStore|session.*default" -iRepository: speedandfunction/website Length of output: 5942 🏁 Script executed: # Check if there's any initialization code that sets up session handling
rg "express.*session|connect.*session" -i -t jsRepository: speedandfunction/website Length of output: 338 🏁 Script executed: # Look at the full createAposConfig function to see where sessionConfig is used
sed -n '13,100p' website/app.js | cat -nRepository: speedandfunction/website Length of output: 2930 🏁 Script executed: # Search for any references to how `@apostrophecms/express` handles session
rg "@apostrophecms/express" -A 5 -B 5 website/app.jsRepository: speedandfunction/website Length of output: 348 🌐 Web query:
💡 Result:
If you want something else (e.g., Redis), you can configure Source
🌐 Web query:
💡 Result: If you leave In Apostrophe 3, the Sources: 🏁 Script executed: # Check if there's any documentation in the node_modules or comments
rg "session.*store.*MongoDB|default.*session" -i -B 2 -A 2Repository: speedandfunction/website Length of output: 50 🏁 Script executed: # Let's verify the exact test expectation and name one more time
sed -n '64,72p' website/app.test.jsRepository: speedandfunction/website Length of output: 326 🏁 Script executed: # Check if there are any comments in the codebase about the session store behavior
rg "session.*store" -B 3 -A 3 website/app.js | head -30Repository: speedandfunction/website Length of output: 477 🏁 Script executed: # Check if there's an explicit MemoryStore or any other session store setup
rg "MemoryStore|connect-mongo|session.*default" -t jsRepository: speedandfunction/website Length of output: 50 🏁 Script executed: # Look at the apostrophe version to confirm it's version 4.x (modern)
grep '"apostrophe"' website/package.jsonRepository: speedandfunction/website Length of output: 96 The test name and code comment are misleading—the fallback is MongoDB-backed, not in-memory. When 🤖 Prompt for AI Agents |
||
|
|
||
| return { | ||
| shortName: 'apostrophe-site', | ||
| baseUrl: process.env.BASE_URL || 'https://speedandfunction.com', | ||
|
|
@@ -13,16 +35,7 @@ function createAposConfig() { | |
| '@apostrophecms/security-headers': {}, | ||
| '@apostrophecms/express': { | ||
| options: { | ||
| session: { | ||
| // If using Redis (recommended for production) | ||
| secret: getEnv('SESSION_SECRET'), | ||
| store: { | ||
| connect: require('connect-redis'), | ||
| options: { | ||
| url: getEnv('REDIS_URI'), | ||
| }, | ||
| }, | ||
| }, | ||
| session: sessionConfig, | ||
| csrf: { | ||
| cookie: { | ||
| key: '_csrf', | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.