1
0
mirror of https://github.com/yldio/copilot.git synced 2024-11-10 21:30:06 +02:00
copilot/packages/portal-api/lib/index.js
2017-05-30 20:18:45 +01:00

39 lines
714 B
JavaScript

'use strict';
const Schema = require('joyent-cp-gql-schema');
const Graphi = require('graphi');
const PortalData = require('portal-data');
const Pack = require('../package.json');
const Resolvers = require('./resolvers');
module.exports = function (server, options, next) {
const data = new PortalData(options.data);
data.connect((err) => {
if (err) {
return next(err);
}
server.bind(data);
server.register([
{
register: Graphi,
options: {
schema: Schema,
resolvers: Resolvers(data)
}
}
]);
next();
});
};
module.exports.attributes = {
name: Pack.name,
version: Pack.version,
once: true,
multiple: false
};