livrare lot 2
This commit is contained in:
commit
8ecc78e729
763 changed files with 164593 additions and 0 deletions
|
|
@ -0,0 +1,37 @@
|
|||
/**
|
||||
* Shared lazy-init singletons + multer config used by route modules under
|
||||
* src/api/. Extracted from the original routes.ts so techniques/media/domain
|
||||
* sub-routers can reuse them without each duplicating connection setup.
|
||||
*/
|
||||
import multer from 'multer';
|
||||
import { lazyRedis } from '../shared/redis/connection';
|
||||
import { MediaService } from '../shared/media/media-service';
|
||||
import { PersistService, PgSessionAdapter, getPgPool } from '../shared/persistence';
|
||||
import { SessionStore } from '../shared/redis/session-store';
|
||||
|
||||
/** Per-module Redis singleton (label visible in connection metadata). */
|
||||
export const getRedis = lazyRedis('routes');
|
||||
|
||||
/** Multer upload — memory storage, 50MB max. Used by /media/upload + /techniques/analyze-media. */
|
||||
export const upload = multer({
|
||||
storage: multer.memoryStorage(),
|
||||
limits: { fileSize: 50 * 1024 * 1024 },
|
||||
});
|
||||
|
||||
let _mediaService: MediaService | null = null;
|
||||
export function getMediaService(): MediaService {
|
||||
if (!_mediaService) _mediaService = new MediaService();
|
||||
return _mediaService;
|
||||
}
|
||||
|
||||
let _persistService: PersistService | null = null;
|
||||
export function getPersistServiceInstance(): PersistService {
|
||||
if (!_persistService) {
|
||||
const r = getRedis();
|
||||
_persistService = new PersistService(
|
||||
new SessionStore(r),
|
||||
new PgSessionAdapter(getPgPool()),
|
||||
);
|
||||
}
|
||||
return _persistService;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue