Open Marak opened 9 years ago
Got this working locally.
Required that we build a new project for managing package installations ( https://github.com/bigcompany/hpm )
Should be deployed in the next day.
auto-installs of modules are back online.
Still need to test more.
@Marak would you mind sharing an example of how I can include a package from npmjs.com, which isn't in here: http://hook.io/packages/npm/installed
@gavinengel - If you attempt to require a npm module in a Hook...it should just auto-install after the first run.
If you have any issues just let me know the package name and I will install myself.
Hi Marak,
I'm new to hook.io
I'm trying to get send an email with mailgun-js but it seems not working.
module['exports'] = function echoHttp (hook) {
require('autoinstall');
var api_key = 'key-XXXXXXXXXXXXXXXXXXXXXXX';
var domain = 'mydomain.mailgun.org';
var mailgun = require('mailgun-js')({apiKey: api_key, domain: domain});
var data = {
from: 'Excited User <me@samples.mailgun.org>',
to: 'serobnic@mail.ru',
subject: 'Hello',
text: 'Testing some Mailgun awesomness!'
};
mailgun.messages().send(data, function (error, body) {
console.log(body);
});
console.log(hook.params.sender)
console.log(hook.params.recipient)
console.log(hook.params.subject)
hook.res.end(JSON.stringify({'msg':'OK'}, true, 2));
};
Can you please help? Thanks.
Auto install worked a few days ago but seems not to be working right now. I tried installing the spark
package and it's stuck in pending.
@knguyen0105 -
I went ahead and installed the mailgun-js
package on hook.io for you.
I think its working now? http://hook.io/marak/mailgun/source
Please remove the autoinstall
module. Based on the documentation I found at https://www.npmjs.com/package/autoinstall , you should not be using that tool on hook.io, ever.
Also @knguyen0105 you should put your mailgun credentials in the environment https://hook.io/env and access them through hook.env
otherwise anybody will be able to view them since the source code for your hook is publicly accessible.
@monkbroc -
I went ahead and manually installed spark
. Can you confirm it's working?
We have no automated testing around automatic npm installs right now. Will be working on that. Everything was working great until I jacked up security.
I'll take a look over the weekend and see if I can make some minor adjustments to improve visibility into package installation failures.
What I can also do is ensure that any manually installed deps / out of band dep installations will be accounted for in our database.
For this hook:
module['exports'] = function particle (hook) {
var Spark = require('spark');
}
I'm still getting a dependency error:
module.js:338
throw err;
^
Cannot find module 'spark'
It looks like `spark` is a npm dependency. We are going to try to install it!
It should be ready in a few moments...
@monkbroc Thank you very much for the tip. Mailgun credentials are stored in hook.env now!
@Marak The hook executes now till the end now. I can view log of sender and recipient but there is no mail...This is strange since I can run the same code on c9.io and got en email delivered.
Something appears wrong with auto-installs.
I'm looking into it right now.
@monkbroc - spark is working now. sorry.
I think we might have roll back to npm@2.x.x
:-\
What I'm seeing on the servers is a massive increase in lag from npm@3
when attempting to install packages in a directory with lots of packages.
I have a feeling it's scanning the entire directory in a not so nice way.
Will see what I can do.
A directory with lots of packages should be quite common on node projects!
Thanks @Marak the spark
library works now.
@Marak I still can't get mailgun-js to work. Is it possible that mailgun API drops requests from hook.io ?
Since our move to the more restricted environment npm installs stopped working.
The issue is that npm needs to be required after the process is chroot in order to ensure the correct version of npm is installing dependencies ( inside the jail )
Should be resolved in the next day or so.