-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
460 additions
and
2,498 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
language: node_js | ||
node_js: | ||
- "0.12" | ||
- "4.4" | ||
- "5.11" | ||
- "6.1" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// lambda.js | ||
'use strict' | ||
const awsServerlessExpress = require('aws-serverless-express') | ||
const app = require('./app') | ||
const server = awsServerlessExpress.createServer(app) | ||
|
||
exports.handler = (event, context) => awsServerlessExpress.proxy(server, event, context) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,82 @@ | ||
'use strict'; | ||
|
||
// See gulp help for overview of commands. | ||
// Requires added the following modules to your dependencies: | ||
// del, aglex, yargs, gulp-help, run-sequence, config, gulp-rename, gulp-zip, gulp-live-server | ||
|
||
var fs = require('fs'); | ||
var del = require('del'); | ||
var aglex = require('aglex'); | ||
var argv = require('yargs') | ||
.default('env','development') | ||
.argv; | ||
|
||
var gulp = require('gulp-help')(require('gulp')); | ||
var runSequence = require('run-sequence'); | ||
|
||
process.env.NODE_ENV = argv.env; | ||
|
||
// Load config from config/ | ||
var config = require('config'); | ||
|
||
var sourceFiles = ['app.js', 'config/*', 'public/**', 'routes/**']; | ||
|
||
gulp.task('serve', 'Start a local development server', () => { | ||
var gls = require('gulp-live-server'); | ||
var server = gls.new('bin/www', {env: {NODE_ENV: 'staging'}}); | ||
server.start(); | ||
|
||
gulp.watch(sourceFiles, () => { | ||
console.log("restart server"); | ||
server.start.bind(server)(); | ||
}); | ||
}); | ||
|
||
gulp.task('build', 'clean and updateLambda', () => runSequence('clean','updateLambda')) | ||
|
||
gulp.task('clean', 'remove the build directory', (done) => del('build', done)); | ||
|
||
gulp.task('copyPackages', 'copy dependences from node_modules into build directory', () => { | ||
var pkg = require('./package.json'); | ||
var depsRe = Object.keys(pkg.dependencies).join('|'); | ||
|
||
gulp.src("node_modules/@("+depsRe+")/**") | ||
.pipe(gulp.dest('build/node_modules')); | ||
}); | ||
|
||
gulp.task('copyConfig', 'copy active config into build directory', () => { | ||
var rename = require('gulp-rename'); | ||
|
||
gulp.src("config/production.yml") | ||
.pipe(rename('default.yml')) | ||
.pipe(gulp.dest('build/config')); | ||
}); | ||
|
||
gulp.task('zip', 'create zipfile to upload', ['copyConfig','copyPackages'], () => { | ||
var zip = require('gulp-zip'); | ||
|
||
'use strict' | ||
const fs = require('fs') | ||
const gulp = require('gulp') | ||
const $ = require('gulp-load-plugins')() | ||
const argv = require('yargs').default('env','development').argv | ||
const yaml = require('js-yaml') | ||
|
||
const aglex = (() => { | ||
const aglexConfig = yaml.safeLoad(fs.readFileSync(`aglex-${argv.env}.yml`, 'utf8')) | ||
return require('aglex')(aglexConfig, 'info') | ||
})() | ||
|
||
const sourceFiles = ['src/**/*.js'] | ||
|
||
gulp.task('serve', () => { | ||
const server = $.liveServer('src/www.js', {env: {NODE_ENV: argv.env}}, false) | ||
server.start() | ||
return gulp.watch(sourceFiles, () => { | ||
console.log('restart server') | ||
return server.start.bind(server)() | ||
}) | ||
}) | ||
|
||
gulp.task('build', () => | ||
require('run-sequence')('clean', 'zip') | ||
) | ||
|
||
gulp.task('clean', done => | ||
require('del')(['build/*', '!build/node_modules', 'dist/*'], done) | ||
) | ||
|
||
gulp.task('lint', () => | ||
gulp.src(sourceFiles) | ||
.pipe($.eslint()) | ||
.pipe($.eslint.format()) | ||
.pipe($.eslint.failAfterError()) | ||
) | ||
|
||
gulp.task('prepareCode', ['lint'], () => | ||
gulp.src(sourceFiles) | ||
.pipe(gulp.dest('build')) | ||
) | ||
|
||
gulp.task('prepareConfig', () => | ||
gulp.src(`config/${argv.env}.yml`) | ||
.pipe($.rename('default.yml')) | ||
.pipe(gulp.dest('build/config')) | ||
) | ||
|
||
gulp.task('preparePackages', () => | ||
gulp.src(['./package.json', './npm-shrinkwrap.json']) | ||
.pipe(gulp.dest('build')) | ||
.pipe($.install({production: true})) | ||
) | ||
|
||
gulp.task('zip', ['prepareCode', 'prepareConfig', 'preparePackages'], () => | ||
gulp.src('build/**') | ||
.pipe(zip('lambda.zip')) | ||
.pipe(gulp.dest('dist')); | ||
}); | ||
.pipe($.zip('lambda.zip')) | ||
.pipe(gulp.dest('dist')) | ||
) | ||
|
||
gulp.task('updateLambda', 'create zip file and update Lambda', ['zip'], (done) => { | ||
aglex.updateLambda('dist/lambda.zip').then(done); | ||
}); | ||
gulp.task('updateLambda', ['zip'], () => aglex.updateLambda('dist/lambda.zip')) | ||
|
||
gulp.task('updateLambdaPermission', 'update Lambda permissions', (done) => { | ||
aglex.addLambdaPermission().then(done); | ||
}); | ||
gulp.task('addLambdaPermission', () => aglex.addLambdaPermission()) | ||
|
||
// Requires --stage, --desc and --stagedesc are optional | ||
gulp.task('deployApi', 'deploy the API. requires --stage. --desc and --stagedesc optional.', (done) => { | ||
gulp.task('updateApi', () => aglex.updateApi()) | ||
|
||
gulp.task('deployApi', () => { | ||
if (!argv.stage) { | ||
console.log("Please use --stage STAGENAME"); | ||
return; | ||
console.log('Please use --stage STAGENAME') | ||
return | ||
} | ||
|
||
aglex.deployApi(argv.desc, argv.stage, argv.stagedesc).then(done); | ||
}); | ||
return aglex.deployApi(argv.desc, argv.stage, argv.stagedesc) | ||
}) | ||
|
||
gulp.task('listStages', () => | ||
aglex.getApiStages().then(stages => { | ||
for (let stage of stages) { | ||
console.log(`${stage.stageName}:${stage.description || ''} (${stage.invokeUrl})`) | ||
} | ||
}) | ||
) |
Oops, something went wrong.