Closed Marak closed 9 years ago
As I said on irc this would be extremely beneficial for us :)
I don't think it would be too hard. Look at haraka.js - it's pretty simple - that's how I test it (via "node haraka.js"). The only complex issue is that there's a very intimate tie-in with the config/plugin directories and system. I don't think you can get around that.
I'm going to try to fork it to see if I can give you something to think about. Wonder if I'll be capable of doing that cause I have little experience with the haraka source code :)
Nah, couldn't do it in 5 minutes as expected
This is the DSL I thought about, it's heavily based on expressjs
but I think that's what most developer will be expecting by now. It absolutely doesn't need to be like this, the important thing is that we could factor out the haraka source code away from user applications (without forcing the use to use Haraka -c .
):
var haraka = require('haraka')
, cfg = require('./cfg/couchdb') // much easier is cfg files are javascript
, app = module.exports = hakara.createServer()
;
app.initialize( function() {
app.useLogger(true); // defaults to true
app.logLevel('debug'); // defaults to info
app.logFormat(':time :plugin :message');
app.registerPlugin('dnsbl'); // absence of new cfg file means use default (or none)
app.registerPlugin('data.signatures');
app.registerPlugin('couch', cfg);
});
app.listen(25, '127.0.0.1'); // optional second argument, defaults to localhost
process.on('uncaughtException', function(err) {
console.log(JSON.stringify(err));
});
Well you can already do:
var server = require('/path/to/haraka/server.js');
var instance = server.createServer({port: 25});
It's just the problem of loading other config that gets tricky.
This hasn't progressed in 3 years. If it's still interesting, it can be reopened.
Currently the library is tightly bound to the command line.
It would be a lot better if this was properly decoupled and there was a better createServer() entry point for the haraka library.
Would you accept a patch to restructure the library to work like this? I estimate it will take me between 2-3 hours.
I would use a similar structure convention as our application server
haibu
.Something like:
https://github.com/nodejitsu/haibu/blob/master/bin/haibu-server https://github.com/nodejitsu/haibu/blob/master/lib/haibu.js
Thoughts?