-
Notifications
You must be signed in to change notification settings - Fork 139
/
run_example.js
39 lines (32 loc) · 1.15 KB
/
run_example.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
const path = require('path');
require('dotenv').config();
const { PORT = 3000, PROVIDER_PORT = 3001, API_PORT = 3002 } = process.env;
const example = process.argv.pop();
// Configure and start a mock authorization server if no .env config is found
if (!process.env.CLIENT_ID) {
const provider = require('../end-to-end/fixture/oidc-provider');
console.log(
'Starting a mock authorization server. You can login with any credentials.'
);
process.env = {
...process.env,
ISSUER_BASE_URL: `http:https://localhost:${PROVIDER_PORT}`,
CLIENT_ID: 'test-express-openid-connect-client-id',
BASE_URL: `http:https://localhost:${PORT}`,
SECRET: 'LONG_RANDOM_VALUE',
CLIENT_SECRET: 'test-express-openid-connect-client-secret',
};
provider.listen(PROVIDER_PORT, () =>
console.log(
`Authorization server started at http:https://localhost:${PROVIDER_PORT}`
)
);
}
const api = require(path.join(__dirname, 'api'));
api.listen(API_PORT, () =>
console.log(`API started at http:https://localhost:${API_PORT}`)
);
const app = require(path.join(__dirname, example));
app.listen(PORT, () =>
console.log(`Example app started at http:https://localhost:${PORT}`)
);