Skip to content

Commit

Permalink
Implement route
Browse files Browse the repository at this point in the history
  • Loading branch information
kdid committed Aug 9, 2023
1 parent 0cf5397 commit 97ebacf
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/handlers/get-file-set-download.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const { wrap } = require("./middleware");
const { getFileSet } = require("../api/opensearch");
// const opensearchResponse = require("../api/response/opensearch");

/**
* A simple function to get a FileSet by id
*/
exports.handler = wrap(async (event) => {
const id = event.pathParameters.id;
const allowPrivate =
event.userToken.isSuperUser() || event.userToken.isReadingRoom();
const allowUnpublished = event.userToken.isSuperUser();
const esResponse = await getFileSet(id, { allowPrivate, allowUnpublished });
console.log(esResponse);
return {
statusCode: 200,
headers: {
"content-type": "application/json",
},
body: "Hello World",
};
// return await opensearchResponse.transform(esResponse);
});
29 changes: 29 additions & 0 deletions template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,35 @@ Resources:
ApiId: !Ref dcApi
Path: /file-sets/{id}/authorization
Method: HEAD
getFileSetDownloadFunction:
Type: AWS::Serverless::Function
Properties:
Handler: handlers/get-file-set-download.handler
Description: Downloads a file set.
Environment:
Variables:
USE_PROXIED_IP: true
Policies:
Version: 2012-10-17
Statement:
- Sid: ESHTTPPolicy
Effect: Allow
Action:
- es:ESHttp*
Resource: "*"
Events:
ApiGet:
Type: HttpApi
Properties:
ApiId: !Ref dcApi
Path: /file-sets/{id}/download
Method: GET
ApiHead:
Type: HttpApi
Properties:
ApiId: !Ref dcApi
Path: /file-sets/{id}/download
Method: HEAD
getWorkAuthFunction:
Type: AWS::Serverless::Function
Properties:
Expand Down

0 comments on commit 97ebacf

Please sign in to comment.