Browse Source

refactor: remove public folder

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/5239/head
Pranav C 2 years ago
parent
commit
4bb26cdf7e
  1. 9
      packages/nocodb/src/lib/controllers/public/index.ts
  2. 105
      packages/nocodb/src/lib/controllers/public/publicDataApis.ts
  3. 31
      packages/nocodb/src/lib/controllers/public/publicMetaApis.ts

9
packages/nocodb/src/lib/controllers/public/index.ts

@ -1,9 +0,0 @@
import publicDataController from './publicDataApis';
import publicDataExportController from './publicDataExportApis';
import publicMetaController from './publicMetaApis';
export {
publicDataController,
publicDataExportController,
publicMetaController,
};

105
packages/nocodb/src/lib/controllers/public/publicDataApis.ts

@ -1,105 +0,0 @@
import { Request, Response, Router } from 'express';
import multer from 'multer';
import { NC_ATTACHMENT_FIELD_SIZE } from '../../constants';
import catchError from '../../meta/helpers/catchError';
import { publicDataService } from '../../services';
export async function dataList(req: Request, res: Response) {
const pagedResponse = await publicDataService.dataList({
query: req.query,
password: req.headers?.['xc-password'] as string,
sharedViewUuid: req.params.sharedViewUuid,
});
res.json({ data: pagedResponse });
}
// todo: Handle the error case where view doesnt belong to model
async function groupedDataList(req: Request, res: Response) {
const groupedData = await publicDataService.groupedDataList({
query: req.query,
password: req.headers?.['xc-password'] as string,
sharedViewUuid: req.params.sharedViewUuid,
groupColumnId: req.params.columnId,
});
res.json(groupedData);
}
async function dataInsert(req: Request & { files: any[] }, res: Response) {
const insertResult = await publicDataService.dataInsert({
sharedViewUuid: req.params.sharedViewUuid,
password: req.headers?.['xc-password'] as string,
body: req.body?.data,
siteUrl: (req as any).ncSiteUrl,
files: req.files,
});
res.json(insertResult);
}
async function relDataList(req, res) {
const pagedResponse = await publicDataService.relDataList({
query: req.query,
password: req.headers?.['xc-password'] as string,
sharedViewUuid: req.params.sharedViewUuid,
columnId: req.params.columnId,
});
res.json(pagedResponse);
}
export async function publicMmList(req: Request, res: Response) {
const paginatedResponse = await publicDataService.publicMmList({
query: req.query,
password: req.headers?.['xc-password'] as string,
sharedViewUuid: req.params.sharedViewUuid,
columnId: req.params.columnId,
rowId: req.params.rowId,
});
res.json(paginatedResponse);
}
export async function publicHmList(req: Request, res: Response) {
const paginatedResponse = await publicDataService.publicHmList({
query: req.query,
password: req.headers?.['xc-password'] as string,
sharedViewUuid: req.params.sharedViewUuid,
columnId: req.params.columnId,
rowId: req.params.rowId,
});
res.json(paginatedResponse);
}
const router = Router({ mergeParams: true });
router.get(
'/api/v1/db/public/shared-view/:sharedViewUuid/rows',
catchError(dataList)
);
router.get(
'/api/v1/db/public/shared-view/:sharedViewUuid/group/:columnId',
catchError(groupedDataList)
);
router.get(
'/api/v1/db/public/shared-view/:sharedViewUuid/nested/:columnId',
catchError(relDataList)
);
router.post(
'/api/v1/db/public/shared-view/:sharedViewUuid/rows',
multer({
storage: multer.diskStorage({}),
limits: {
fieldSize: NC_ATTACHMENT_FIELD_SIZE,
},
}).any(),
catchError(dataInsert)
);
router.get(
'/api/v1/db/public/shared-view/:sharedViewUuid/rows/:rowId/mm/:colId',
catchError(publicMmList)
);
router.get(
'/api/v1/db/public/shared-view/:sharedViewUuid/rows/:rowId/hm/:colId',
catchError(publicHmList)
);
export default router;

31
packages/nocodb/src/lib/controllers/public/publicMetaApis.ts

@ -1,31 +0,0 @@
import { Request, Response, Router } from 'express';
import catchError from '../../meta/helpers/catchError';
import { publicMetaService } from '../../services';
export async function viewMetaGet(req: Request, res: Response) {
res.json(
await publicMetaService.viewMetaGet({
password: req.headers?.['xc-password'] as string,
sharedViewUuid: req.params.sharedViewUuid,
})
);
}
async function publicSharedBaseGet(req, res): Promise<any> {
res.json(
await publicMetaService.publicSharedBaseGet({
sharedBaseUuid: req.params.sharedBaseUuid,
})
);
}
const router = Router({ mergeParams: true });
router.get(
'/api/v1/db/public/shared-view/:sharedViewUuid/meta',
catchError(viewMetaGet)
);
router.get(
'/api/v1/db/public/shared-base/:sharedBaseUuid/meta',
catchError(publicSharedBaseGet)
);
export default router;
Loading…
Cancel
Save