Browse Source

refactor(nocodb): apply PagedResponseImpl

pull/5269/head
Wing-Kam Wong 2 years ago
parent
commit
534273d642
  1. 7
      packages/nocodb/src/lib/controllers/apiToken.ctl.ts
  2. 4
      packages/nocodb/src/lib/controllers/audit.ctl.ts
  3. 6
      packages/nocodb/src/lib/controllers/filter.ctl.ts
  4. 11
      packages/nocodb/src/lib/controllers/hookFilter.ctl.ts
  5. 10
      packages/nocodb/src/lib/controllers/orgUser.ctl.ts
  6. 2
      packages/nocodb/src/lib/controllers/view.ctl.ts
  7. 7
      packages/nocodb/src/lib/controllers/viewColumn.ctl.ts

7
packages/nocodb/src/lib/controllers/apiToken.ctl.ts

@ -1,11 +1,16 @@
import { Router } from 'express';
import ncMetaAclMw from '../meta/helpers/ncMetaAclMw';
import { metaApiMetrics } from '../meta/helpers/apiMetrics';
import { PagedResponseImpl } from '../meta/helpers/PagedResponse';
import { apiTokenService } from '../services';
import type { Request, Response } from 'express';
export async function apiTokenList(req: Request, res: Response) {
res.json(await apiTokenService.apiTokenList({ userId: req['user'].id }));
res.json(
new PagedResponseImpl(
await apiTokenService.apiTokenList({ userId: req['user'].id })
)
);
}
export async function apiTokenCreate(req: Request, res: Response) {

4
packages/nocodb/src/lib/controllers/audit.ctl.ts

@ -25,7 +25,9 @@ export async function auditRowUpdate(req: Request<any, any>, res) {
}
export async function commentList(req: Request<any, any, any>, res) {
res.json(await auditService.commentList({ query: req.query }));
res.json(
new PagedResponseImpl(await auditService.commentList({ query: req.query }))
);
}
export async function auditList(req: Request, res: Response) {

6
packages/nocodb/src/lib/controllers/filter.ctl.ts

@ -1,25 +1,25 @@
import { Router } from 'express';
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 { Request, Response } from 'express';
// @ts-ignore
export async function filterGet(req: Request, res: Response) {
res.json(await filterService.filterGet({ filterId: req.params.filterId }));
}
// @ts-ignore
export async function filterList(req: Request, res: Response) {
res.json(
new PagedResponseImpl(
await filterService.filterList({
viewId: req.params.viewId,
})
)
);
}
// @ts-ignore
export async function filterChildrenRead(req: Request, res: Response) {
const filter = await filterService.filterChildrenList({
filterId: req.params.filterParentId,

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

@ -3,6 +3,7 @@ import { T } from 'nc-help';
import ncMetaAclMw from '../meta/helpers/ncMetaAclMw';
import { metaApiMetrics } from '../meta/helpers/apiMetrics';
import { hookFilterService } from '../services';
import { PagedResponseImpl } from '../meta/helpers/PagedResponse';
import type { Request, Response } from 'express';
export async function filterGet(req: Request, res: Response) {
@ -14,11 +15,13 @@ export async function filterGet(req: Request, res: Response) {
}
export async function filterList(req: Request, res: Response) {
const filter = await hookFilterService.filterList({
res.json(
new PagedResponseImpl(
await hookFilterService.filterList({
hookId: req.params.hookId,
});
res.json(filter);
})
)
);
}
export async function filterChildrenRead(req: Request, res: Response) {

10
packages/nocodb/src/lib/controllers/orgUser.ctl.ts

@ -2,13 +2,21 @@ import { Router } from 'express';
import { OrgUserRoles } from 'nocodb-sdk';
import { metaApiMetrics } from '../meta/helpers/apiMetrics';
import ncMetaAclMw from '../meta/helpers/ncMetaAclMw';
import { PagedResponseImpl } from '../meta/helpers/PagedResponse';
import { orgUserService } from '../services';
import { User } from '../models';
async function userList(req, res) {
res.json(
new PagedResponseImpl(
await orgUserService.userList({
query: req.query,
})
}),
{
...req.query,
count: await User.count(req.query),
}
)
);
}

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

@ -78,9 +78,11 @@ async function hideAllColumns(req: Request<any, any>, res) {
async function shareViewList(req: Request<any, any>, res) {
res.json(
new PagedResponseImpl(
await viewService.shareViewList({
tableId: req.params.tableId,
})
)
);
}

7
packages/nocodb/src/lib/controllers/viewColumn.ctl.ts

@ -2,10 +2,15 @@ import { Router } from 'express';
import ncMetaAclMw from '../meta/helpers/ncMetaAclMw';
import { metaApiMetrics } from '../meta/helpers/apiMetrics';
import { viewColumnService } from '../services';
import { PagedResponseImpl } from '../meta/helpers/PagedResponse';
import type { Request, Response } from 'express';
export async function columnList(req: Request, res: Response) {
res.json(await viewColumnService.columnList({ viewId: req.params.viewId }));
res.json(
new PagedResponseImpl(
await viewColumnService.columnList({ viewId: req.params.viewId })
)
);
}
export async function columnAdd(req: Request, res: Response) {

Loading…
Cancel
Save