Skip to content

Commit

Permalink
Merge pull request #36 from G4brym/fix-bucket-pagination-api
Browse files Browse the repository at this point in the history
Fix list object endpoint limit parameter
  • Loading branch information
G4brym authored Sep 17, 2023
2 parents c578c92 + da58628 commit 848eca8
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 19 deletions.
1 change: 1 addition & 0 deletions packages/dashboard/src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ const apiHandler = {
params: {
delimiter: '/',
prefix: encodeKey(prefix)
// limit: 1000 TODO: only use this parameter on 1.0.3 or above
}
})

Expand Down
8 changes: 4 additions & 4 deletions worker/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"wrangler": "^3.6.0"
},
"dependencies": {
"@cloudflare/itty-router-openapi": "^1.0.1",
"@cloudflare/itty-router-openapi": "^1.0.3",
"postal-mime": "^1.0.16"
},
"bin": {
Expand Down
2 changes: 1 addition & 1 deletion worker/src/buckets/api/createFolder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class CreateFolder extends OpenAPIRoute {
bucket: Path(String),
},
requestBody: {
key: z.string().optional().describe('base64 encoded file key'),
key: z.string().describe('base64 encoded file key'),
}
}

Expand Down
2 changes: 1 addition & 1 deletion worker/src/buckets/api/deleteObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class DeleteObject extends OpenAPIRoute {
bucket: Path(String),
},
requestBody: {
key: z.string().optional().describe('base64 encoded file key'),
key: z.string().describe('base64 encoded file key'),
}
}

Expand Down
2 changes: 1 addition & 1 deletion worker/src/buckets/api/getObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class GetObject extends OpenAPIRoute {
summary: 'Get Object',
parameters: {
bucket: Path(String),
key: Path(z.string().optional().describe('base64 encoded file key')),
key: Path(z.string().describe('base64 encoded file key')),
},
responses: {
'200': {
Expand Down
2 changes: 1 addition & 1 deletion worker/src/buckets/api/headObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class HeadObject extends OpenAPIRoute {
summary: 'Get Object',
parameters: {
bucket: Path(String),
key: Query(z.string().optional().describe('base64 encoded file key')),
key: Query(z.string().describe('base64 encoded file key')),
},
}

Expand Down
4 changes: 2 additions & 2 deletions worker/src/buckets/api/listObjects.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {OpenAPIRoute, Path, Query} from "@cloudflare/itty-router-openapi";
import { OpenAPIRoute, Path, Query } from "@cloudflare/itty-router-openapi";
import {Context} from "../../interfaces";
import {OpenAPIRouteSchema} from "@cloudflare/itty-router-openapi/dist/src/types";
import {z} from 'zod'
Expand All @@ -10,7 +10,7 @@ export class ListObjects extends OpenAPIRoute {
summary: 'List objects',
parameters: {
bucket: Path(String),
limit: Query(z.number().optional()),
limit: Query(Number, {required: false}),
prefix: Query(z.string().optional().describe('base64 encoded prefix'),),
cursor: Query(z.string().optional()),
delimiter: Query(z.string().optional()),
Expand Down
4 changes: 2 additions & 2 deletions worker/src/buckets/api/moveObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export class MoveObject extends OpenAPIRoute {
bucket: Path(String),
},
requestBody: {
oldKey: z.string().optional().describe('base64 encoded file key'),
newKey: z.string().optional().describe('base64 encoded file key'),
oldKey: z.string().describe('base64 encoded file key'),
newKey: z.string().describe('base64 encoded file key'),
}
}

Expand Down
2 changes: 1 addition & 1 deletion worker/src/buckets/api/multipart/completeUpload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class CompleteUpload extends OpenAPIRoute {
},
requestBody: {
uploadId: String,
key: z.string().optional().describe('base64 encoded file key'),
key: z.string().describe('base64 encoded file key'),
parts: [{
etag: String,
partNumber: Int
Expand Down
2 changes: 1 addition & 1 deletion worker/src/buckets/api/multipart/createUpload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class CreateUpload extends OpenAPIRoute {
summary: 'Create upload',
parameters: {
bucket: Path(String),
key: Query(z.string().optional().describe('base64 encoded file key')),
key: Query(z.string().describe('base64 encoded file key')),
customMetadata: Query(z.string().optional().describe('base64 encoded json string')),
httpMetadata: Query(z.string().optional().describe('base64 encoded json string')),
}
Expand Down
14 changes: 12 additions & 2 deletions worker/src/buckets/api/multipart/partUpload.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Int, OpenAPIRoute, Path, Query} from "@cloudflare/itty-router-openapi";
import { Int, OpenAPIRoute, Path, Query, RequestBody } from "@cloudflare/itty-router-openapi";
import {Context} from "../../../interfaces";
import {OpenAPIRouteSchema} from "@cloudflare/itty-router-openapi/dist/src/types";
import {z} from "zod";
Expand All @@ -8,9 +8,19 @@ export class PartUpload extends OpenAPIRoute {
operationId: 'post-multipart-part-upload',
tags: ['Multipart'],
summary: 'Part upload',
requestBody: new RequestBody({
content: {
'application/octet-stream': {
schema: {
type: 'string',
format: 'binary',
},
},
},
}),
parameters: {
bucket: Path(String),
key: Query(z.string().optional().describe('base64 encoded file key')),
key: Query(z.string().describe('base64 encoded file key')),
uploadId: Query(String),
partNumber: Query(Int),
}
Expand Down
14 changes: 12 additions & 2 deletions worker/src/buckets/api/putObject.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {OpenAPIRoute, Path, Query} from "@cloudflare/itty-router-openapi";
import { OpenAPIRoute, Path, Query, RequestBody } from "@cloudflare/itty-router-openapi";
import {Context} from "../../interfaces";
import {OpenAPIRouteSchema} from "@cloudflare/itty-router-openapi/dist/src/types";
import {z} from 'zod'
Expand All @@ -8,9 +8,19 @@ export class PutObject extends OpenAPIRoute {
operationId: 'post-bucket-upload-object',
tags: ['Buckets'],
summary: 'Upload object',
requestBody: new RequestBody({
content: {
'application/octet-stream': {
schema: {
type: 'string',
format: 'binary',
},
},
},
}),
parameters: {
bucket: Path(String),
key: Query(z.string().optional().describe('base64 encoded file key')),
key: Query(z.string().describe('base64 encoded file key')),
customMetadata: Query(z.string().optional().describe('base64 encoded json string')),
httpMetadata: Query(z.string().optional().describe('base64 encoded json string')),
},
Expand Down

0 comments on commit 848eca8

Please sign in to comment.