-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathserver.js
More file actions
35 lines (28 loc) · 1.08 KB
/
server.js
File metadata and controls
35 lines (28 loc) · 1.08 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
'use strict';
const
d2l = require('valence'),
express = require('express'),
bodyParser = require('body-parser'),
cookieParser = require('cookie-parser'),
configs = require('./src/configurations'),
path = require('path'),
app = express();
app.use(bodyParser.urlencoded({ extended: true }));
app.use(cookieParser());
// Setup the initial D2L context object using the configured instance settings.
const appContext = new d2l.ApplicationContext(configs.instanceUrl, configs.applicationId, configs.applicationKey);
// Import Authorization
app.use(require('./src/authorization/oauth.js')());
// Import Sample API Calls
app.use(require('./src/apis/whoami')(appContext));
app.use(require('./src/apis/content')(appContext));
app.use(require('./src/apis/grades')(appContext));
app.use(require('./src/apis/profileimage')(appContext, __dirname));
/* GET /
* The default server location that will return the index html page.
*/
app.get('/', function(req, res) {
res.sendFile(path.join(__dirname+'/html/index.html'));
});
module.exports = app;
app.listen(configs.configuredPort);