-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
34 lines (29 loc) · 1.06 KB
/
Copy pathserver.js
File metadata and controls
34 lines (29 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const express = require( 'express' ),
app = express(),
littlebits = require(__dirname + '/littlebits.js'),
aws = require(__dirname + '/aws.js'),
slack = require(__dirname + '/slack.js');
littlebits.subscribeToCloudBit( function( err ){
if ( err ){
console.log( err );
}
} );
app.get('/', function (req, res) {
/* Show project README when visiting home page. */
res.redirect( `https://glitch.com/edit/#!/${process.env.PROJECT_DOMAIN}?path=README.md` );
} );
app.post( '/on', function ( req, res ) {
/* When the button is pressed, check deployment status. If no deployment is running, start one. */
aws.checkDeploymentStatus( function( isDeploying ){
if ( !isDeploying ){
aws.runDeployment( function( err ){
/* Check for errors, do whatever. */
} );
} else {
slack.postSlackMessage( process.env.SLACK_CHANNEL_ID, 'Deployment in progress.' );
}
} );
} );
var listener = app.listen( process.env.PORT, function () {
console.log( `app is listening on port ${listener.address().port}` );
} );