Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import express from 'express'
import postgraphile from 'postgraphile'
// import PluginName from './plugins/PluginName'
// const plugins = [
// PluginName
// ]
const app = express()
const pgConnectionString = process.env.DB_URI
const pgSchemas = process.env.POSTGRAPHILE_SCHEMAS.split(',')
const pgOptions = JSON.parse(process.env.POSTGRAPHILE_OPTIONS)
// pgOptions.appendPlugins = plugins
app.use(postgraphile(pgConnectionString, pgSchemas, pgOptions))
app.listen(3000, '0.0.0.0', function () {
console.info('NODE_ENV: ' + process.env.NODE_ENV)
console.info('Postgraphile API started.\n')
})
export default async function startApp(options = {}) {
const app = new Koa();
app.use(requestLogger(logger));
app.use(handleErrors(options));
const pgqlOpts = setPGQLOpts(options);
const pgPool = createPgPool(options, pgqlOpts);
await startSchemaWatcher(pgPool, 'public', pgqlOpts);
app.use(postgraphile(pgPool, 'public', pgqlOpts));
app.use(cors());
app.use(bodyParser());
app.use(cookie());
// load any user defined middleware
const middleware = load('middleware', { options, default: () => {} });
if (middleware.default) {
middleware.default({ app, logger, options });
}
app.use(appManifest(options));
if (!options.disableWebpack) {
// eslint-disable-next-line global-require
await require('../config/webpack.dev').default(app, options);
}