Skip to content

Commit

Permalink
Merge branch 'main' into selfhost
Browse files Browse the repository at this point in the history
  • Loading branch information
auniverseaway authored Mar 30, 2024
2 parents 9554ebc + a350e1d commit 1863498
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 13 deletions.
2 changes: 2 additions & 0 deletions src/handlers/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
*/
import { postSource } from '../routes/source.js';
import { postConfig } from '../routes/config.js';
import copyHandler from '../routes/copy.js';

export default async function postHandler({ req, env, daCtx }) {
const { path } = daCtx;

if (path.startsWith('/source')) return postSource({ req, env, daCtx });
if (path.startsWith('/config')) return postConfig({ req, env, daCtx });
if (path.startsWith('/copy')) return copyHandler({ req, env, daCtx });

return undefined;
}
10 changes: 3 additions & 7 deletions src/routes/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@
import copyObject from '../storage/object/copy.js';
import copyHelper from '../helpers/copy.js';

export default async function copyHandler(req, env, daCtx) {
if (req.method === 'POST') {
const details = await copyHelper(req, daCtx);
return copyObject(env, daCtx, details);
}

return { body: JSON.stringify([]), status: 200, contentType: 'application/json' };
export default async function copyHandler({ req, env, daCtx }) {
const details = await copyHelper(req, daCtx);
return copyObject(env, daCtx, details);
}
6 changes: 1 addition & 5 deletions src/storage/object/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ const copyFile = async (client, org, sourceKey, details) => {
// eslint-disable-next-line no-console
console.log(e.$metadata);
}

// const delCommand = new DeleteObjectCommand({ Bucket: `${org}-content`, Key: sourceKey });
// const url = await getSignedUrl(client, delCommand, { expiresIn: 3600 });
// await fetch(url, { method: 'DELETE' });
};

export default async function copyObject(env, daCtx, details) {
Expand Down Expand Up @@ -78,5 +74,5 @@ export default async function copyObject(env, daCtx, details) {
}
} while (ContinuationToken);

return { body: '', status: 204 };
return { status: 204 };
}
2 changes: 1 addition & 1 deletion src/utils/daResp.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
export default function daResp({
status,
body = '',
body,
contentType = 'application/json',
contentLength,
}) {
Expand Down

0 comments on commit 1863498

Please sign in to comment.