diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-04-08 23:19:49 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-04-08 23:19:49 -0400 |
| commit | 2a4266fd00a0b1327a7b24ee9807b94f0060a118 (patch) | |
| tree | 316b74a259ecd3ba5bafbe89f9cbfdf30b8d4159 | |
| parent | bae6a32b83209846b2a6a757c0c414d537c157b2 (diff) | |
load environment with dotenv
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | app/index.js | 6 | ||||
| -rw-r--r-- | app/node_modules/okservices/index.js | 10 | ||||
| -rw-r--r-- | examples/index.js | 8 | ||||
| -rw-r--r-- | package.json | 1 |
5 files changed, 26 insertions, 1 deletions
@@ -5,3 +5,5 @@ *.swp .DS_Store db.json +.env + diff --git a/app/index.js b/app/index.js index b9958c2..b312eb1 100644 --- a/app/index.js +++ b/app/index.js @@ -15,6 +15,8 @@ var OKServer = require('okserver'); var OKSchema = require('okschema'); var OKImageService = require('okservices').OKImageService; +require('dotenv').load(); + /** * OKCMS! * Basically takes configuration and gives you a server. @@ -68,6 +70,7 @@ function OKCMS(options) { var viewConfig = options.views || { '/': { template: 'index' } }; + var serviceConfig = options.services || {}; var templateProvider = this._templateProvider = new OKTemplate({root: templateRoot}); @@ -88,7 +91,8 @@ function OKCMS(options) { // Create services var imageService = OKImageService({ - express: express + express: express, + s3: serviceConfig.s3, }); var server = this._server = new OKServer({ diff --git a/app/node_modules/okservices/index.js b/app/node_modules/okservices/index.js index cb96072..10de460 100644 --- a/app/node_modules/okservices/index.js +++ b/app/node_modules/okservices/index.js @@ -5,6 +5,8 @@ function OKImageService(options) { options = options || {}; if (!options.express) throw new Error('Express not provided to OKImageService'); + if (!options.s3) + throw new Error('S3 configuration not provided to OKImageService'); var express = options.express; var router = express.Router(); @@ -14,6 +16,14 @@ function OKImageService(options) { router.post('/', function(req, res) { // req should have a method `file` on it which is // provided by skipper. Use that to do AWS stuff + req.file('image').upload({ + adapter: require('skipper-s3'), + key: options.s3.key, + secret: options.s3.secret, + bucket: options.s3.bucket + }, function (err, uploadedFiles) { + // + }); }); this._middleware = router; diff --git a/examples/index.js b/examples/index.js index 56693ce..3dd3a39 100644 --- a/examples/index.js +++ b/examples/index.js @@ -24,6 +24,14 @@ var app = okcms.createApp({ { type: 'bread' }, ], + services: { + s3: { + key: process.env.S3_KEY, + secret: process.env.S3_SECRET, + bucket: process.env.S3_BUCKET, + } + }, + views: { '/': { data: [ diff --git a/package.json b/package.json index 1e7c1cd..c837051 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "author": "OKFocus", "license": "None", "dependencies": { + "dotenv": "^1.1.0", "express": "^4.12.3", "object-assign": "^2.0.0", "q": "^1.2.0" |
