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. 15
      packages/nocodb/src/lib/controllers/hook.ctl.ts
  3. 16
      packages/nocodb/src/lib/controllers/sort.ctl.ts
  4. 15
      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 { 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<FilterListType>) {
res.json(
new PagedResponseImpl(
await filterService.filterList({

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

@ -54,14 +54,13 @@ export async function hookTest(req: Request<any, any>, 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 });

16
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<any, any, any>,
res: Response<SortListType>
) {
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<any, any, SortReqType>, 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,

15
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<any, any, any>, 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

Loading…
Cancel
Save