refactor(storage): Upstream-Aufrufstellen auf getStorage().brews/notifications umgestellt (ADR 0002 §4)

Mechanischer Ersatz der Datenzugriffe, Wartungsjobs unter Postgres mit 501. Specs minimal angepasst (_id -> id, Mocks).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
dev-bot BotandClaude Sonnet 5.5 committed 2026-11-25 10:16:55 +00:00
1 parent a55c403527
commit 23d9b83567
8 files changed
+119 -243

No files matched your search

+4 -13
View File
@@ -25,7 +25,6 @@ import pageRoutes from './page-routes.js';
import serveCompressedStaticAssets from './static-assets.mv.js';
import asyncHandler from 'express-async-handler';
import { model as HomebrewModel } from './homebrew.model.js';
//==== Middleware Imports ====//
import contentNegotiation from './middleware/content-negotiation.js';
@@ -48,6 +47,7 @@ export default async function createApp(vite) {
const isLocalEnvironment = config.get('local_environments').includes(nodeEnv);
const sanitizeBrew = (brew, accessType)=>{
brew.id = undefined;
brew._id = undefined;
brew.__v = undefined;
if(accessType !== 'edit' && accessType !== 'shareAuthor') {
@@ -120,7 +120,7 @@ export default async function createApp(vite) {
app.use(accountMiddleware(authConfig));
app.use(createAuthRouter(authConfig, {
getUsers : ()=>getStorage().users,
brewAuthorExists : async (name)=>!!(await HomebrewModel.exists({ authors: name }))
brewAuthorExists : (name)=>getStorage().brews.existsAuthor(name)
}));
app.use(homebrewApi);
@@ -140,7 +140,6 @@ export default async function createApp(vite) {
app.use(pageRoutes({
defaultMetaTags,
HomebrewModel,
sanitizeBrew,
}));
@@ -188,16 +187,8 @@ export default async function createApp(vite) {
if(!ownAccount)
return res.status(403).json({ error: 'Must be logged in to change your username' });
try {
const brews = await HomebrewModel.getByUser(username, true, ['authors']);
const renamePromises = brews.map(async (brew)=>{
const updatedAuthors = brew.authors.map((author)=>author === username ? newUsername : author
);
return HomebrewModel.updateOne(
{ _id: brew._id },
{ $set: { authors: updatedAuthors } }
);
});
await Promise.all(renamePromises);
// [fork] ADR-0002
await getStorage().brews.renameAuthor(username, newUsername);
return res.json({ success: true, message: `Brews for ${username} renamed to ${newUsername}.` });
} catch (error) {