Merge pull request #90 from vulcanize/vdb-563-remove-postgraphile

(VDB-563) Remove Postgraphile bespoke code
This commit is contained in:
Rob Mulholand 2019-05-08 12:51:56 -05:00 committed by GitHub
commit c5cfa85f4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 33 additions and 5352 deletions

View File

@ -16,10 +16,7 @@ before_install:
before_script: before_script:
- sudo -u postgres createdb vulcanize_private - sudo -u postgres createdb vulcanize_private
- make migrate NAME=vulcanize_private - make migrate NAME=vulcanize_private
- cd postgraphile && yarn
script: script:
- yarn test
- cd ../
- make test - make test
- make integrationtest - make integrationtest
notifications: notifications:

View File

@ -127,7 +127,7 @@ Documentation on how to build custom transformers to work with these commands ca
- `make integrationtest` will run just the integration tests - `make integrationtest` will run just the integration tests
## API ## API
[Postgraphile](https://www.graphile.org/postgraphile/) is used to expose GraphQL endpoints for our database schemas, this is described in detail [here](../staging/postgraphile/README.md). [Postgraphile](https://www.graphile.org/postgraphile/) is used to expose GraphQL endpoints for our database schemas, this is described in detail [here](../staging/documentation/postgraphile.md).
## Contributing ## Contributing

View File

@ -0,0 +1,32 @@
# Postgraphile
You can expose VulcanizeDB data via [Postgraphile](https://github.com/graphile/postgraphile).
Check out [their documentation](https://www.graphile.org/postgraphile/) for the most up-to-date instructions on installing, running, and customizing Postgraphile.
## Simple Setup
As of April 30, 2019, you can run Postgraphile pointed at the default `vulcanize_public` database with the following commands:
```
npm install -g postgraphile
postgraphile --connection postgres://localhost/vulcanize_public --schema=public,custom --disable-default-mutations
```
Arguments:
- `--connection` specifies the database. The above command connects to the default `vulcanize_public` database defined in [the example config](../staging/environments/public.toml.example).
- `--schema` defines what schema(s) to expose. The above exposes the `public` schema (for core VulcanizeDB data) as well as a `custom` schema (where `custom` is the name of a schema defined in executed transformers).
- `--disable-default-mutations` prevents Postgraphile from exposing create, update, and delete operations on your data, which are otherwise enabled by default.
## Customizing Postgraphile
By default, Postgraphile will expose queries for all tables defined in your chosen database/schema(s), including [filtering](https://www.graphile.org/postgraphile/filtering/) and [auto-discovered relations](https://www.graphile.org/postgraphile/relations/).
If you'd like to expose more customized windows into your data, there are some techniques you can apply when writing migrations:
- [Computed columns](https://www.graphile.org/postgraphile/computed-columns/) enable you to derive additional fields from types defined in your database.
For example, you could write a function to expose a block header's state root over Postgraphile with a computed column - without modifying the `public.headers` table.
- [Custom queries](https://www.graphile.org/postgraphile/custom-queries/) enable you to provide on-demand access to more complex data (e.g. the product of joining and filtering several tables' data based on a passed argument).
For example, you could write a custom query to get the block timestamp for every transaction originating from a given address.
- [Subscriptions](https://www.graphile.org/postgraphile/subscriptions/) enable you to publish data as it is coming into your database.
The above list is not exhaustive - please see the Postgraphile documentation for a more comprehensive and up-to-date description of available features.

View File

@ -1,7 +0,0 @@
package-lock.json
yarn.lock
node_modules
Dockerfile
README.md
spec
.dockerignore

View File

@ -1,9 +0,0 @@
FROM mhart/alpine-node:10
RUN apk --update --no-cache add make g++ python findutils postgresql-dev
WORKDIR /app
COPY . /app
run yarn install
RUN ["./node_modules/typescript/bin/tsc"]
EXPOSE 3000
CMD ["node", "/app/build/dist/index.js"]

View File

@ -1,51 +0,0 @@
# Vulcanize GraphQL API
This application utilizes Postgraphile to expose GraphQL endpoints for exposure of the varied data that VulcanizeDB tracks.
## Docker use
_Note: currently this image is ~500MB large (unpacked)_
Build the docker image in this directory. Start the `GraphiQL` frontend by:
* Setting the env variables for the database connection: `DATABASE_HOST`,
`DATABASE_NAME`, `DATABASE_USER`, `DATABASE_PASSWORD` (and optionally
`DATABASE_PORT` if running on non-standard port).
* The specified user needs to be `superuser` on the vulcanizeDB database,
so postgraphile can setup watch fixtures keeping track of live schema
changes.
* To limit the amount of available queries in GraphQL, a restricted user can be used
for postgraphile introspection by adding env variables `GQ_USER` and `GQ_PASSWORD`.
* By doing `GRANT [SELECT | EXECUTE]` on tables/functions for this user,
you can selectively assign things you want available in GraphQL.
* You still need to pass in a superuser with `DATABASE_USER` & `DATABASE_PASSWORD` for
the postgraphile watch fixtures to work.
* By default, postgraphile publishes the `public` schema. This can be expanded with for example `GQ_SCHEMAS=public,maker`
* Run the container (ex. `docker run -e DATABASE_HOST=localhost -e DATABASE_NAME=my_database -e DATABASE_USER=superuser -e DATABASE_PASSWORD=superuser -e GQ_USER=graphql -e GQ_PASSWORD=graphql -e GQ_SCHEMAS=public,anotherSchema -d my-postgraphile-image`)
* GraphiQL frontend is available at `:3000/graphiql`
GraphQL endpoint is available at `:3000/graphql`
By default, this build will expose only the "public" schema and will disable mutations - to change mutation behaviour, you can use an optional config file `config.toml` and set the env var `POSTGRAPHILE_CONFIG_PATH` to point to its location. Example `toml`:
```
[database]
name = "vulcanize_public"
hostname = "localhost"
port = 5432
gq_schemas = ["public", "yourschema"]
gq_user = "graphql"
gq_password = "graphql"
disable_default_mutations = false
```
## Building
*This application assumes the use of the [Yarn package manager](https://yarnpkg.com/en/). The use of npm may produce unexpected results.*
Install dependencies with `yarn` and execute `yarn build`. The bundle produced by Webpack will be present in `build/dist/`.
## Running
Provide the built bundle to node as a runnable script: `node ./build/dist/vulcanize-postgraphile-server.js`
## Testing
Tests are executed via Jasmine with a console reporter via the `yarn test` task.

View File

@ -1,57 +0,0 @@
{
"name": "vulcanizedb",
"version": "1.0.0",
"description": "",
"scripts": {
"build": "rm -rf ./build/dist && webpack --config=./webpack.config.js",
"lint": "tslint --project ./tsconfig.json --config ./tslint.json",
"start": "npm run build && node ./build/dist/vulcanize-postgraphile-server.js",
"dev": "./node_modules/typescript/bin/tsc && node build/dist/src/index.js",
"test": "rm -rf ./build/spec && tsc --build ./tsconfig.test.json && jasmine --config=./spec/support/jasmine.json",
"test:ci": "npm run lint && npm run test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/vulcanize/vulcanizedb.git"
},
"author": "Vulcanize, Inc.",
"license": "AGPL-3.0",
"bugs": {
"url": "https://github.com/vulcanize/vulcanizedb/issues"
},
"homepage": "https://github.com/vulcanize/vulcanizedb",
"dependencies": {
"express-session": "1.15.6",
"graphql-subscriptions": "0.5.8",
"lodash": ">=4.17.11",
"passport": "0.4.0",
"pg": "6.4.2",
"pg-native": "3.0.0",
"postgraphile": "4.4.0-beta.11",
"subscriptions-transport-ws": "0.9.14",
"toml": "2.3.3"
},
"devDependencies": {
"@types/express": "4.16.0",
"@types/express-session": "1.15.10",
"@types/graphql": "^0.13.4",
"@types/jasmine": "2.8.8",
"@types/lodash": "4.14.116",
"@types/node": "^10.12.21",
"@types/passport": "0.4.6",
"@graphile-contrib/pg-simplify-inflector": "3.0.0",
"awesome-typescript-loader": "5.2.0",
"jasmine": "3.2.0",
"jasmine-ts-console-reporter": "3.1.1",
"source-map-loader": "0.2.4",
"tslint": "5.11.0",
"tslint-eslint-rules": "5.4.0",
"typescript": "3.0.1",
"webpack": "4.17.1",
"webpack-cli": "3.1.0",
"webpack-dev-server": ">=3.1.11"
},
"resolutions": {
"pg": "6.4.2"
}
}

View File

@ -1,79 +0,0 @@
import { parseConfig } from '../../src/config/parse';
describe('parseConfig', () => {
let configPath: string;
let tomlContents: string;
let parsedToml: object;
let readCallback: jasmine.Spy;
let tomlParseCallback: jasmine.Spy;
beforeEach(() => {
configPath = '/example/config/path.toml';
tomlContents = `[database]\nname = 'example_database'\n `
+ `hostname = 'example.com'\nport = 1234`;
parsedToml = {
database: {
hostname: 'example.com',
name: 'example_database',
port: '1234',
user: 'user',
password: 'password'
}
};
readCallback = jasmine.createSpy('readCallback');
readCallback.and.returnValue(tomlContents);
tomlParseCallback = jasmine.createSpy('tomlParseCallback');
tomlParseCallback.and.returnValue(parsedToml);
});
it('provides the database host', () => {
const databaseConfig = parseConfig(
readCallback, tomlParseCallback, configPath);
expect(databaseConfig.host)
.toEqual('postgres://user:password@example.com:1234');
});
it('provides the database name', () => {
const databaseConfig = parseConfig(
readCallback, tomlParseCallback, configPath);
expect(databaseConfig.database).toEqual('example_database');
});
it('handles a missing config path', () => {
const failingCall = () =>
parseConfig(readCallback, tomlParseCallback, '');
tomlParseCallback.and.returnValue({
database: { hostname: 'example.com', name: 'example_database' }
});
expect(failingCall).toThrow();
});
it('handles a missing database host', () => {
const failingCall = () =>
parseConfig(readCallback, tomlParseCallback, configPath);
tomlParseCallback.and.returnValue({
database: { hostname: '', name: 'example_database' }
});
expect(failingCall).toThrow();
});
it('handles a missing database name', () => {
const failingCall = () =>
parseConfig(readCallback, tomlParseCallback, configPath);
tomlParseCallback.and.returnValue({
database: { hostname: 'example.com', name: '', port: '1234' }
});
expect(failingCall).toThrow();
});
});

View File

@ -1,7 +0,0 @@
// NOTE: This file helps Jasmine
// comprehend TS sourcemaps by installing a reporter
// specifically for TypeScript
const TSConsoleReporter = require('jasmine-ts-console-reporter');
jasmine.getEnv().clearReporters();
jasmine.getEnv().addReporter(new TSConsoleReporter());

View File

@ -1,106 +0,0 @@
import { PassportStatic } from 'passport';
import { PostgraphileMiddleware } from '../../src/adapters/postgraphile';
import { buildServerConfig } from '../../src/server/config';
import {
DatabaseConfig,
ServerConfig,
ServerUtilities
} from '../../src/server/interface';
describe('buildServerConfig', () => {
let configParser: jasmine.Spy;
let postgraphileMiddleware: PostgraphileMiddleware;
let expressSessionHandler: jasmine.Spy;
let passportInitializer: jasmine.Spy;
let passportSessionHandler: jasmine.Spy;
let serverConfig: ServerConfig;
let serverUtilities: ServerUtilities;
let databaseConfig: DatabaseConfig;
beforeEach(() => {
databaseConfig = {
host: 'example.com',
database: 'example_database',
schemas: ['public'],
ownerConnectionString: 'postgres://admin:admin@host',
disableDefaultMutations: true
};
postgraphileMiddleware = jasmine
.createSpyObj<PostgraphileMiddleware>(['call']);
serverUtilities = {
pluginHook: jasmine.createSpy('pluginHook'),
express: jasmine.createSpy('express'),
expressSession: jasmine.createSpy('expressSession'),
httpServerFactory: jasmine.createSpy('httpServerFactory'),
passport: jasmine.createSpyObj<PassportStatic>(['initialize', 'session']),
postgraphile: jasmine.createSpy('postgraphile')
};
const rawConfig: object = { exampleOption: 'example value' };
configParser = jasmine.createSpy('configParser');
configParser.and.returnValue(rawConfig);
expressSessionHandler = jasmine.createSpy('expressSessionHandler');
passportInitializer = jasmine.createSpy('passportInitializer');
passportSessionHandler = jasmine.createSpy('passportSessionHandler');
(serverUtilities.postgraphile as jasmine.Spy)
.and.returnValue(postgraphileMiddleware);
(serverUtilities.expressSession as jasmine.Spy)
.and.returnValue(expressSessionHandler);
(serverUtilities.passport.initialize as jasmine.Spy)
.and.returnValue(passportInitializer);
(serverUtilities.passport.session as jasmine.Spy)
.and.returnValue(passportSessionHandler);
serverConfig = buildServerConfig(
serverUtilities, databaseConfig, undefined);
});
it('provides the Postgraphile options', () => {
expect(serverConfig.options).not.toBeNull();
});
it('it adds the express session handler as the first middleware', () => {
expect(serverConfig.options.webSocketMiddlewares[0])
.toBe(expressSessionHandler);
});
it('it adds the passport initializer as the second middleware', () => {
expect(serverConfig.options.webSocketMiddlewares[1])
.toBe(passportInitializer);
});
it('it adds the passport session handler as the third middleware', () => {
expect(serverConfig.options.webSocketMiddlewares[2])
.toBe(passportSessionHandler);
});
it('provides the database config to Postgraphile', () => {
expect(serverUtilities.postgraphile).toHaveBeenCalledWith(
`${databaseConfig.host}/${databaseConfig.database}`,
databaseConfig.schemas,
jasmine.any(Object));
});
it('provides the Postgraphile middleware', () => {
expect(serverConfig.middleware).toBe(postgraphileMiddleware);
});
it('sets the default server port', () => {
expect(serverConfig.port).toEqual(3000);
});
it('sets an explicit server port', () => {
const serverConfigWithPort = buildServerConfig(
serverUtilities, databaseConfig, '1234');
expect(serverConfigWithPort.port).toEqual(1234);
});
});

View File

@ -1,66 +0,0 @@
import { Express } from 'express';
import { PassportStatic } from 'passport';
import { Server } from 'http';
import { ServerUtilities, ServerConfig } from '../../src/server/interface';
import { bootServer } from '../../src/server/runtime';
import { PostgraphileMiddleware } from '../../src/adapters/postgraphile';
describe('bootServer', () => {
let serverUtilities: ServerUtilities;
let serverConfig: ServerConfig;
let mockExpressApp: Express;
let mockHttpServer: Server;
beforeEach(() => {
serverUtilities = {
pluginHook: jasmine.createSpy('pluginHook'),
express: jasmine.createSpy('express'),
expressSession: jasmine.createSpy('expressSession'),
httpServerFactory: jasmine.createSpy('httpServerFactory'),
passport: jasmine.createSpyObj<PassportStatic>(['initialize', 'session']),
postgraphile: jasmine.createSpy('postgraphile')
};
serverConfig = {
middleware: jasmine.createSpyObj<PostgraphileMiddleware>(['call']),
options: {
appendPlugins: [],
disableDefaultMutations: false,
enableCors: true,
exportGqlSchemaPath: '',
graphiql: true,
ignoreRBAC: false,
ownerConnectionString: '',
pluginHook: jasmine.createSpy('pluginHook'),
watchPg: true,
webSocketMiddlewares: [] },
port: 5678
};
mockExpressApp = jasmine.createSpyObj<Express>(['use']);
(serverUtilities.express as jasmine.Spy)
.and.returnValue(mockExpressApp);
mockHttpServer = jasmine.createSpyObj<Server>(['listen']);
(serverUtilities.httpServerFactory as jasmine.Spy)
.and.returnValue(mockHttpServer);
bootServer(serverUtilities, serverConfig);
});
it('builds a new, Node HTTP server', () => {
expect(serverUtilities.httpServerFactory)
.toHaveBeenCalledWith(mockExpressApp);
});
it('provides Postgraphile middleware to the Express app', () => {
const useSpy = mockExpressApp.use as jasmine.Spy;
expect(useSpy).toHaveBeenCalledWith(serverConfig.middleware);
});
it('instructs the server to listen on the given port', () => {
const listenSpy = mockHttpServer.listen as jasmine.Spy;
expect(listenSpy).toHaveBeenCalledWith(serverConfig.port);
});
});

View File

@ -1,11 +0,0 @@
{
"spec_dir": "build/spec/",
"spec_files": [
"**/*[sS]pec.js"
],
"helpers": [
"helpers/*.js"
],
"stopSpecOnExpectationFailure": false,
"random": true
}

View File

@ -1,11 +0,0 @@
import { URL } from 'url';
export type ReadFileSyncCallback = (
path: string | number | Buffer | URL,
options?: { encoding?: null | undefined; flag?: string | undefined; }
| null
| undefined
) => string | Buffer;
export type TomlParseCallback
= (fileContents: string) => { [key: string]: { [key: string]: any } };

View File

@ -1,7 +0,0 @@
import { IncomingMessage, ServerResponse, Server } from 'http';
export type RequestListenerCallback
= (request: IncomingMessage, response: ServerResponse) => void;
export type CreateHttpServerCallback
= (requestListener?: RequestListenerCallback) => Server;

View File

@ -1,32 +0,0 @@
import { RequestHandler } from 'express';
import {PluginHookFn } from 'postgraphile/build/postgraphile/pluginHook';
import {Plugin} from 'postgraphile';
// NOTE: Shape of the middleware is not
// currently important to this application, but if a need arises,
// any needed shape can be assigned from a custom type here. For
// the time being, this is a named stub to provide clarity.
export interface PostgraphileMiddleware extends RequestHandler {}
export interface PostgraphileOptions {
appendPlugins: Plugin[];
disableDefaultMutations: boolean;
enableCors: boolean;
exportGqlSchemaPath: string;
graphiql: boolean;
ignoreRBAC: boolean;
ownerConnectionString: string;
pluginHook: PluginHookFn;
watchPg: boolean;
// NOTE Shape of the middlewares is not
// currently important to this application, but if a need arises,
// any needed shape can be assigned from a custom type here.
webSocketMiddlewares: object[];
}
export type PostgraphileInitCallback = (
databaseUrl: string,
schemas: string[],
options: PostgraphileOptions
) => PostgraphileMiddleware;

View File

@ -1,20 +0,0 @@
import { SessionOptions } from 'express-session';
import { Express, RequestHandler, Handler } from 'express';
export type ExpressInitCallback = () => Express;
export type ExpressSessionInitCallback
= (options?: SessionOptions) => RequestHandler ;
export type PassportInitCallback = (
options?: { userProperty: string; } | undefined
) => Handler;
export type PassportSessionCallback = (
options?: { pauseStream: boolean; } | undefined
) => Handler;
export interface StaticPassportProvider {
initialize: PassportInitCallback;
session: PassportSessionCallback;
}

View File

@ -1,79 +0,0 @@
import { CONFIG_PATH_KEY } from '../server/config';
import { DatabaseConfig } from '../server/interface';
import { ReadFileSyncCallback, TomlParseCallback } from '../adapters/fs';
export const MISSING_PATH_MESSAGE = `No path to config toml file provided, `
+ `please check the value of ${CONFIG_PATH_KEY} in your environment`;
export const MISSING_HOST_MESSAGE = 'No database host provided in config toml';
export const MISSING_USER_MESSAGE = 'No database user & password '
+ 'provided in config toml';
export const MISSING_DATABASE_MESSAGE = 'No database name provided '
+ 'in config toml';
export function parseConfig(
readCallback: ReadFileSyncCallback,
tomlParseCallback: TomlParseCallback,
configPath?: string
): DatabaseConfig {
let host = '';
let port = '';
let database = '';
let user = '';
let password = '';
let gqSchemas = ['public'];
let gqUser = '';
let gqPassword = '';
let disableDefaultMutations = true;
if (configPath) {
const tomlContents = readCallback(`${configPath}`).toString();
const parsedToml = tomlParseCallback(tomlContents);
host = parsedToml['database']['hostname'];
port = parsedToml['database']['port'];
database = parsedToml['database']['name'];
user = parsedToml['database']['user'];
password = parsedToml['database']['password'];
gqSchemas = parsedToml['database']['gq_schemas'];
gqUser = parsedToml['database']['gq_user'] || gqUser;
gqPassword = parsedToml['database']['gq_password'] || gqPassword;
disableDefaultMutations = parsedToml['database']['disable_default_mutations'] === undefined
? true
: parsedToml['database']['disable_default_mutations'];
}
// Overwrite config values with env. vars if such are set
host = process.env.DATABASE_HOST || host;
port = process.env.DATABASE_PORT || port;
database = process.env.DATABASE_NAME || database;
user = process.env.DATABASE_USER || user;
password = process.env.DATABASE_PASSWORD || password;
gqSchemas = process.env.GQ_SCHEMAS
? process.env.GQ_SCHEMAS.split(',')
: gqSchemas;
gqUser = process.env.GQ_USER || gqUser;
gqPassword = process.env.GQ_PASSWORD || gqPassword;
if (!host) {
throw new Error(MISSING_HOST_MESSAGE);
}
if (!database) {
throw new Error(MISSING_DATABASE_MESSAGE);
}
if (!user || !password) {
throw new Error(MISSING_USER_MESSAGE);
}
return {
host: gqUser && gqPassword
? `postgres://${gqUser}:${gqPassword}@${host}:${port}`
: `postgres://${user}:${password}@${host}:${port}`,
database,
schemas: gqSchemas,
ownerConnectionString: `postgres://${user}:${password}@${host}:${port}/${database}`,
disableDefaultMutations
};
}

View File

@ -1,38 +0,0 @@
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 pluginHook = makePluginHook([]);
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 = {
express,
expressSession: session,
httpServerFactory: createServer,
passport,
postgraphile,
pluginHook
};
const databaseConfig = parseConfig(readFileSync, toml.parse, configPath);
const serverConfig = buildServerConfig(
serverUtilities, databaseConfig, serverPort);
bootServer(serverUtilities, serverConfig);

View File

@ -1,52 +0,0 @@
import { ServerUtilities, DatabaseConfig, ServerConfig } from './interface';
import {
PostgraphileMiddleware,
PostgraphileOptions
} from '../adapters/postgraphile';
export const CONFIG_PATH_KEY = 'POSTGRAPHILE_CONFIG_PATH';
export const SERVER_PORT_KEY = 'SERVER_PORT';
const DEFAULT_SERVER_PORT = '3000';
export function buildServerConfig(
utilities: ServerUtilities,
databaseConfig: DatabaseConfig,
port?: string
): ServerConfig {
if (!port || port.length < 1) {
port = DEFAULT_SERVER_PORT;
}
const expressSessionHandler = utilities.expressSession();
const passportInitializer = utilities.passport.initialize();
const passportSessionHandler = utilities.passport.session();
const pluginHook = utilities.pluginHook;
const PgSimplifyInflectorPlugin = require('@graphile-contrib/pg-simplify-inflector');
const options: PostgraphileOptions = {
appendPlugins: [PgSimplifyInflectorPlugin],
disableDefaultMutations: databaseConfig.disableDefaultMutations,
enableCors: true,
exportGqlSchemaPath: 'schema.graphql',
graphiql: true,
ignoreRBAC: false,
ownerConnectionString: databaseConfig.ownerConnectionString,
pluginHook: pluginHook,
watchPg: true,
webSocketMiddlewares: [
expressSessionHandler,
passportInitializer,
passportSessionHandler
]
};
const middleware: PostgraphileMiddleware = utilities.postgraphile(
`${databaseConfig.host}/${databaseConfig.database}`,
databaseConfig.schemas,
options
);
return { middleware, options, port: parseInt(port, 10) };
}

View File

@ -1,37 +0,0 @@
import { CreateHttpServerCallback } from '../adapters/http';
import {
ExpressInitCallback,
ExpressSessionInitCallback,
StaticPassportProvider
} from '../adapters/session';
import {
PostgraphileInitCallback,
PostgraphileMiddleware,
PostgraphileOptions
} from '../adapters/postgraphile';
import { PluginHookFn } from 'postgraphile/build/postgraphile/pluginHook';
export interface DatabaseConfig {
host: string;
database: string;
schemas: string[];
ownerConnectionString: string;
disableDefaultMutations: boolean;
}
export interface ServerConfig {
middleware: PostgraphileMiddleware;
options: PostgraphileOptions;
port: number;
}
export interface ServerUtilities {
express: ExpressInitCallback;
expressSession: ExpressSessionInitCallback;
httpServerFactory: CreateHttpServerCallback;
passport: StaticPassportProvider;
postgraphile: PostgraphileInitCallback;
pluginHook: PluginHookFn;
}

View File

@ -1,13 +0,0 @@
import { ServerUtilities, ServerConfig } from './interface';
export function bootServer(
utilities: ServerUtilities,
config: ServerConfig
): void {
const expressApp = utilities.express();
expressApp.use(config.middleware);
const httpServer = utilities.httpServerFactory(expressApp);
httpServer.listen(config.port);
}

View File

@ -1,54 +0,0 @@
{
"compilerOptions": {
/* Basic Options */
"target": "es2017", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"lib": ["esnext"], /* Specify library files to be included in the compilation: */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
"jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
"sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "build/dist", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
"removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
/* Source Map Options */
// "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
}
}

View File

@ -1,54 +0,0 @@
{
"compilerOptions": {
/* Basic Options */
"target": "es2017", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"lib": ["esnext"], /* Specify library files to be included in the compilation: */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
"jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
"sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "build/spec", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
"removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
/* Source Map Options */
// "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
}
}

View File

@ -1,93 +0,0 @@
{
"extends": [
"tslint-eslint-rules"
],
"rules": {
"object-curly-spacing": true,
"ter-indent": [true, 2],
"array-bracket-spacing": ["error", "never"],
"class-name": true,
"comment-format": [
true,
"check-space"
],
"curly": [true, "ignore-same-line"],
"eofline": true,
"forin": true,
"indent": [
true,
"spaces"
],
"label-position": true,
"max-line-length": [
true,
80
],
"member-access": [true, "no-public"],
"member-ordering": [true, { "order": "statics-first" }],
"no-arg": true,
"no-bitwise": true,
"no-console": [
true,
"debug",
"info",
"time",
"timeEnd",
"trace"
],
"no-consecutive-blank-lines": true,
"no-construct": true,
"no-debugger": true,
"no-duplicate-variable": true,
"no-empty": false,
"no-eval": true,
"no-inferrable-types": true,
"no-shadowed-variable": false,
"no-string-literal": false,
"no-switch-case-fall-through": true,
"no-trailing-whitespace": false,
"no-unused-expression": false,
"no-use-before-declare": true,
"no-var-keyword": false,
"object-literal-sort-keys": false,
"one-line": [
true,
"check-open-brace",
"check-whitespace"
],
"quotemark": [
true,
"single"
],
"radix": true,
"semicolon": true,
"triple-equals": [
true,
"allow-null-check"
],
"typedef-whitespace": [
true,
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
}
],
"variable-name": false,
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type"
],
"use-host-property-decorator": false,
"no-access-missing-member": false,
"templates-use-public": false,
"brace-style": false
}
}

View File

@ -1,20 +0,0 @@
module.exports = {
entry: "./src/index.ts",
mode: "production",
devtool: "source-map",
target: 'node',
output: {
filename: "vulcanize-postgraphile-server.js",
path: __dirname + "/build/dist/",
publicPath: "build/dist/"
},
resolve: {
extensions: [".ts", ".tsx", ".mjs", ".js", ".json", ".css", ".png"]
},
module: {
rules: [
{ test: /\.ts$/, loader: "awesome-typescript-loader" },
{ enforce: "pre", test: /\.js$/, loader: "source-map-loader" }
]
}
};

File diff suppressed because it is too large Load Diff