-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
12,314 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
MIT License | ||
|
||
Copyright (c) friends@niiknow.org | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import store from './lib/storeHandler' | ||
import store from './src/storeHandler' | ||
import research from './src/researchHandler' | ||
|
||
export const storeHandler = post | ||
export const storeHandler = store | ||
export const researchHandler = research |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import fs from 'fs' | ||
import path from 'path' | ||
import got from 'got' | ||
import AWS from 'aws-sdk' | ||
|
||
const s3 = new AWS.S3({ | ||
accessKeyId: process.env.S3_ACCESS_KEY_ID, | ||
secretAccessKey: process.env.S3_ACCESS_KEY_SECRET, | ||
}); | ||
|
||
/** | ||
* Convert date to a number that enable most-recent first sort/ordering | ||
* on storage system such as AWS S3 | ||
* | ||
* @param {string} url the data url | ||
* @return {string} the response | ||
*/ | ||
export default (url, bucket, path) => { | ||
const fstream = got.stream(url) | ||
|
||
s3.upload({ | ||
Bucket: bucket, | ||
Key: path, | ||
Body: fstream, | ||
}, | ||
function (err, data) { | ||
console.log(err, data); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import fs from 'fs' | ||
import res from './response' | ||
import saveToS3 from './saveToS3' | ||
|
||
const debug = require('debug')('gtin-cloud') | ||
|
||
|
||
/** | ||
* Proxy request to external vendor for GTIN data | ||
* | ||
* @param object event the event | ||
* @param object context the context | ||
* @param Function callback the callback | ||
*/ | ||
export default async (event, context, callback) => { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import AWS from 'aws-sdk' | ||
|
||
const s3 = new AWS.S3() | ||
const debug = require('debug')('gtin-cloud') | ||
|
||
export default (path, data, contentType = 'image/jpeg') => { | ||
return new Promise((resolve, reject) => { | ||
const params = { | ||
Bucket: process.env.AWS_BUCKET, | ||
Body: data, | ||
Key: path | ||
} | ||
|
||
if (contentType) { | ||
params.ContentType = contentType | ||
} | ||
|
||
s3.putObject(params, (err2, data) => { | ||
if (err2) { | ||
debug(`'${path}' upload error`, err2) | ||
return reject(err2) | ||
} | ||
|
||
return resolve(data) | ||
} | ||
) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters