diff --git a/packages/nocodb/src/lib/controllers/public/index.ts b/packages/nocodb/src/lib/controllers/public/index.ts deleted file mode 100644 index 8e1c237b36..0000000000 --- a/packages/nocodb/src/lib/controllers/public/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -import publicDataController from './publicDataApis'; -import publicDataExportController from './publicDataExportApis'; -import publicMetaController from './publicMetaApis'; - -export { - publicDataController, - publicDataExportController, - publicMetaController, -}; diff --git a/packages/nocodb/src/lib/controllers/public/publicDataApis.ts b/packages/nocodb/src/lib/controllers/public/publicDataApis.ts deleted file mode 100644 index 46a73a0f2a..0000000000 --- a/packages/nocodb/src/lib/controllers/public/publicDataApis.ts +++ /dev/null @@ -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; diff --git a/packages/nocodb/src/lib/controllers/public/publicMetaApis.ts b/packages/nocodb/src/lib/controllers/public/publicMetaApis.ts deleted file mode 100644 index 238e3223ae..0000000000 --- a/packages/nocodb/src/lib/controllers/public/publicMetaApis.ts +++ /dev/null @@ -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 { - 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;