UNPKG

@opengis/fastify-table

Version:

core-plugins

22 lines (17 loc) 897 B
import { pgClients, getTemplatePath } from '../../../../utils.js'; export default async function getInterfaces({ pg = pgClients.client }) { const { rows = [] } = await pg.query('select route_id, alias, table_name, title, enabled from admin.routes'); const interfaces = rows .filter((el, idx, arr) => el.table_name && arr.findIndex(item => item.route_id === el.route_id) === idx) .filter(el => pg.pk?.[el.table_name || '']) .filter(el => !['log.', 'admin.', 'setting.'].find(item => el.table_name.startsWith(item))) .map(el => ({ title: el.title, alias: el.alias, table: el.table_name, route: el.route_id, enabled: el.enabled, })); const all = getTemplatePath('table').map(el => el[0]); return interfaces.filter(el => el.alias && all.includes(el.alias)); }