Skip to content

Commit

Permalink
Exposing server for use in integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonyhastings committed Aug 1, 2022
1 parent 2f2ce74 commit 6b9ef49
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
4 changes: 2 additions & 2 deletions server/src/index.mts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'dotenv/config';
import startServer from './server.mjs';
import { startServer } from './server.mjs';

const { url } = await startServer();
const url = await startServer();

console.log(`
🚀 Server is running!
Expand Down
21 changes: 9 additions & 12 deletions server/src/server.mts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,15 @@ import { ApolloServerPluginInlineTrace } from 'apollo-server-core';
import DummyAPI from './contexts/dummy-api.mjs';
import schema from './schema.mjs';

const startServer = async () => {
const server = new ApolloServer({
dataSources: () => ({
dummyAPI: new DummyAPI(),
}),
plugins: [ApolloServerPluginInlineTrace()],
schema,
});
export const server = new ApolloServer({
dataSources: () => ({
dummyAPI: new DummyAPI(),
}),
plugins: [ApolloServerPluginInlineTrace()],
schema,
});

export const startServer = async () => {
const { url } = await server.listen({ port: process.env.APOLLO_PORT });

return { server, url };
return url;
};

export default startServer;

0 comments on commit 6b9ef49

Please sign in to comment.