-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
36 lines (32 loc) · 982 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
require('dotenv').config()
require('./server')
const graphHelper = require('./graphHelper')
const subscriptions = require('./lib/subscriptions')
function initialize() {
console.log('Initializing...')
graphHelper.initialiseGraphForUserAuth(info => {
console.log(info.message)
})
}
function initializeSubscriptions() {
const userClient = graphHelper.getClient()
console.log('Initializing subscriptions...')
// subscriptions.EmailSubscription(userClient).register(process.env.ENDPOINT)
subscriptions.TeamsSubscription(userClient).register(process.env.ENDPOINT)
}
async function displayUserInfo() {
try {
const user = await graphHelper.getUserInfo()
console.log(`Hello, ${user.displayName}!`)
console.log(`Email: ${user.mail}`)
} catch (error) {
console.log(`Error getting user: ${error}`)
}
}
async function main() {
initialize()
// const token = await graphHelper.getUserToken()
displayUserInfo()
initializeSubscriptions()
}
main()