Skip to content

Commit 2bb4d14

Browse files
committed
dev-demo: update kv adapters select in api.ts
AdminForth/1735/kv-adapters-and-storage-s3-com
1 parent 8093d7d commit 2bb4d14

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

dev-demo/api.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import TwoFactorsAuthPlugin from "../plugins/adminforth-two-factors-auth/index.j
55
import { levelDbAdapter, resourceAdapter, ramAdapter } from './utils.js';
66

77
const CURRENT_KV_ADAPTER = resourceAdapter;
8+
const CURRENT_COLLECTION = 'dev-demo';
89

910
const DASHBOARD_CAR_SOURCES = [
1011
{ resourceId: 'cars_sl', label: 'SQLite' },
@@ -196,7 +197,7 @@ export function initApi(app: Express, admin: IAdminForth) {
196197
async (_req: IAdminUserExpressRequest, res: Response) => {
197198
console.log('Received keyValue/list');
198199
const { prefix } = _req.body;
199-
const keys = await CURRENT_KV_ADAPTER.listByPrefix(prefix, 100, 'dev-demo');
200+
const keys = await CURRENT_KV_ADAPTER.listByPrefix(prefix, 100, CURRENT_COLLECTION);
200201
res.json({ keys });
201202
}
202203
)
@@ -206,7 +207,7 @@ export function initApi(app: Express, admin: IAdminForth) {
206207
async (_req: IAdminUserExpressRequest, res: Response) => {
207208
console.log('Received keyValue/set');
208209
const {key, value} = _req.body;
209-
await CURRENT_KV_ADAPTER.set(key, value, undefined, 'dev-demo');
210+
await CURRENT_KV_ADAPTER.set(key, value, undefined, CURRENT_COLLECTION);
210211
res.json({ ok: true });
211212
}
212213
)
@@ -216,7 +217,7 @@ export function initApi(app: Express, admin: IAdminForth) {
216217
async (_req: IAdminUserExpressRequest, res: Response) => {
217218
console.log('Received keyValue/get');
218219
const { key } = _req.body;
219-
const value = await CURRENT_KV_ADAPTER.get(key, 'dev-demo');
220+
const value = await CURRENT_KV_ADAPTER.get(key, CURRENT_COLLECTION);
220221
res.json({ key, value });
221222
}
222223
)
@@ -226,7 +227,7 @@ export function initApi(app: Express, admin: IAdminForth) {
226227
async (_req: IAdminUserExpressRequest, res: Response) => {
227228
console.log('Received keyValue/delete');
228229
const { key } = _req.body;
229-
await CURRENT_KV_ADAPTER.delete(key, 'dev-demo');
230+
await CURRENT_KV_ADAPTER.delete(key, CURRENT_COLLECTION);
230231
res.json({ ok: true });
231232
}
232233
)

dev-demo/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ export const ramAdapter = new RAMKeyValueAdapter();
1818

1919
// Uncomment if you have running Redis instance
2020
// export const redisAdapter = new RedisKeyValueAdapter({
21-
// redisUrl: 'redis://localhost:6379',
21+
// redisUrl: 'redis://localhost:6379/0',
2222
// })

0 commit comments

Comments
 (0)