-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from javierbrea/release-1.0.0-alpha.1
Release 1.0.0 alpha.1
- Loading branch information
Showing
25 changed files
with
678 additions
and
17 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env node | ||
|
||
require('../lib/cli') |
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,12 @@ | ||
'use strict' | ||
|
||
const path = require('path') | ||
const domapic = require('domapic-service') | ||
|
||
const options = require('./options') | ||
|
||
domapic.cli({ | ||
packagePath: path.resolve(__dirname, '..'), | ||
script: path.resolve(__dirname, '..', 'server.js'), | ||
customConfig: options | ||
}) |
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,17 @@ | ||
'use strict' | ||
|
||
const { WEBHOOK_URI, WEBHOOK_METHOD } = require('./statics') | ||
|
||
module.exports = { | ||
[WEBHOOK_URI]: { | ||
type: 'string', | ||
alias: ['url'], | ||
describe: 'Define the webhook url' | ||
}, | ||
[WEBHOOK_METHOD]: { | ||
type: 'string', | ||
describe: 'GPIO number where the relay is connected', | ||
choices: ['GET', 'POST'], | ||
default: 'POST' | ||
} | ||
} |
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,6 @@ | ||
'use strict' | ||
|
||
module.exports = { | ||
WEBHOOK_URI: 'url', | ||
WEBHOOK_METHOD: 'method' | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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 +1,46 @@ | ||
'use strict' | ||
|
||
const path = require('path') | ||
|
||
const domapic = require('domapic-service') | ||
const requestPromise = require('request-promise') | ||
|
||
const options = require('./lib/options') | ||
const { WEBHOOK_URI, WEBHOOK_METHOD } = require('./lib/statics') | ||
|
||
const ABILITY = 'webhook' | ||
|
||
domapic.createModule({ | ||
packagePath: path.resolve(__dirname), | ||
customConfig: options | ||
}).then(async dmpcModule => { | ||
const config = await dmpcModule.config.get() | ||
|
||
await dmpcModule.register({ | ||
[ABILITY]: { | ||
description: 'Launch a request to a webhook', | ||
event: { | ||
description: 'The webhook has been triggered' | ||
}, | ||
action: { | ||
description: 'Trigger the webhook', | ||
handler: async () => { | ||
await dmpcModule.tracer.info(`Sending ${config[WEBHOOK_METHOD]} request to ${config[WEBHOOK_URI]}`) | ||
return requestPromise({ | ||
uri: config[WEBHOOK_URI], | ||
method: config[WEBHOOK_METHOD] | ||
}).then(() => { | ||
dmpcModule.events.emit(ABILITY) | ||
return Promise.resolve() | ||
}).catch(async error => { | ||
const errorMessage = `Error ${error.response.statusCode} received from ${config[WEBHOOK_METHOD]} to ${config[WEBHOOK_URI]}` | ||
await dmpcModule.tracer.error(errorMessage) | ||
return Promise.reject(new dmpcModule.errors.BadGateway(errorMessage)) | ||
}) | ||
} | ||
} | ||
} | ||
}) | ||
|
||
return dmpcModule.start() | ||
}) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env bash | ||
|
||
rm -rf .test | ||
mkdir .test |
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,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
npm i |
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,4 @@ | ||
#!/usr/bin/env bash | ||
|
||
./test/functional/commands/pm2-clean.sh | ||
./test/functional/commands/clean.sh |
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,4 @@ | ||
#!/usr/bin/env bash | ||
|
||
pm2 flush | ||
pm2 delete webhook-domapic-module |
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,4 @@ | ||
#!/usr/bin/env bash | ||
|
||
npm run domapic-webhook start -- --path=${domapic_path} ${service_extra_options} | ||
npm run domapic-webhook logs |
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,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
node server.js --path=${domapic_path} ${service_extra_options} |
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,24 @@ | ||
const test = require('narval') | ||
|
||
const utils = require('./utils') | ||
|
||
test.describe('module configuration', function () { | ||
this.timeout(10000) | ||
let connection | ||
|
||
test.before(() => { | ||
connection = new utils.Connection() | ||
}) | ||
|
||
test.it('should be exposed in config api', () => { | ||
return connection.request('/config', { | ||
method: 'GET' | ||
}).then(response => { | ||
return Promise.all([ | ||
test.expect(response.statusCode).to.equal(200), | ||
test.expect(response.body.url).to.equal('http://google.com'), | ||
test.expect(response.body.method).to.equal('GET') | ||
]) | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.