Skip to content

Commit

Permalink
use ENV vars instead of config.json for api keys; setup for deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
gpoitch committed Jan 28, 2015
1 parent 3a01391 commit 7510ee0
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ bower_components

# Builds
dist/
server/config.json
keys.txt
export.sh
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,20 @@

*Currently under heavy active development. API subject to change.*

## Live Demo
[http://content-kit.herokuapp.com/](http://content-kit.herokuapp.com/)

## Prerequisites
* [node.js](http://nodejs.org/) ([install package](http://nodejs.org/download/)) or `brew install node`

## Server Configuration (optional)
For embeds and image uploads, you will have to configure the built-in server:
Rename `server/config.example.json` to `server/config.json` and enter your AWS/Embedly credentials in the file.
For uploads and embeds to work, you will have to configure AWS and Embedly keys as environment variables:
```bash
export AWS_ACCESS_KEY_ID=XXXXXX
export AWS_SECRET_ACCESS_KEY=XXXXXX
export EMBEDLY_KEY=XXXXXX
```
Also, set the `bucketName` in `server/config.json` with the name of your AWS S3 bucket for uploading files.

## Playing
1. Install dependencies: `npm install`
Expand All @@ -19,4 +27,4 @@ Rename `server/config.example.json` to `server/config.json` and enter your AWS/E
`gulp test`

## Dev tips
- `gulp watch` to auto build/test as you save files
`gulp watch` to auto build/test as you save files
5 changes: 4 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ gulp.task('lint', function() {
.pipe(jshint.reporter('default'));
});

gulp.task('build-js', ['lint'], function() {
gulp.task('build-js', function() {
return gulp.src(jsSrc)
.pipe(transpile({ formatter: 'bundle' }))
.pipe(concat(jsDistName))
Expand Down Expand Up @@ -113,3 +113,6 @@ gulp.task('watch', ['watch-js', 'watch-tests', 'watch-css']);

// Default task
gulp.task('default', ['lint', 'build', 'test']);

// Deploy task
gulp.task('heroku:production', ['build']); // TODO: minify assets etc...
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"description": "A modern, minimalist WYSIWYG editor.",
"repository": "https://github.com/ContentKit/content-kit-editor",
"main": "dist/content-kit-editor.js",
"engines": {
"node": "0.10.x"
},
"scripts": {
"start": "node server/index.js",
"test": "gulp test"
Expand Down
12 changes: 0 additions & 12 deletions server/config.example.json

This file was deleted.

5 changes: 5 additions & 0 deletions server/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"s3" : {
"bucketName" : "content-kit"
}
}
2 changes: 1 addition & 1 deletion server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ app.get('/', function(req, res) {
app.post('/upload', UploadService);
app.get('/embed', EmbedService);

app.listen(5000, function() {
app.listen(process.env.PORT || 5000, function() {
console.log('content-kit-server: listening on port %d', this.address().port);
});

Expand Down
3 changes: 1 addition & 2 deletions server/services/embed.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
var embedly = require('embedly');
var config = require('../config');

module.exports = function(req, res) {

Expand All @@ -8,7 +7,7 @@ module.exports = function(req, res) {
url = 'http://' + url;
}

new embedly({key: config.embedlyKey}, function(err, api) {
new embedly({key: process.env.EMBEDLY_KEY}, function(err, api) {
if (err) {
return res.status(500).json(err);
}
Expand Down
1 change: 0 additions & 1 deletion server/services/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ var Busboy = require('busboy');
var AWS = require('aws-sdk');
var config = require('../config');

AWS.config = config.aws;
var maxFileSize = config.s3.maxFileSize || 5000000;
var uploadBucket = config.s3.bucketName;
var s3 = new AWS.S3({ params: { Bucket: uploadBucket } });
Expand Down

0 comments on commit 7510ee0

Please sign in to comment.