mirror of
https://github.com/aljazceru/ditto.git
synced 2026-01-05 06:34:24 +01:00
Refactor Storages to get lazy-loaded only when they are used
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
import { AppMiddleware } from '@/app.ts';
|
||||
import { UserStore } from '@/storages/UserStore.ts';
|
||||
import { getAdminStore } from '@/storages/adminStore.ts';
|
||||
import { Storages } from '@/storages.ts';
|
||||
|
||||
/** Store middleware. */
|
||||
const storeMiddleware: AppMiddleware = async (c, next) => {
|
||||
const pubkey = c.get('pubkey');
|
||||
const adminStore = getAdminStore();
|
||||
|
||||
if (pubkey) {
|
||||
const store = new UserStore(pubkey, adminStore);
|
||||
const store = new UserStore(pubkey, Storages.admin);
|
||||
c.set('store', store);
|
||||
} else {
|
||||
c.set('store', adminStore);
|
||||
c.set('store', Storages.admin);
|
||||
}
|
||||
await next();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user