forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
89 lines (83 loc) · 2 KB
/
index.js
File metadata and controls
89 lines (83 loc) · 2 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import './src/env'
import { ensure } from 'arango-tools'
import { Server } from './src/server'
import { databaseOptions } from './database-options'
import Redis from 'ioredis'
import { RedisPubSub } from 'graphql-redis-subscriptions'
const {
PORT = 4000,
DB_PASS: rootPass,
DB_URL: url,
DB_NAME: databaseName,
DEPTH_LIMIT: maxDepth,
COST_LIMIT: complexityCost,
SCALAR_COST: scalarCost,
OBJECT_COST: objectCost,
LIST_FACTOR: listFactor,
TRACING_ENABLED: tracing,
REDIS_PORT_NUMBER,
REDIS_DOMAIN_NAME,
} = process.env
;(async () => {
const { query, collections, transaction } = await ensure({
type: 'database',
name: databaseName,
url,
rootPassword: rootPass,
options: databaseOptions({ rootPass }),
})
// Connect With Redis
const options = {
host: REDIS_DOMAIN_NAME,
port: REDIS_PORT_NUMBER,
}
const pubsubs = {
dkimPubSub: new RedisPubSub({
publisher: new Redis(options),
subscriber: new Redis(options),
}),
dmarcPubSub: new RedisPubSub({
publisher: new Redis(options),
subscriber: new Redis(options),
}),
spfPubSub: new RedisPubSub({
publisher: new Redis(options),
subscriber: new Redis(options),
}),
httpsPubSub: new RedisPubSub({
publisher: new Redis(options),
subscriber: new Redis(options),
}),
sslPubSub: new RedisPubSub({
publisher: new Redis(options),
subscriber: new Redis(options),
}),
}
const server = await Server({
arango: {
db: databaseName,
url,
as: {
username: 'root',
password: rootPass,
},
},
maxDepth,
complexityCost,
scalarCost,
objectCost,
listFactor,
tracing,
context: {
query,
collections,
transaction,
pubsubs,
},
})
await server.listen(PORT, (err) => {
if (err) throw err
console.log(`🚀 Server ready at http://localhost:${PORT}/graphql`)
console.log(`🚀 Subscriptions ready at ws://localhost:${PORT}/graphql`)
})
})()