Skip to content
This repository has been archived by the owner on May 22, 2021. It is now read-only.

S3 integration #45

Merged
merged 6 commits into from
Jun 7, 2017
Merged

S3 integration #45

merged 6 commits into from
Jun 7, 2017

Conversation

abhinadduri
Copy link
Collaborator

No description provided.

@dannycoates
Copy link
Contributor

We should keep the file system version so we can dev without aws credentials. Lets factor out the storage bits into its own module. I sketched something up as a start here: https://gist.github.com/dannycoates/f75e37df25968ff74475156b894669d4

…ion, but if there is either no aws bucket or bitly key specified as env vars, it defaults back to local storage
};
}

function LocalLength(id) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Traditionally, in js this case style is used for constructors. Let's use camelCase for these function names

const redis = require('redis'),
client = redis.createClient();
const redis = require('redis');
const redis_client = redis.createClient();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we move all this redis code into storage.js?

conf.bitly_key !== 'localhost';

const AWS = require('aws-sdk');
const s3 = new AWS.S3();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove AWS and s3 from this file now

const fetch = require('node-fetch');
const storage = require('./storage.js');

let isProduction =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's confusing that isProduction can be false when NODE_ENV=production. Perhaps naming it something like useRemoteServices or localhostOnly.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I don't think this variable is used in this file anymore.
But @dannycoates comment still applies to server/storage.js:10 below.

return new Promise((resolve, reject) => {
client.hget(id, 'delete', (err, reply) => {
if (!reply || delete_token !== reply) {
resolve(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this block can just be reject()

return new Promise((resolve, reject) => {
s3.upload(params, function(err, data) {
if (err) {
console.log(err, err.stack); // an error occurred
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should call reject() here

);
} else {
resolve(
new Promise((resolve, reject) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we shouldn't need this Promise, just resolve the unlink

@dannycoates
Copy link
Contributor

This looks good to merge. I don't think we necessarily need index to be a template but NBD

@dannycoates dannycoates merged commit a4437a3 into master Jun 7, 2017
@dannycoates dannycoates deleted the s3-integration branch June 8, 2017 19:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants