A social knowledge tool for researchers built on ATProto

Merge pull request #151 from cosmik-network/fix/mock-persistence-config

Fix/mock persistence config

authored by

Wesley Finck and committed by
GitHub
e413c196 0b5a32d9

+28 -37
-3
.github/ISSUE_TEMPLATE/bug-report.md
··· 4 4 title: '' 5 5 labels: bug 6 6 assignees: '' 7 - 8 7 --- 9 - 10 -
-3
.github/ISSUE_TEMPLATE/feature.md
··· 4 4 title: '' 5 5 labels: feature 6 6 assignees: '' 7 - 8 7 --- 9 - 10 -
-3
.github/ISSUE_TEMPLATE/task.md
··· 4 4 title: '' 5 5 labels: task 6 6 assignees: '' 7 - 8 7 --- 9 - 10 -
+1 -1
package.json
··· 34 34 "dev:app:inner": "dotenv -e .env.local -- concurrently -k -n TYPE,APP -c red,blue \"tsc --noEmit --watch\" \"tsup --watch --onSuccess='node dist/index.js'\"", 35 35 "dev:worker:feeds:inner": "dotenv -e .env.local -- concurrently -k -n WORKER -c green \"tsup --watch --onSuccess='node dist/workers/feed-worker.js'\"", 36 36 "dev:worker:search:inner": "dotenv -e .env.local -- concurrently -k -n WORKER -c yellow \"tsup --watch --onSuccess='node dist/workers/search-worker.js'\"", 37 - "dev:mock": "USE_PERSISTENCE=false USE_FAKE_PUBLISHERS=true USE_MOCK_AUTH=true npm run dev:app:inner", 37 + "dev:mock": "USE_MOCK_PERSISTENCE=true USE_FAKE_PUBLISHERS=true USE_MOCK_AUTH=true USE_MOCK_VECTOR_DB=true npm run dev:app:inner", 38 38 "dev:mock:pub:auth": "USE_FAKE_PUBLISHERS=true USE_MOCK_AUTH=true npm run dev", 39 39 "dev": "bash ./scripts/dev-combined.sh", 40 40 "migrate": "node dist/scripts/migrate.js",
+2 -2
src/modules/atproto/infrastructure/__tests__/ATProtoCardPublisher.integration.test.ts
··· 12 12 dotenv.config({ path: '.env.test' }); 13 13 14 14 // Set to false to skip unpublishing (useful for debugging published records) 15 - const UNPUBLISH = false; 15 + const UNPUBLISH = true; 16 16 17 - describe('ATProtoCardPublisher', () => { 17 + describe.skip('ATProtoCardPublisher', () => { 18 18 let publisher: ATProtoCardPublisher; 19 19 let curatorId: CuratorId; 20 20 let publishedCardIds: PublishedRecordId[] = [];
+2 -2
src/modules/atproto/infrastructure/__tests__/ATProtoCollectionPublisher.integration.test.ts
··· 15 15 dotenv.config({ path: '.env.test' }); 16 16 17 17 // Set to false to skip unpublishing (useful for debugging published records) 18 - const UNPUBLISH = false; 18 + const UNPUBLISH = true; 19 19 20 - describe('ATProtoCollectionPublisher', () => { 20 + describe.skip('ATProtoCollectionPublisher', () => { 21 21 let collectionPublisher: ATProtoCollectionPublisher; 22 22 let cardPublisher: FakeCardPublisher; 23 23 let curatorId: CuratorId;
+15 -15
src/shared/infrastructure/config/EnvironmentConfigService.ts
··· 7 7 export interface EnvironmentConfig { 8 8 environment: Environment; 9 9 runtime: { 10 - usePersistence: boolean; 10 + useMockPersistence: boolean; 11 11 useMockAuth: boolean; 12 12 useFakePublishers: boolean; 13 13 useMockVectorDb: boolean; ··· 64 64 this.config = { 65 65 environment, 66 66 runtime: { 67 - usePersistence: this.determinePersistenceFlag(), 67 + useMockPersistence: this.determineMockPersistenceFlag(), 68 68 useMockAuth: process.env.USE_MOCK_AUTH === 'true', 69 69 useFakePublishers: process.env.USE_FAKE_PUBLISHERS === 'true', 70 70 useMockVectorDb: process.env.USE_MOCK_VECTOR_DB === 'true', ··· 198 198 return this.config.runtime; 199 199 } 200 200 201 - public shouldUsePersistence(): boolean { 202 - return this.config.runtime.usePersistence; 201 + public shouldUseMockPersistence(): boolean { 202 + return this.config.runtime.useMockPersistence; 203 203 } 204 204 205 205 public shouldUseMockRepos(): boolean { 206 - return !this.config.runtime.usePersistence; 206 + return this.config.runtime.useMockPersistence; 207 207 } 208 208 209 209 public shouldUseInMemoryEvents(): boolean { 210 - return !this.config.runtime.usePersistence; 210 + return this.config.runtime.useMockPersistence; 211 211 } 212 212 213 213 public shouldUseMockAuth(): boolean { ··· 225 225 // Convenience methods for common combinations 226 226 public isFullyMocked(): boolean { 227 227 const r = this.config.runtime; 228 - return !r.usePersistence && r.useMockAuth && r.useFakePublishers; 228 + return r.useMockPersistence && r.useMockAuth && r.useFakePublishers; 229 229 } 230 230 231 - public isPersistenceEnabled(): boolean { 232 - return this.config.runtime.usePersistence; 231 + public isMockPersistenceEnabled(): boolean { 232 + return this.config.runtime.useMockPersistence; 233 233 } 234 234 235 - private determinePersistenceFlag(): boolean { 235 + private determineMockPersistenceFlag(): boolean { 236 236 // New unified flag takes precedence 237 - if (process.env.USE_PERSISTENCE !== undefined) { 238 - return process.env.USE_PERSISTENCE === 'true'; 237 + if (process.env.USE_MOCK_PERSISTENCE !== undefined) { 238 + return process.env.USE_MOCK_PERSISTENCE === 'true'; 239 239 } 240 240 241 241 // Legacy support - if either old flag is false, persistence is disabled ··· 243 243 process.env.USE_MOCK_REPOS === 'true' || 244 244 process.env.USE_IN_MEMORY_EVENTS === 'true' 245 245 ) { 246 - return false; 246 + return true; 247 247 } 248 248 249 - // Default to true (use persistence) unless explicitly disabled 250 - return true; 249 + // Default to false (use mock persistence) unless explicitly enabled 250 + return false; 251 251 } 252 252 }
+2 -3
src/shared/infrastructure/http/factories/ServiceFactory.ts
··· 48 48 import { RedisFactory } from '../../redis/RedisFactory'; 49 49 import { IEventSubscriber } from 'src/shared/application/events/IEventSubscriber'; 50 50 import { FeedService } from '../../../../modules/feeds/domain/services/FeedService'; 51 - import { CardCollectionSaga } from '../../../../modules/feeds/application/sagas/CardCollectionSaga'; 52 51 import { ATProtoIdentityResolutionService } from '../../../../modules/atproto/infrastructure/services/ATProtoIdentityResolutionService'; 53 52 import { IIdentityResolutionService } from '../../../../modules/atproto/domain/services/IIdentityResolutionService'; 54 53 import { CookieService } from '../services/CookieService'; ··· 293 292 const baseProfileService = new BlueskyProfileService(atProtoAgentService); 294 293 295 294 let profileService: IProfileService; 296 - const usePersistence = configService.shouldUsePersistence(); 295 + const useMockPersistence = configService.shouldUseMockPersistence(); 297 296 298 297 // caching requires persistence 299 - if (!usePersistence) { 298 + if (useMockPersistence) { 300 299 profileService = baseProfileService; 301 300 } else { 302 301 // Create Redis connection for caching
+3 -2
src/shared/infrastructure/locking/LockServiceFactory.ts
··· 2 2 import { RedisLockService } from './RedisLockService'; 3 3 import { InMemoryLockService } from './InMemoryLockService'; 4 4 import { RedisFactory } from '../redis/RedisFactory'; 5 + import { configService } from '../config'; 5 6 6 7 export class LockServiceFactory { 7 8 static create(): ILockService { 8 - const useMockRepos = process.env.USE_MOCK_REPOS === 'true'; 9 - if (!useMockRepos) { 9 + const useMockPersistence = configService.shouldUseMockPersistence(); 10 + if (!useMockPersistence) { 10 11 try { 11 12 const redis = RedisFactory.createConnection({ 12 13 host: process.env.REDIS_HOST || 'localhost',
+2 -2
src/shared/infrastructure/processes/AppProcess.ts
··· 10 10 // Get configuration 11 11 const config = this.configService.get(); 12 12 13 - const useMockRepos = process.env.USE_MOCK_REPOS === 'true'; 14 - if (!useMockRepos) { 13 + const useMockPersistence = this.configService.shouldUseMockPersistence(); 14 + if (!useMockPersistence) { 15 15 // Create database connection with config 16 16 const db = DatabaseFactory.createConnection( 17 17 this.configService.getDatabaseConfig(),
+1 -1
src/webapp/lib/auth/dal.server.ts
··· 2 2 import { cookies } from 'next/headers'; 3 3 import { cache } from 'react'; 4 4 5 - const appUrl = process.env.APP_URL || 'http://127.0.0.1:4000'; 5 + const appUrl = process.env.NEXT_PUBLIC_APP_URL || 'http://127.0.0.1:4000'; 6 6 7 7 export const verifySessionOnServer = cache(async () => { 8 8 const cookieStore = await cookies();