2017-04-28 00:59:03 +03:00
|
|
|
'use strict';
|
|
|
|
|
2017-05-23 03:13:15 +03:00
|
|
|
const Graphi = require('graphi');
|
2017-05-11 23:28:32 +03:00
|
|
|
const PortalData = require('portal-data');
|
2017-04-28 00:59:03 +03:00
|
|
|
const Graphql = require('./models/graphql');
|
|
|
|
const Pack = require('../package.json');
|
|
|
|
const Routes = require('./routes');
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = function (server, options, next) {
|
2017-05-11 23:28:32 +03:00
|
|
|
const data = new PortalData(options.data);
|
2017-05-02 01:28:03 +03:00
|
|
|
data.connect((err) => {
|
|
|
|
if (err) {
|
|
|
|
return next(err);
|
|
|
|
}
|
2017-04-28 00:59:03 +03:00
|
|
|
|
2017-05-02 01:28:03 +03:00
|
|
|
server.bind(data);
|
|
|
|
|
|
|
|
server.register([
|
|
|
|
{
|
2017-05-23 03:13:15 +03:00
|
|
|
register: Graphi,
|
|
|
|
options: Graphql.options(data)
|
2017-04-28 00:59:03 +03:00
|
|
|
}
|
2017-05-02 01:28:03 +03:00
|
|
|
]);
|
|
|
|
|
|
|
|
server.route(Routes);
|
2017-04-28 00:59:03 +03:00
|
|
|
|
2017-05-02 01:28:03 +03:00
|
|
|
next();
|
|
|
|
});
|
2017-04-28 00:59:03 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
module.exports.attributes = {
|
|
|
|
name: Pack.name,
|
|
|
|
version: Pack.version,
|
|
|
|
once: true,
|
|
|
|
multiple: false
|
|
|
|
};
|