From 6d7754fe8032d95708d4592fd757700b3e78f49f Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Fri, 10 Mar 2023 11:58:25 +0800 Subject: [PATCH] refactor(nocodb): list response --- .../nocodb/src/lib/controllers/filter.ctl.ts | 4 ++-- packages/nocodb/src/lib/controllers/hook.ctl.ts | 15 +++++++-------- packages/nocodb/src/lib/controllers/sort.ctl.ts | 16 ++++++++-------- packages/nocodb/src/lib/controllers/view.ctl.ts | 15 ++++++++------- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/packages/nocodb/src/lib/controllers/filter.ctl.ts b/packages/nocodb/src/lib/controllers/filter.ctl.ts index 5c321e950b..bef2b240e1 100644 --- a/packages/nocodb/src/lib/controllers/filter.ctl.ts +++ b/packages/nocodb/src/lib/controllers/filter.ctl.ts @@ -3,14 +3,14 @@ import ncMetaAclMw from '../meta/helpers/ncMetaAclMw'; import { metaApiMetrics } from '../meta/helpers/apiMetrics'; import { PagedResponseImpl } from '../meta/helpers/PagedResponse'; import { filterService } from '../services'; -import type { FilterReqType } from 'nocodb-sdk'; +import type { FilterListType, FilterReqType } from 'nocodb-sdk'; import type { Request, Response } from 'express'; export async function filterGet(req: Request, res: Response) { res.json(await filterService.filterGet({ filterId: req.params.filterId })); } -export async function filterList(req: Request, res: Response) { +export async function filterList(req: Request, res: Response) { res.json( new PagedResponseImpl( await filterService.filterList({ diff --git a/packages/nocodb/src/lib/controllers/hook.ctl.ts b/packages/nocodb/src/lib/controllers/hook.ctl.ts index 65a4a66e45..64073aa114 100644 --- a/packages/nocodb/src/lib/controllers/hook.ctl.ts +++ b/packages/nocodb/src/lib/controllers/hook.ctl.ts @@ -54,14 +54,13 @@ export async function hookTest(req: Request, res: Response) { } export async function tableSampleData(req: Request, res: Response) { - res // todo: pagination - .json( - await hookService.tableSampleData({ - tableId: req.params.tableId, - // todo: replace any with type - operation: req.params.operation as any, - }) - ); + res.json( + await hookService.tableSampleData({ + tableId: req.params.tableId, + // todo: replace any with type + operation: req.params.operation as any, + }) + ); } const router = Router({ mergeParams: true }); diff --git a/packages/nocodb/src/lib/controllers/sort.ctl.ts b/packages/nocodb/src/lib/controllers/sort.ctl.ts index e39f727d78..20a5ed7f2b 100644 --- a/packages/nocodb/src/lib/controllers/sort.ctl.ts +++ b/packages/nocodb/src/lib/controllers/sort.ctl.ts @@ -6,20 +6,19 @@ import { sortService } from '../services'; import type { SortListType, SortReqType } from 'nocodb-sdk'; import type { Request, Response } from 'express'; -// @ts-ignore export async function sortList( req: Request, res: Response ) { - const sortList = await sortService.sortList({ - viewId: req.params.viewId, - }); - res.json({ - sorts: new PagedResponseImpl(sortList), - }); + res.json( + new PagedResponseImpl( + await sortService.sortList({ + viewId: req.params.viewId, + }) + ) + ); } -// @ts-ignore export async function sortCreate(req: Request, res) { const sort = await sortService.sortCreate({ sort: req.body, @@ -42,6 +41,7 @@ export async function sortDelete(req: Request, res: Response) { }); res.json(sort); } + export async function sortGet(req: Request, res: Response) { const sort = await sortService.sortGet({ sortId: req.params.sortId, diff --git a/packages/nocodb/src/lib/controllers/view.ctl.ts b/packages/nocodb/src/lib/controllers/view.ctl.ts index 7c1f574843..646074ea35 100644 --- a/packages/nocodb/src/lib/controllers/view.ctl.ts +++ b/packages/nocodb/src/lib/controllers/view.ctl.ts @@ -9,14 +9,15 @@ import type { Request, Response } from 'express'; // @ts-ignore export async function viewGet(req: Request, res: Response) {} -// @ts-ignore export async function viewList(req: Request, res: Response) { - const filteredViewList = await viewService.viewList({ - tableId: req.params.tableId, - user: (req as any).session?.passport?.user, - }); - - res.json(new PagedResponseImpl(filteredViewList)); + res.json( + new PagedResponseImpl( + await viewService.viewList({ + tableId: req.params.tableId, + user: (req as any).session?.passport?.user, + }) + ) + ); } // @ts-ignore