forked from DebaucheryLibrarian/traxxx
Experimenting using GraphQL in favor of REST.
This commit is contained in:
@@ -3,9 +3,13 @@
|
||||
const path = require('path');
|
||||
const config = require('config');
|
||||
const express = require('express');
|
||||
const { postgraphile } = require('postgraphile');
|
||||
const Router = require('express-promise-router');
|
||||
const bodyParser = require('body-parser');
|
||||
|
||||
const ConnectionFilterPlugin = require('postgraphile-plugin-connection-filter');
|
||||
const PgSimplifyInflectorPlugin = require('@graphile-contrib/pg-simplify-inflector');
|
||||
|
||||
const {
|
||||
fetchReleases,
|
||||
fetchReleaseById,
|
||||
@@ -28,6 +32,25 @@ function initServer() {
|
||||
const app = express();
|
||||
const router = Router();
|
||||
|
||||
const connectionString = `postgres://${config.database.user}:${config.database.password}@${config.database.host}:5432/${config.database.database}`;
|
||||
|
||||
app.use(postgraphile(
|
||||
connectionString,
|
||||
'public',
|
||||
{
|
||||
// watchPg: true,
|
||||
dynamicJson: true,
|
||||
graphiql: true,
|
||||
enhanceGraphiql: true,
|
||||
allowExplain: () => true,
|
||||
simpleCollections: 'only',
|
||||
graphileBuildOptions: {
|
||||
pgOmitListSuffix: true,
|
||||
},
|
||||
appendPlugins: [PgSimplifyInflectorPlugin, ConnectionFilterPlugin],
|
||||
},
|
||||
));
|
||||
|
||||
router.use('/media', express.static(config.media.path));
|
||||
router.use(express.static('public'));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user