Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c7edb33
add datasources
larrylin17 Feb 19, 2021
8c0a083
add schema, resolvers to graphql
larrylin17 Feb 19, 2021
4c7cac8
add field and ignoreFile for graphql in zero-module.yml
larrylin17 Feb 19, 2021
3b2b342
remove store.sqlite from git
larrylin17 Feb 19, 2021
fae1790
Merge branch 'main' into add-graphql-support-to-node-backend
larrylin17 Feb 20, 2021
ae82c74
switch sqlite to default database
larrylin17 Feb 20, 2021
c6b3f9a
update file apis to match Go version
larrylin17 Feb 22, 2021
7df277a
add graphql for s3 file apis
larrylin17 Feb 22, 2021
19f8030
change type to category due to type is against preserve keyword type
larrylin17 Feb 22, 2021
9a9c21b
Strip down graphql functions
larrylin17 Feb 22, 2021
0f81c61
change expression 'graphql=yes/no' to apiType='graphql/rest'
larrylin17 Feb 23, 2021
1eae7e2
add apiType="graphql/rest" to package.json
larrylin17 Feb 23, 2021
eb87d65
support users to choose buckets
larrylin17 Feb 23, 2021
b8f43b5
Strip down graphql functions
larrylin17 Feb 23, 2021
9c940ed
add graphql for authAPI
larrylin17 Feb 24, 2021
4b85fc2
add env variable GRAPHQL_BASE_URL to Kubernetes config
larrylin17 Feb 24, 2021
5a487de
imitate middleware/auth/index.js to add authentication to graphql
larrylin17 Feb 25, 2021
a5a9fc8
restructure directories for graphql and rest api
larrylin17 Feb 26, 2021
3825e22
refactor file apis with FileService that is used by graphql as well
larrylin17 Feb 26, 2021
01333b5
add trip service for demonstration
larrylin17 Feb 27, 2021
cee9227
remove all datasources from graphql and remove initdb.js
larrylin17 Feb 27, 2021
e8ade19
add mockauth and standard jwt decode middleware
larrylin17 Mar 1, 2021
041f24e
add standard jwtDecoder in middleware
larrylin17 Mar 1, 2021
b80433b
seperate main entry for rest and graphql
larrylin17 Mar 1, 2021
2f99c44
optimize variable definition pre-keyword
larrylin17 Mar 2, 2021
67e9d1c
remove env var GRAPHQL_BASE_URL from kustomization.yml
larrylin17 Mar 2, 2021
43d6609
add documentation to graphql schema
larrylin17 Mar 4, 2021
708061d
remove health check endpoints through Graphql
larrylin17 Mar 4, 2021
97b662d
update documnetation for graphql schemas
larrylin17 Mar 4, 2021
b1137ad
update ignorefile for rest apipType
larrylin17 Mar 4, 2021
713ae1e
change download link from s3 presigned url to cloudfront signed url.
larrylin17 Mar 5, 2021
b836664
update auth component and add the whitelist filter
larrylin17 Mar 5, 2021
86c040c
remove the empty template block
larrylin17 Mar 5, 2021
642cccf
split persignedurls to downloadSignedUrl and uploadSignedUrl
larrylin17 Mar 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
change download link from s3 presigned url to cloudfront signed url.
  • Loading branch information
larrylin17 committed Mar 5, 2021
commit 713ae1eb79a05261665bb7fac83f407d022eff09
4 changes: 3 additions & 1 deletion templates/src/conf/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const conf = {
jwtSecret: "SecretfromIdentityProvider"
jwtSecret: "SecretfromIdentityProvider",
s3PresignedExpires: 60 * 5, //5 minutes
cfSignerExpires: 1000 * 60 * 5 //5 minutes
}

module.exports = conf;
1 change: 0 additions & 1 deletion templates/src/graphql/default.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
This schema is the default graphql schema, please don't remove it.
"""

"The user object for the authentication"
type User {
"The user id from the authentication middleware"
id: ID!
Expand Down
21 changes: 13 additions & 8 deletions templates/src/service/file.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const aws = require("aws-sdk");
const conf = require("../conf");

const s3 = new aws.S3();

Expand All @@ -9,7 +10,7 @@ class FileService {
const params = {
Bucket: process.env.S3_BUCKET,
Key: key,
Expires: 60 * 60, // 60 minutes
Expires: conf.s3PresignedExpires,
};
const url = s3.getSignedUrl('putObject',params);
return {
Expand All @@ -19,13 +20,17 @@ class FileService {
}

getDownloadPresignedUrl(key){
const params = {
Bucket: process.env.S3_BUCKET,
Key: key,
Expires: 60 * 60, // 60 minutes
};
const url = s3.getSignedUrl('getObject',params);
console.log(url);
const cloudfrontAccessKeyId = process.env.CF_KEYPAIR_ID;
const cloudFrontPrivateKey = process.env.CF_KEYPAIR_SECRET_KEY;
const cloudFrontDomain = process.env.CF_DOMAIN;
const signer = new aws.CloudFront.Signer(cloudfrontAccessKeyId, cloudFrontPrivateKey);
key = (key.substring(0,1)=='/') ? key : "/"+key

const url = signer.getSignedUrl({
url: cloudFrontDomain+key,
expires: new Date().getTime() + conf.cfSignerExpires
});

return {
url: url,
method: "get"
Expand Down