Last active
May 8, 2017 10:48
-
-
Save kianenigma/68977ee67acb9405a1fba9b685f05c2e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const express = require('express') | |
const XYZ = require('xyz-core') | |
const app = express() | |
const EXPRES_PORT = 4001 | |
// setup xyz | |
const front = new XYZ({ | |
selfConf: { | |
name: 'front.ms', | |
host: '127.0.0.1', | |
// all nodes will connect to seed node which is Client service | |
seed: ['127.0.0.1:5000'] | |
transport: [{type: 'HTTP', port: 4000}], | |
logLevel: 'verbose' | |
} | |
}) | |
// setup express app | |
app.post('/service', function (req, res) { | |
front.call({ | |
servicePath: req.query['service_path'] | |
}, (err, body) => { | |
res.json({err: err, body: body}) | |
}) | |
}) | |
// note that xyz HTTP transport is listening on port 4000 | |
// and express on port 4001 | |
app.listen(EXPRES_PORT, function () { | |
// use xyz's logger | |
front.logger.info(`EXPRESS :: Front app listening on port ${EXPRES_PORT}!`) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment