-
Notifications
You must be signed in to change notification settings - Fork 30
/
index.js
51 lines (43 loc) · 1.66 KB
/
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
43
44
45
46
47
48
49
50
51
require('dotenv').config()
const path = require('path')
const routes = require('./src/routes')
const lti = require('ltijs').Provider
// Setup
lti.setup(process.env.LTI_KEY,
{
url: 'mongodb://' + process.env.DB_HOST + '/' + process.env.DB_NAME + '?authSource=admin',
connection: { user: process.env.DB_USER, pass: process.env.DB_PASS }
}, {
staticPath: path.join(__dirname, './public'), // Path to static files
cookies: {
secure: false, // Set secure to true if the testing platform is in a different domain and https is being used
sameSite: '' // Set sameSite to 'None' if the testing platform is in a different domain and https is being used
},
devMode: true // Set DevMode to true if the testing platform is in a different domain and https is not being used
})
// When receiving successful LTI launch redirects to app
lti.onConnect(async (token, req, res) => {
return res.sendFile(path.join(__dirname, './public/index.html'))
})
// When receiving deep linking request redirects to deep screen
lti.onDeepLinking(async (token, req, res) => {
return lti.redirect(res, '/deeplink', { newResource: true })
})
// Setting up routes
lti.app.use(routes)
// Setup function
const setup = async () => {
await lti.deploy({ port: process.env.PORT })
/**
* Register platform
*/
/* await lti.registerPlatform({
url: 'http://localhost/moodle',
name: 'Platform',
clientId: 'CLIENTID',
authenticationEndpoint: 'http://localhost/moodle/mod/lti/auth.php',
accesstokenEndpoint: 'http://localhost/moodle/mod/lti/token.php',
authConfig: { method: 'JWK_SET', key: 'http://localhost/moodle/mod/lti/certs.php' }
}) */
}
setup()