refactor(store middleware): get adminStore through function

This commit is contained in:
P. Reis 2024-04-30 21:21:32 -03:00
parent ba6d33c115
commit e8e45360d3
1 changed files with 2 additions and 4 deletions

View File

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