storeMiddleware: pass through admin UserStore

This commit is contained in:
Alex Gleason 2024-04-30 13:27:30 -05:00
parent 1ed700d7f9
commit d22c606960
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 4 additions and 2 deletions

View File

@ -1,16 +1,18 @@
import { AppMiddleware } from '@/app.ts';
import { Conf } from '@/config.ts';
import { UserStore } from '@/storages/UserStore.ts';
import { eventsDB } from '@/storages.ts';
/** Store middleware. */
const storeMiddleware: AppMiddleware = async (c, next) => {
const pubkey = c.get('pubkey');
const adminStore = new UserStore(Conf.pubkey, eventsDB);
if (pubkey) {
const store = new UserStore(pubkey, eventsDB);
const store = new UserStore(pubkey, adminStore);
c.set('store', store);
} else {
c.set('store', eventsDB);
c.set('store', adminStore);
}
await next();
};