Browse Source

refactor(nocodb): list response

pull/5269/head
Wing-Kam Wong 2 years ago
parent
commit
6d7754fe80
  1. 4
      packages/nocodb/src/lib/controllers/filter.ctl.ts
  2. 3
      packages/nocodb/src/lib/controllers/hook.ctl.ts
  3. 14
      packages/nocodb/src/lib/controllers/sort.ctl.ts
  4. 11
      packages/nocodb/src/lib/controllers/view.ctl.ts

4
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 { metaApiMetrics } from '../meta/helpers/apiMetrics';
import { PagedResponseImpl } from '../meta/helpers/PagedResponse'; import { PagedResponseImpl } from '../meta/helpers/PagedResponse';
import { filterService } from '../services'; import { filterService } from '../services';
import type { FilterReqType } from 'nocodb-sdk'; import type { FilterListType, FilterReqType } from 'nocodb-sdk';
import type { Request, Response } from 'express'; import type { Request, Response } from 'express';
export async function filterGet(req: Request, res: Response) { export async function filterGet(req: Request, res: Response) {
res.json(await filterService.filterGet({ filterId: req.params.filterId })); 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<FilterListType>) {
res.json( res.json(
new PagedResponseImpl( new PagedResponseImpl(
await filterService.filterList({ await filterService.filterList({

3
packages/nocodb/src/lib/controllers/hook.ctl.ts

@ -54,8 +54,7 @@ export async function hookTest(req: Request<any, any>, res: Response) {
} }
export async function tableSampleData(req: Request, res: Response) { export async function tableSampleData(req: Request, res: Response) {
res // todo: pagination res.json(
.json(
await hookService.tableSampleData({ await hookService.tableSampleData({
tableId: req.params.tableId, tableId: req.params.tableId,
// todo: replace any with type // todo: replace any with type

14
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 { SortListType, SortReqType } from 'nocodb-sdk';
import type { Request, Response } from 'express'; import type { Request, Response } from 'express';
// @ts-ignore
export async function sortList( export async function sortList(
req: Request<any, any, any>, req: Request<any, any, any>,
res: Response<SortListType> res: Response<SortListType>
) { ) {
const sortList = await sortService.sortList({ res.json(
new PagedResponseImpl(
await sortService.sortList({
viewId: req.params.viewId, viewId: req.params.viewId,
}); })
res.json({ )
sorts: new PagedResponseImpl(sortList), );
});
} }
// @ts-ignore
export async function sortCreate(req: Request<any, any, SortReqType>, res) { export async function sortCreate(req: Request<any, any, SortReqType>, res) {
const sort = await sortService.sortCreate({ const sort = await sortService.sortCreate({
sort: req.body, sort: req.body,
@ -42,6 +41,7 @@ export async function sortDelete(req: Request, res: Response) {
}); });
res.json(sort); res.json(sort);
} }
export async function sortGet(req: Request, res: Response) { export async function sortGet(req: Request, res: Response) {
const sort = await sortService.sortGet({ const sort = await sortService.sortGet({
sortId: req.params.sortId, sortId: req.params.sortId,

11
packages/nocodb/src/lib/controllers/view.ctl.ts

@ -9,14 +9,15 @@ import type { Request, Response } from 'express';
// @ts-ignore // @ts-ignore
export async function viewGet(req: Request, res: Response) {} export async function viewGet(req: Request, res: Response) {}
// @ts-ignore
export async function viewList(req: Request<any, any, any>, res: Response) { export async function viewList(req: Request<any, any, any>, res: Response) {
const filteredViewList = await viewService.viewList({ res.json(
new PagedResponseImpl(
await viewService.viewList({
tableId: req.params.tableId, tableId: req.params.tableId,
user: (req as any).session?.passport?.user, user: (req as any).session?.passport?.user,
}); })
)
res.json(new PagedResponseImpl(filteredViewList)); );
} }
// @ts-ignore // @ts-ignore

Loading…
Cancel
Save