-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
42 lines (37 loc) · 980 Bytes
/
index.js
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
41
42
require("module-alias/register");
require("dotenv").config();
const { ApolloServer } = require("apollo-server");
const typeDefs = require("spent/config/apollo/schema");
const resolvers = require("spent/config/apollo/resolvers");
const { getUserFromToken } = require("spent/api/auth");
const { Budget, Plan, Category, ImportSchema } = require("spent/db/models");
const importers = require("spent/api/importers");
const server = new ApolloServer({
typeDefs,
resolvers,
dataSources: () => ({
budget: Budget,
plan: Plan,
category: Category,
importSchema: ImportSchema,
importers
}),
context: ({ req }) => {
let token = null;
let user = null;
token = req.headers.authorization;
console.log(token);
user = getUserFromToken(token);
return {
token,
user
};
},
uploads: {
maxFileSize: 10000000,
maxFiles: 20
}
});
server.listen().then(({ url }) => {
console.log(`🚀 Server ready at ${url}`);
});