Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3 from garden-aid/develop
Browse files Browse the repository at this point in the history
Add iopipe to production
  • Loading branch information
johncmckim authored Aug 27, 2016
2 parents 2c66f1b + 4c9a0dc commit c10ffb2
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
coverage

webpack/*
public/dist/*

gulpfile.js
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.serverless
secrets.json

# Logs
logs
*.log
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ env:

before_install:
- npm i -g snyk
- npm i -g serverless@1.0.0-beta.1
- npm i -g serverless@beta

script: ./deploy.sh
20 changes: 20 additions & 0 deletions create-secrets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env node

'use strict';

const fs = require('fs');
const path = require('path');


const iopipeKey = process.env.IOPIPE_KEY;

if (!iopipeKey) {
throw new Error('Please set IOPIPE_KEY env var');
}

const secrets = {
iopipeKey: iopipeKey
};

const secretsPath = path.resolve(__dirname, './secrets.json');
fs.writeFileSync(secretsPath, JSON.stringify(secrets));
2 changes: 2 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ echo "Deploying from branch $BRANCH to stage $STAGE"

cp "./config/$STAGE.json" config.json

node ./create-secrets.js # create secrets.json from env variables

npm prune --production

sls deploy --stage $STAGE --region $AWS_REGION
11 changes: 9 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@

const config = require('./config.json')
const env = require('./env');

require('./env')(config);
const config = require('./config.json');
const secrets = require('./secrets.json');

env(config);
env(secrets, true);

// Setup env vars before requiring functions
const graphql = require('./src/graphql');
const iopipe = require('iopipe')({
clientId: process.env.iopipeKey
});

module.exports.graphql = graphql.handler;
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"dependencies": {
"bluebird": "^3.4.1",
"graphql": "^0.6.1",
"iopipe": "0.0.19",
"joi": "^9.0.4",
"lodash": "^4.13.1",
"moment": "^2.14.1",
Expand Down
14 changes: 11 additions & 3 deletions serverless.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,21 @@ defaults:
region: ap-southeast-2
package:
include:
- index.js
- src
- node_modules
- src
exclude:
- tests
- coverage
- tests
- .editorconfig
- .eslintignore
- .gitignore
- .synk
- .travis.yml
- .create-secrets.js
- deploy.sh
- LICENSE
- package.json
- README.md

functions:
graphQl:
Expand Down

0 comments on commit c10ffb2

Please sign in to comment.