Files
homebrewery-oidc/server/storage/mongo/index.js
T
dev-bot BotandClaude Sonnet 5.5 448c67912f
CI / App (npm ci + Build, ESLint, Stylelint, Jest) (push) Successful in 3m25s
CI / Storage (mongo) (push) Successful in 1m24s
CI / Storage (postgres) (push) Successful in 1m13s
Image / Image bauen und pushen (push) Successful in 1m3s
feat(git): Git-Backend über HTTPS + PAT (ADR 0003, FLW-86) (#19)
Repositories gitConnections/brewGitLinks (Mongo/PG), Krypto, SSRF-Policy mit net.BlockList, git-Client ohne Arbeitskopie, Sync/Konflikte, /api/git/*, Client (Verbindungen, Git-Status, Konfliktdialog), Autosave 60 s für Git-Brews (F6), Tests und Doku.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Dev (Paperclip) <dev-bot@noreply.git.morlana.online>
2026-11-25 21:16:42 +00:00

48 lines
1.4 KiB
JavaScript

import mongoose from 'mongoose';
import DB from '../../db.js';
import { createUserRepository } from './users.js';
import { createBrewRepository } from './brews.js';
import { createNotificationRepository } from './notifications.js';
import { createGitConnectionRepository, createBrewGitLinkRepository } from './git.js';
// Mongo-Implementierung der Storage-Schicht (ADR 0002). Ruft die Statics und Methoden der
// unveränderten Upstream-Modelle (homebrew.model.js, notifications.model.js) auf.
export const createMongoStorage = (config)=>{
const brews = createBrewRepository();
const notifications = createNotificationRepository();
let users;
let gitConnections;
let brewGitLinks;
return {
driver : 'mongo',
brews,
notifications,
async connect() {
await DB.connect(config);
if(!config.get('local_environments').includes(config.get('node_env'))) {
await this.users.Model.syncIndexes(); // nur Fork-Modelle, nie Homebrew
await this.gitConnections.Model.syncIndexes();
await this.brewGitLinks.Model.syncIndexes();
}
},
async disconnect() {
await DB.disconnect();
},
isReady() {
return mongoose.connection.readyState === 1;
},
get users() {
users ??= createUserRepository();
return users;
},
get gitConnections() {
gitConnections ??= createGitConnectionRepository();
return gitConnections;
},
get brewGitLinks() {
brewGitLinks ??= createBrewGitLinkRepository();
return brewGitLinks;
}
};
};