p3x-redis-ui-server
Version:
🏍️ P3X Redis UI server — Socket.IO backend for the dual Angular + React frontend with AI queries, 54 languages, and auto data decompression
2 lines (1 loc) • 644 B
JavaScript
import*as e from"../../shared.mjs";export default async r=>{const{socket:s,payload:o}=r;try{e.ensureReadonlyConnection({socket:s});const t=s.p3xrs.ioredis,{name:n,prefix:a,schema:c}=o;if(!n||!c||!Array.isArray(c)||0===c.length)return void s.emit(r.responseEvent,{status:"error",error:"Index name and schema are required"});const i=[n,"ON","HASH"];a&&i.push("PREFIX","1",a),i.push("SCHEMA");for(const e of c)i.push(e.name,e.type),e.sortable&&i.push("SORTABLE"),e.noindex&&i.push("NOINDEX");await t.call("FT.CREATE",...i),s.emit(r.responseEvent,{status:"ok"})}catch(e){console.error(e),s.emit(r.responseEvent,{status:"error",error:e.message})}};