forked from DebaucheryLibrarian/traxxx
Extended and improved transfer tool. Moved scenes up on movie page.
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
'use strict';
|
||||
|
||||
const config = require('config');
|
||||
const { withPostGraphileContext } = require('postgraphile');
|
||||
const { graphql } = require('graphql');
|
||||
|
||||
const pg = require('./postgraphile');
|
||||
const initPg = require('./postgraphile');
|
||||
const logger = require('../logger')(__filename);
|
||||
|
||||
async function query(graphqlQuery, params) {
|
||||
async function query(graphqlQuery, params, role = 'query') {
|
||||
const pg = initPg(config.database[role]);
|
||||
|
||||
return withPostGraphileContext(pg, async (context) => {
|
||||
const schema = await pg.getGraphQLSchema();
|
||||
const result = await graphql(schema, graphqlQuery, null, context, params);
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
/* eslint-disable arrow-body-style */
|
||||
const config = require('config');
|
||||
|
||||
const { postgraphile } = require('postgraphile');
|
||||
|
||||
const PgConnectionFilterPlugin = require('postgraphile-plugin-connection-filter');
|
||||
@@ -11,41 +9,45 @@ const PgOrderByRelatedPlugin = require('@graphile-contrib/pg-order-by-related');
|
||||
|
||||
const { ActorPlugins, SitePlugins, ReleasePlugins, MediaPlugins } = require('./plugins/plugins');
|
||||
|
||||
const connectionString = `postgres://${config.database.query.user}:${config.database.query.password}@${config.database.query.host}:5432/${config.database.query.database}`;
|
||||
|
||||
async function pgSettings(req) {
|
||||
return {
|
||||
'user.id': req.session.user?.id || null, // undefined is passed as an empty string, avoid
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = postgraphile(
|
||||
connectionString,
|
||||
'public',
|
||||
{
|
||||
// watchPg: true,
|
||||
disableDefaultMutations: true,
|
||||
dynamicJson: true,
|
||||
graphiql: true,
|
||||
enhanceGraphiql: true,
|
||||
allowExplain: () => true,
|
||||
// simpleCollections: 'only',
|
||||
simpleCollections: 'both',
|
||||
graphileBuildOptions: {
|
||||
pgOmitListSuffix: true,
|
||||
connectionFilterRelations: true,
|
||||
connectionFilterAllowNullInput: true,
|
||||
function initPostgraphile(credentials) {
|
||||
const connectionString = `postgres://${credentials.user}:${credentials.password}@${credentials.host}:5432/${credentials.database}`;
|
||||
|
||||
return postgraphile(
|
||||
connectionString,
|
||||
'public',
|
||||
{
|
||||
// watchPg: true,
|
||||
disableDefaultMutations: true,
|
||||
dynamicJson: true,
|
||||
graphiql: true,
|
||||
enhanceGraphiql: true,
|
||||
allowExplain: () => true,
|
||||
// simpleCollections: 'only',
|
||||
simpleCollections: 'both',
|
||||
graphileBuildOptions: {
|
||||
pgOmitListSuffix: true,
|
||||
connectionFilterRelations: true,
|
||||
connectionFilterAllowNullInput: true,
|
||||
},
|
||||
appendPlugins: [
|
||||
PgSimplifyInflectorPlugin,
|
||||
PgConnectionFilterPlugin,
|
||||
PgOrderByRelatedPlugin,
|
||||
...ActorPlugins,
|
||||
...SitePlugins,
|
||||
...ReleasePlugins,
|
||||
...MediaPlugins,
|
||||
],
|
||||
pgSettings,
|
||||
},
|
||||
appendPlugins: [
|
||||
PgSimplifyInflectorPlugin,
|
||||
PgConnectionFilterPlugin,
|
||||
PgOrderByRelatedPlugin,
|
||||
...ActorPlugins,
|
||||
...SitePlugins,
|
||||
...ReleasePlugins,
|
||||
...MediaPlugins,
|
||||
],
|
||||
pgSettings,
|
||||
},
|
||||
pgSettings,
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = initPostgraphile;
|
||||
|
||||
@@ -13,7 +13,7 @@ const logger = require('../logger')(__filename);
|
||||
const knex = require('../knex');
|
||||
const errorHandler = require('./error');
|
||||
|
||||
const pg = require('./postgraphile');
|
||||
const initPg = require('./postgraphile');
|
||||
|
||||
const {
|
||||
login,
|
||||
@@ -83,7 +83,7 @@ async function initServer() {
|
||||
router.use(bodyParser.json({ strict: false }));
|
||||
router.use(session({ ...config.web.session, store }));
|
||||
|
||||
router.use(pg);
|
||||
router.use(initPg(config.database.query));
|
||||
|
||||
router.use((req, res, next) => {
|
||||
req.session.safeId = req.session.safeId || nanoid();
|
||||
|
||||
Reference in New Issue
Block a user