forked from cerc-io/ipld-eth-server
d417b9cf3d
update subscription setup after doc was fixed
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import { createServer } from 'http';
|
|
import { postgraphile, makePluginHook } from 'postgraphile';
|
|
import { readFileSync } from 'fs';
|
|
|
|
import express = require('express');
|
|
import passport = require('passport');
|
|
import session = require('express-session');
|
|
import toml = require('toml');
|
|
|
|
const {
|
|
default: PostGraphileSupporter,
|
|
enhanceHttpServerWithSubscriptions,
|
|
} = require('@graphile/plugin-supporter');
|
|
const pluginHook = makePluginHook([PostGraphileSupporter]);
|
|
|
|
import { ServerUtilities } from './server/interface';
|
|
import { bootServer } from './server/runtime';
|
|
import { parseConfig } from './config/parse';
|
|
|
|
import {
|
|
buildServerConfig,
|
|
CONFIG_PATH_KEY,
|
|
SERVER_PORT_KEY
|
|
} from './server/config';
|
|
|
|
const configPath = process.env[CONFIG_PATH_KEY];
|
|
const serverPort = process.env[SERVER_PORT_KEY];
|
|
|
|
const serverUtilities: ServerUtilities = {
|
|
enableSubscriptions: enhanceHttpServerWithSubscriptions,
|
|
express,
|
|
expressSession: session,
|
|
httpServerFactory: createServer,
|
|
passport,
|
|
postgraphile,
|
|
pluginHook
|
|
};
|
|
|
|
const databaseConfig = parseConfig(readFileSync, toml.parse, configPath);
|
|
const serverConfig = buildServerConfig(
|
|
serverUtilities, databaseConfig, serverPort);
|
|
|
|
bootServer(serverUtilities, serverConfig);
|