Skip to content

Instantly share code, notes, and snippets.

@nevyn
Last active October 29, 2015 07:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nevyn/6533f61af8ffc80663f3 to your computer and use it in GitHub Desktop.
Save nevyn/6533f61af8ffc80663f3 to your computer and use it in GitHub Desktop.
console.log("Hello AwsStorageAdapter.coffee!!");
Interface = require("../../Interface/storage.coffee")
class AWSStorageAdapter extends Interface.Storage
Path = require 'path'
AWS = require 'aws-sdk'
...
console.log("Hello index.js");
module.exports = require("./lib/Interface/storage.coffee");
module.exports.StorageAdapters.AWSStorageAdapter = require('./lib/Adapters/AWS/AwsStorageAdapter.coffee');
module.exports.StorageAdapters.SProxyStorageAdapter = require('./lib/Adapters/SProxy/SProxyStorageAdapter.coffee');
console.log("Hello meteor-support");
/* Make this NPM package look like a Meteor package.
Q: Why not just make an "npm package wrapper"?
A: Because the package isn't published anywhere, and I (nevyn) can't figure out how to make it
depend on the package from a git URL (either 404's or complains about "exact version").
Q: But isn't this kinda ugly?
A: Eh yeah. If you know a better fix, lemme know and I'll do it.
*/
// Catch module.exports = ... calls and just ignore them. package.js will do the actual exporting instead.
module = {}
// Catch require() calls. If it's to a local file, hard-code appropriate returns. Otherwise, let NPM handle it.
require = function(moduleName) {
if(moduleName.indexOf("storage.coffee") != -1)
return {Storage: Storage, StorageAdapters: StorageAdapters};
if(moduleName.indexOf("AwsStorageAdapter.coffee") != -1)
return AWSStorageAdapter;
if(moduleName.indexOf("SProxyStorageAdapter.coffee") != -1)
return SProxyStorageAdapter;
if(moduleName.indexOf("SProxyJWTSigner.coffee") != -1)
return SProxyJWTSigner;
return Npm.require(moduleName)
}
Package.describe({
name: 'lookback:storage',
version: '0.0.1',
// Brief, one-line summary of the package.
summary: '',
// URL to the Git repository containing the source code for this package.
git: '',
// By default, Meteor will default to using README.md for documentation.
// To avoid submitting documentation, set this field to null.
documentation: 'README.md'
});
Npm.depends({
"mkdirp": "0.5.1",
// For the AWS adapter
"aws-sdk": "1.7.1",
"aws-cloudfront-sign": "2.0.1",
// For the SProxy adapter
"json-web-token": "1.5.3",
});
Package.onUse(function(api) {
api.versionsFrom('1.1.0.2');
api.use('coffeescript', 'server');
api.use('underscore', 'server');
api.addFiles([
'meteor-support.js',
'lib/Interface/storage.coffee',
'lib/Adapters/AWS/AwsStorageAdapter.coffee',
'lib/Adapters/SProxy/SProxyStorageAdapter.coffee',
'lib/Adapters/SProxy/SProxyJWTSigner.coffee',
], 'server');
api.export('Storage', 'server');
api.export('StorageAdapters', 'server');
api.export('AwsStorageAdapter', 'server');
api.export('SProxyJWTSigner', 'server');
api.export('SProxyStorageAdapter', 'server');
api.addFiles([
'index.js',
], 'server');
});
Package.onTest(function(api) {
api.use('tinytest');
api.use('lookback:storage');
api.addFiles('storage-tests.coffee');
});
console.log("Hello storage.coffee");
Path = require("path")
http = require('http')
https = require('https')
URL = require('url')
fs = require('fs')
mkdirp = require('mkdirp')
Future = require('fibers/future')
_ = require('underscore')
# Base class and public interface for long-term file storage.
# Cloud uses an AWSStorageAdapter, onprem environments might use others.
class Storage
# Call this to access the currently configured storage adapter. Don't use
# subclasses directly unless you know what you're doing.
@shared: ->
.....
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment