Skip to content

Commit

Permalink
fix: fixed firebase deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
favna committed Nov 3, 2019
1 parent 322f61d commit ea47780
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 25 deletions.
21 changes: 21 additions & 0 deletions src/graphql/server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import express from 'express';
import {ApolloServer} from 'apollo-server-express';
import {buildSchemaSync} from 'type-graphql';
import DexResolver from '../resolvers/DexResolver';

const gqlServer = () => {
const app = express();
const schema = buildSchemaSync({resolvers: [ DexResolver ]});

const apolloServer = new ApolloServer({
schema,
introspection: true,
playground: {endpoint: '/playground'},
});

apolloServer.applyMiddleware({app, path: '/', cors: true});

return app;
};

export default gqlServer;
36 changes: 11 additions & 25 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,16 @@
import 'reflect-metadata';
import * as functions from 'firebase-functions';
import express from 'express';
import {ApolloServer} from 'apollo-server-express';
import {buildSchemaSync} from 'type-graphql';
import DexResolver from './resolvers/DexResolver';

const schema = buildSchemaSync({resolvers: [ DexResolver ]});
const apolloServer = new ApolloServer({
schema,
playground: {endpoint: '/playground'},
});
const app = express();

apolloServer.applyMiddleware({app});

app.get('/', (_req, res) => {
return res.send('Looks like you hit a non-existing endpoint!');
});
import {https} from 'firebase-functions';
import gqlServer from './graphql/server';

// If we're not in the Cloud Functions environment, spin up a Node server
if (!process.env.FIREBASE_CONFIG) {
const PORT = process.env.PORT || 4000;
app.listen(PORT, () => {
console.log('server started on http://localhost:4000/graphql'); // eslint-disable-line no-console
});
}
// If (!process.env.FIREBASE_CONFIG) {
// Const PORT = process.env.PORT || 4000;
// App.listen(PORT, () => {
// Console.log('server started on http://localhost:4000/graphql'); // eslint-disable-line no-console
// });
// }

const server = gqlServer();

export const api = functions.https.onRequest(app);
export const api = https.onRequest(server);
export * from './client';

0 comments on commit ea47780

Please sign in to comment.