forked from Azure-Samples/ms-identity-javascript-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
42 lines (34 loc) · 1.08 KB
/
server.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
/*
* Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license.
* See LICENSE in the source repository root for complete license information.
*/
const express = require('express');
const morgan = require('morgan');
const path = require('path');
const argv = require('yargs')
.usage('Usage: $0 -p [PORT]')
.alias('p', 'port')
.describe('port', '(Optional) Port Number - default is 3000')
.strict()
.argv;
const DEFAULT_PORT = 3000;
//initialize express.
const app = express();
// Initialize variables.
let port = DEFAULT_PORT; // -p {PORT} || 3000;
if (argv.p) {
port = argv.p;
}
// Configure morgan module to log all requests.
app.use(morgan('dev'));
// Set the front-end folder to serve public assets.
app.use("/lib", express.static(path.join(__dirname, "../../lib/msal-browser/lib")));
// Setup app folders
app.use(express.static('app'));
// Set up a route for index.html.
app.get('*', function (req, res) {
res.sendFile(path.join(__dirname + '/index.html'));
});
// Start the server.
app.listen(port);
console.log(`Listening on port ${port}...`);