-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
40 lines (31 loc) · 945 Bytes
/
index.js
File metadata and controls
40 lines (31 loc) · 945 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const {connectDB} = require('./src/db/db');
const { ApolloServer } = require('apollo-server');
const {colors} = require('colors');
const dotenv = require('dotenv');
dotenv.config({path: './.env'});
const resolvers = require('./src/resolvers');
const typeDefs = require('./src/schema');
const {createModel} = require('./src/models/Pokemon');
const PokemonAPI = require('./src/datasources/pokemon');
const store = createModel();
const createServer = async () => {
try {
const server = new ApolloServer({
typeDefs,
resolvers,
dataSources: () => ({
pokemonAPI: new PokemonAPI({store})
})
// context: () => {
// return {models: {store}}
// }
});
const {url} = await server.listen();
console.log(`🚀 Server ready at ${url}`.green);
} catch (error) {
console.error(`Server initialization failed!`.red);
console.error(error);
}
};
connectDB();
createServer();