@@ -5,8 +5,6 @@ import * as mongo from './mongo';
55import * as rabbitmq from './rabbitmq' ;
66import jwt , { Secret } from 'jsonwebtoken' ;
77import http from 'http' ;
8- import { initializeStrategies } from './passport' ;
9- import { authRouter } from './auth' ;
108import resolvers from './resolvers' ;
119import typeDefs from './typeDefs' ;
1210import { ExpressContext } from 'apollo-server-express/dist/ApolloServer' ;
@@ -16,7 +14,6 @@ import { GraphQLError } from 'graphql';
1614import WorkspacesFactory from './models/workspacesFactory' ;
1715import DataLoaders from './dataLoaders' ;
1816import HawkCatcher from '@hawk.so/nodejs' ;
19- import { express as voyagerMiddleware } from 'graphql-voyager/middleware' ;
2017import bodyParser from 'body-parser' ;
2118
2219import UploadImageDirective from './directives/uploadImageDirective' ;
@@ -82,10 +79,7 @@ class HawkAPI {
8279 } ) ;
8380 this . app . use ( express . json ( ) ) ;
8481 this . app . use ( bodyParser . urlencoded ( { extended : false } ) ) ;
85- this . app . use ( '/uploads' , express . static ( `./${ process . env . UPLOADS_DIR || 'uploads' } ` ) ) ;
8682 this . app . use ( '/static' , express . static ( `./static` ) ) ;
87- this . app . use ( '/voyager' , voyagerMiddleware ( { endpointUrl : '/graphql' } ) ) ;
88- this . app . use ( authRouter ) ;
8983
9084 /**
9185 * Add context to the express request object to use its methods in any requests
@@ -95,8 +89,6 @@ class HawkAPI {
9589 next ( ) ;
9690 } ) ;
9791
98- initializeStrategies ( ) ;
99-
10092 this . server = new ApolloServer ( {
10193 typeDefs,
10294 debug : process . env . NODE_ENV === 'development' ,
@@ -112,11 +104,6 @@ class HawkAPI {
112104 validate : ValidateDirective ,
113105 requireUserInWorkspace : RequireUserInWorkspaceDirective ,
114106 } ,
115- subscriptions : {
116- path : '/subscriptions' ,
117- onConnect : ( connectionParams ) : { headers : { authorization : string } } =>
118- HawkAPI . onWebSocketConnection ( connectionParams as Record < string , string > ) ,
119- } ,
120107 context : ( { req } ) : ResolverContextBase => req . context ,
121108 formatError : ( error ) : GraphQLError => {
122109 if ( error . originalError instanceof NonCriticalError ) {
@@ -214,21 +201,6 @@ class HawkAPI {
214201 } ;
215202 }
216203
217- /**
218- * Fires when coming new Websocket connection
219- * Returns authorization headers for building request context
220- * @param connectionParams - websocket connection params (actually, headers only)
221- * @return - context for subscription request
222- */
223- private static onWebSocketConnection ( connectionParams : Record < string , string > ) : { headers : { authorization : string } } {
224- return {
225- headers : {
226- authorization :
227- connectionParams [ 'authorization' ] || connectionParams [ 'Authorization' ] ,
228- } ,
229- } ;
230- }
231-
232204 /**
233205 * Start API server
234206 */
@@ -242,10 +214,6 @@ class HawkAPI {
242214 `🚀 Server ready at http://localhost:${ this . serverPort } ${ this . server . graphqlPath
243215 } `
244216 ) ;
245- console . log (
246- `🚀 Subscriptions ready at ws://localhost:${ this . serverPort } ${ this . server . subscriptionsPath
247- } `
248- ) ;
249217 resolve ( ) ;
250218 } ) ;
251219 } ) ;
0 commit comments