Browse Source

refactor: public and attachment apis

pull/6644/head
Pranav C 1 year ago
parent
commit
ae41241f70
  1. 4
      packages/nocodb/src/controllers/attachments-secure.controller.ts
  2. 4
      packages/nocodb/src/controllers/attachments.controller.ts
  3. 20
      packages/nocodb/src/controllers/auth/auth.controller.ts
  4. 4
      packages/nocodb/src/controllers/public-datas-export.controller.ts
  5. 14
      packages/nocodb/src/controllers/public-datas.controller.ts
  6. 4
      packages/nocodb/src/controllers/public-metas.controller.ts
  7. 42
      packages/nocodb/src/schema/swagger.json

4
packages/nocodb/src/controllers/attachments-secure.controller.ts

@ -26,7 +26,7 @@ export class AttachmentsSecureController {
constructor(private readonly attachmentsService: AttachmentsService) {}
@UseGuards(MetaApiLimiterGuard, GlobalGuard)
@Post(['/api/v1/db/storage/upload', '/api/v1/storage/upload'])
@Post(['/api/v1/db/storage/upload', '/api/v2/storage/upload'])
@HttpCode(200)
@UseInterceptors(UploadAllowedInterceptor, AnyFilesInterceptor())
async upload(@UploadedFiles() files: Array<any>, @Request() req) {
@ -40,7 +40,7 @@ export class AttachmentsSecureController {
return attachments;
}
@Post(['/api/v1/db/storage/upload-by-url', '/api/v1/storage/upload-by-url'])
@Post(['/api/v1/db/storage/upload-by-url', '/api/v2/storage/upload-by-url'])
@HttpCode(200)
@UseInterceptors(UploadAllowedInterceptor)
@UseGuards(MetaApiLimiterGuard, GlobalGuard)

4
packages/nocodb/src/controllers/attachments.controller.ts

@ -25,7 +25,7 @@ export class AttachmentsController {
constructor(private readonly attachmentsService: AttachmentsService) {}
@UseGuards(MetaApiLimiterGuard, GlobalGuard)
@Post(['/api/v1/db/storage/upload', '/api/v1/storage/upload'])
@Post(['/api/v1/db/storage/upload', '/api/v2/storage/upload'])
@HttpCode(200)
@UseInterceptors(UploadAllowedInterceptor, AnyFilesInterceptor())
async upload(
@ -41,7 +41,7 @@ export class AttachmentsController {
return attachments;
}
@Post(['/api/v1/db/storage/upload-by-url', '/api/v1/storage/upload-by-url'])
@Post(['/api/v1/db/storage/upload-by-url', '/api/v2/storage/upload-by-url'])
@HttpCode(200)
@UseInterceptors(UploadAllowedInterceptor)
@UseGuards(MetaApiLimiterGuard, GlobalGuard)

20
packages/nocodb/src/controllers/auth/auth.controller.ts

@ -37,7 +37,7 @@ export class AuthController {
@Post([
'/auth/user/signup',
'/api/v1/db/auth/user/signup',
'/api/v1/auth/user/signup',
'/api/v2/auth/user/signup',
])
@UseGuards(PublicApiLimiterGuard)
@HttpCode(200)
@ -57,7 +57,7 @@ export class AuthController {
@Post([
'/auth/token/refresh',
'/api/v1/db/auth/token/refresh',
'/api/v1/auth/token/refresh',
'/api/v2/auth/token/refresh',
])
@UseGuards(PublicApiLimiterGuard)
@HttpCode(200)
@ -74,7 +74,7 @@ export class AuthController {
@Post([
'/auth/user/signin',
'/api/v1/db/auth/user/signin',
'/api/v1/auth/user/signin',
'/api/v2/auth/user/signin',
])
@UseGuards(PublicApiLimiterGuard, AuthGuard('local'))
@HttpCode(200)
@ -87,7 +87,7 @@ export class AuthController {
}
@UseGuards(GlobalGuard)
@Post('/api/v1/auth/user/signout')
@Post('/api/v2/auth/user/signout')
@HttpCode(200)
async signOut(@Request() req, @Response() res): Promise<any> {
if (!(req as any).isAuthenticated()) {
@ -115,7 +115,7 @@ export class AuthController {
// google strategy will take care the request
}
@Get(['/auth/user/me', '/api/v1/db/auth/user/me', '/api/v1/auth/user/me'])
@Get(['/auth/user/me', '/api/v1/db/auth/user/me', '/api/v2/auth/user/me'])
@UseGuards(MetaApiLimiterGuard, GlobalGuard)
async me(@Request() req) {
const user = {
@ -130,7 +130,7 @@ export class AuthController {
@Post([
'/user/password/change',
'/api/v1/db/auth/password/change',
'/api/v1/auth/password/change',
'/api/v2/auth/password/change',
])
@UseGuards(MetaApiLimiterGuard, GlobalGuard)
@Acl('passwordChange', {
@ -154,7 +154,7 @@ export class AuthController {
@Post([
'/auth/password/forgot',
'/api/v1/db/auth/password/forgot',
'/api/v1/auth/password/forgot',
'/api/v2/auth/password/forgot',
])
@UseGuards(PublicApiLimiterGuard)
@HttpCode(200)
@ -171,7 +171,7 @@ export class AuthController {
@Post([
'/auth/token/validate/:tokenId',
'/api/v1/db/auth/token/validate/:tokenId',
'/api/v1/auth/token/validate/:tokenId',
'/api/v2/auth/token/validate/:tokenId',
])
@UseGuards(PublicApiLimiterGuard)
@HttpCode(200)
@ -185,7 +185,7 @@ export class AuthController {
@Post([
'/auth/password/reset/:tokenId',
'/api/v1/db/auth/password/reset/:tokenId',
'/api/v1/auth/password/reset/:tokenId',
'/api/v2/auth/password/reset/:tokenId',
])
@UseGuards(PublicApiLimiterGuard)
@HttpCode(200)
@ -205,7 +205,7 @@ export class AuthController {
@Post([
'/api/v1/db/auth/email/validate/:tokenId',
'/api/v1/auth/email/validate/:tokenId',
'/api/v2/auth/email/validate/:tokenId',
])
@UseGuards(PublicApiLimiterGuard)
@HttpCode(200)

4
packages/nocodb/src/controllers/public-datas-export.controller.ts

@ -27,7 +27,7 @@ export class PublicDatasExportController {
@Get([
'/api/v1/db/public/shared-view/:publicDataUuid/rows/export/excel',
'/api/v1/public/shared-view/:publicDataUuid/rows/export/excel',
'/api/v2/public/shared-view/:publicDataUuid/rows/export/excel',
])
async exportExcel(
@Request() req,
@ -82,7 +82,7 @@ export class PublicDatasExportController {
@Get([
'/api/v1/db/public/shared-view/:publicDataUuid/rows/export/csv',
'/api/v1/public/shared-view/:publicDataUuid/rows/export/csv',
'/api/v2/public/shared-view/:publicDataUuid/rows/export/csv',
])
async exportCsv(@Request() req, @Response() res) {
const view = await View.getByUUID(req.params.publicDataUuid);

14
packages/nocodb/src/controllers/public-datas.controller.ts

@ -19,7 +19,7 @@ export class PublicDatasController {
@Get([
'/api/v1/db/public/shared-view/:sharedViewUuid/rows',
'/api/v1/public/shared-view/:sharedViewUuid/rows',
'/api/v2/public/shared-view/:sharedViewUuid/rows',
])
async dataList(
@Request() req,
@ -35,7 +35,7 @@ export class PublicDatasController {
@Get([
'/api/v1/db/public/shared-view/:sharedViewUuid/groupby',
'/api/v1/public/shared-view/:sharedViewUuid/groupby',
'/api/v2/public/shared-view/:sharedViewUuid/groupby',
])
async dataGroupBy(
@Request() req,
@ -50,7 +50,7 @@ export class PublicDatasController {
@Get([
'/api/v1/db/public/shared-view/:sharedViewUuid/group/:columnId',
'/api/v1/public/shared-view/:sharedViewUuid/group/:columnId',
'/api/v2/public/shared-view/:sharedViewUuid/group/:columnId',
])
async groupedDataList(
@Request() req,
@ -68,7 +68,7 @@ export class PublicDatasController {
@Post([
'/api/v1/db/public/shared-view/:sharedViewUuid/rows',
'/api/v1/public/shared-view/:sharedViewUuid/rows',
'/api/v2/public/shared-view/:sharedViewUuid/rows',
])
@HttpCode(200)
@UseInterceptors(AnyFilesInterceptor())
@ -89,7 +89,7 @@ export class PublicDatasController {
@Get([
'/api/v1/db/public/shared-view/:sharedViewUuid/nested/:columnId',
'/api/v1/public/shared-view/:sharedViewUuid/nested/:columnId',
'/api/v2/public/shared-view/:sharedViewUuid/nested/:columnId',
])
async relDataList(
@Request() req,
@ -108,7 +108,7 @@ export class PublicDatasController {
@Get([
'/api/v1/db/public/shared-view/:sharedViewUuid/rows/:rowId/mm/:columnId',
'/api/v1/public/shared-view/:sharedViewUuid/rows/:rowId/mm/:columnId',
'/api/v2/public/shared-view/:sharedViewUuid/rows/:rowId/mm/:columnId',
])
async publicMmList(
@Request() req,
@ -128,7 +128,7 @@ export class PublicDatasController {
@Get([
'/api/v1/db/public/shared-view/:sharedViewUuid/rows/:rowId/hm/:columnId',
'/api/v1/public/shared-view/:sharedViewUuid/rows/:rowId/hm/:columnId',
'/api/v2/public/shared-view/:sharedViewUuid/rows/:rowId/hm/:columnId',
])
async publicHmList(
@Request() req,

4
packages/nocodb/src/controllers/public-metas.controller.ts

@ -9,7 +9,7 @@ export class PublicMetasController {
@Get([
'/api/v1/db/public/shared-view/:sharedViewUuid/meta',
'/api/v1/public/shared-view/:sharedViewUuid/meta',
'/api/v2/public/shared-view/:sharedViewUuid/meta',
])
async viewMetaGet(
@Request() req,
@ -23,7 +23,7 @@ export class PublicMetasController {
@Get([
'/api/v1/db/public/shared-base/:sharedBaseUuid/meta',
'/api/v1/public/shared-base/:sharedBaseUuid/meta',
'/api/v2/public/shared-base/:sharedBaseUuid/meta',
])
async publicSharedBaseGet(
@Param('sharedBaseUuid') sharedBaseUuid: string,

42
packages/nocodb/src/schema/swagger.json

@ -88,7 +88,7 @@
}
}
},
"/api/v1/auth/user/signup": {
"/api/v1/db/auth/user/signup": {
"post": {
"summary": "Signup",
"operationId": "auth-signup",
@ -187,7 +187,7 @@
"description": "Create a new user with provided email and password and first user is marked as super admin. "
}
},
"/api/v1/auth/user/signout": {
"/api/v1/db/auth/user/signout": {
"post": {
"summary": "Signout",
"operationId": "auth-signout",
@ -231,7 +231,7 @@
}
]
},
"/api/v1/auth/user/signin": {
"/api/v1/db/auth/user/signin": {
"post": {
"summary": "Signin",
"operationId": "auth-signin",
@ -292,7 +292,7 @@
}
]
},
"/api/v1/auth/user/me": {
"/api/v1/db/auth/user/me": {
"parameters": [
{
"$ref": "#/components/parameters/xc-auth"
@ -344,7 +344,7 @@
]
}
},
"/api/v1/auth/password/forgot": {
"/api/v1/db/auth/password/forgot": {
"post": {
"summary": "Forget Password",
"operationId": "auth-password-forgot",
@ -408,7 +408,7 @@
}
]
},
"/api/v1/auth/password/change": {
"/api/v1/db/auth/password/change": {
"post": {
"summary": "Change Password",
"operationId": "auth-password-change",
@ -469,7 +469,7 @@
}
]
},
"/api/v1/auth/token/validate/{token}": {
"/api/v1/db/auth/token/validate/{token}": {
"post": {
"summary": "Verify Reset Token",
"operationId": "auth-password-reset-token-validate",
@ -529,7 +529,7 @@
}
]
},
"/api/v1/auth/email/validate/{token}": {
"/api/v1/db/auth/email/validate/{token}": {
"post": {
"summary": "Verify Email",
"operationId": "auth-email-validate",
@ -589,7 +589,7 @@
}
]
},
"/api/v1/auth/password/reset/{token}": {
"/api/v1/db/uth/password/reset/{token}": {
"post": {
"summary": "Reset Password",
"operationId": "auth-password-reset",
@ -665,7 +665,7 @@
}
]
},
"/api/v1/auth/token/refresh": {
"/api/v1/db/auth/token/refresh": {
"post": {
"summary": "Refresh Token",
"operationId": "auth-token-refresh",
@ -11501,7 +11501,7 @@
"description": "Get the table rows but exculding the current record's children and parent"
}
},
"/api/v1/public/shared-view/{sharedViewUuid}/group/{columnId}": {
"/api/v1/db/public/shared-view/{sharedViewUuid}/group/{columnId}": {
"parameters": [
{
"schema": {
@ -11742,7 +11742,7 @@
"description": "List Shared View Grouped Data"
}
},
"/api/v1/public/shared-view/{sharedViewUuid}/rows": {
"/api/v1/db/public/shared-view/{sharedViewUuid}/rows": {
"parameters": [
{
"schema": {
@ -11950,7 +11950,7 @@
"description": "Create a new row for the target shared view"
}
},
"/api/v1/public/shared-view/{sharedViewUuid}/groupby": {
"/api/v1/db/public/shared-view/{sharedViewUuid}/groupby": {
"parameters": [
{
"schema": {
@ -12073,7 +12073,7 @@
"description": "List all shared view rows grouped by a column"
}
},
"/api/v1/public/shared-view/{sharedViewUuid}/rows/{rowId}/{relationType}/{columnName}": {
"/api/v1/db/public/shared-view/{sharedViewUuid}/rows/{rowId}/{relationType}/{columnName}": {
"parameters": [
{
"schema": {
@ -12271,7 +12271,7 @@
"description": "List all nested list data in a given shared view"
}
},
"/api/v1/public/shared-view/{sharedViewUuid}/rows/export/{type}": {
"/api/v1/db/public/shared-view/{sharedViewUuid}/rows/export/{type}": {
"parameters": [
{
"schema": {
@ -12329,7 +12329,7 @@
]
}
},
"/api/v1/public/shared-view/{sharedViewUuid}/nested/{columnName}": {
"/api/v1/db/public/shared-view/{sharedViewUuid}/nested/{columnName}": {
"parameters": [
{
"schema": {
@ -12451,7 +12451,7 @@
"description": "List Nested Data Relation"
}
},
"/api/v1/public/shared-base/{sharedBaseUuid}/meta": {
"/api/v1/db/public/shared-base/{sharedBaseUuid}/meta": {
"parameters": [
{
"schema": {
@ -12506,7 +12506,7 @@
]
}
},
"/api/v1/public/shared-view/{sharedViewUuid}/meta": {
"/api/v1/db/public/shared-view/{sharedViewUuid}/meta": {
"parameters": [
{
"schema": {
@ -12611,7 +12611,7 @@
"description": "Get Share View Meta"
}
},
"/api/v1/public/shared-erd/{sharedErdUuid}/meta": {
"/api/v1/db/public/shared-erd/{sharedErdUuid}/meta": {
"parameters": [
{
"schema": {
@ -14927,7 +14927,7 @@
}
]
},
"/api/v1/storage/upload": {
"/api/v1/db/storage/upload": {
"post": {
"summary": "Attachment Upload",
"operationId": "storage-upload",
@ -14973,7 +14973,7 @@
"description": "Upload attachment"
}
},
"/api/v1/storage/upload-by-url": {
"/api/v1/db/storage/upload-by-url": {
"post": {
"summary": "Attachment Upload by URL",
"operationId": "storage-upload-by-url",

Loading…
Cancel
Save