This commit is contained in:
Nathan Bierema 2022-06-12 21:13:16 -04:00
parent 1948431289
commit d4cf84c37a
3 changed files with 10 additions and 9 deletions

View File

@ -1,8 +1,8 @@
import path from 'path'; import path from 'path';
import knexModule, { Knex } from 'knex'; import knexModule, { Knex } from 'knex';
import { SCServer } from 'socketcluster-server'; import { AGServer } from 'socketcluster-server';
export default function connector(options: SCServer.SCServerOptions) { export default function connector(options: AGServer.AGServerOptions) {
const dbOptions = options.dbOptions as Knex.Config; const dbOptions = options.dbOptions as Knex.Config;
dbOptions.useNullAsDefault = true; dbOptions.useNullAsDefault = true;
if (!(dbOptions as any).migrate) { if (!(dbOptions as any).migrate) {

View File

@ -5,7 +5,7 @@ import morgan from 'morgan';
import * as http from 'http'; import * as http from 'http';
import bodyParser from 'body-parser'; import bodyParser from 'body-parser';
import cors from 'cors'; import cors from 'cors';
import { SCServer } from 'socketcluster-server'; import { AGServer } from 'socketcluster-server';
import { ApolloServer } from 'apollo-server-express'; import { ApolloServer } from 'apollo-server-express';
import { AddData, ReportBaseFields, Store } from './store'; import { AddData, ReportBaseFields, Store } from './store';
import { resolvers, schema } from './api/schema'; import { resolvers, schema } from './api/schema';
@ -21,9 +21,9 @@ function serveUmdModule(name: string) {
} }
function routes( function routes(
options: SCServer.SCServerOptions, options: AGServer.AGServerOptions,
store: Store, store: Store,
scServer: SCServer scServer: AGServer
): Router { ): Router {
const limit = options.maxRequestBody; const limit = options.maxRequestBody;
const logHTTPRequests = options.logHTTPRequests; const logHTTPRequests = options.logHTTPRequests;
@ -65,7 +65,8 @@ function routes(
serveUmdModule('@redux-devtools/app'); serveUmdModule('@redux-devtools/app');
app.get('/port.js', function (req, res) { app.get('/port.js', function (req, res) {
res.send(`reduxDevToolsPort = ${options.port!}`); // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
res.send(`reduxDevToolsPort = ${options.port}`);
}); });
app.get('*', function (req, res) { app.get('*', function (req, res) {
res.sendFile(path.join(__dirname, '../app/index.html')); res.sendFile(path.join(__dirname, '../app/index.html'));
@ -108,7 +109,7 @@ function routes(
id: (r as ReportBaseFields).id, id: (r as ReportBaseFields).id,
error: (r as { error: string }).error, error: (r as { error: string }).error,
}); });
scServer.exchange.publish('report', { scServer.exchange.transmitPublish('report', {
type: 'add', type: 'add',
data: r, data: r,
}); });

View File

@ -1,6 +1,6 @@
import { v4 as uuidV4 } from 'uuid'; import { v4 as uuidV4 } from 'uuid';
import pick from 'lodash/pick'; import pick from 'lodash/pick';
import { SCServer } from 'socketcluster-server'; import { AGServer } from 'socketcluster-server';
import { Knex } from 'knex'; import { Knex } from 'knex';
import connector from './db/connector'; import connector from './db/connector';
@ -139,7 +139,7 @@ export interface Store {
add: (data: AddData) => Promise<ReportBaseFields | { error: string }>; add: (data: AddData) => Promise<ReportBaseFields | { error: string }>;
} }
function createStore(options: SCServer.SCServerOptions): Store { function createStore(options: AGServer.AGServerOptions): Store {
knex = connector(options); knex = connector(options);
return { return {