1+ require ( 'dotenv' ) . config ( )
12const http = require ( 'http' )
23const jsonfile = require ( 'jsonfile' )
34const url = require ( 'url' )
@@ -10,12 +11,16 @@ const app = express()
1011const proxy = require ( 'http-proxy-middleware' )
1112const path = require ( 'path' )
1213
13- const configPath = './config.json'
14- const admindataPath = './admindata.json'
15- const dataPath = '../assets/data/data.json'
16- const logPath = '../assets/data/log.json'
17- const port = jsonfile . readFileSync ( configPath ) . serverPort
18- const configBackupPath = '../../configBackup.json'
14+ const configPath = process . env . CONFIG_PATH || './config.json'
15+ const admindataPath = process . env . ADMINDATA_PATH || './admindata.json'
16+ const dataPath = process . env . DATA_PATH || '../assets/data/data.json'
17+ const logPath = process . env . LOG_PATH || '../assets/data/log.json'
18+ const port = process . env . SERVER_PORT || 62050
19+ const configBackupPath = process . env . CONFIG_BACKUP_PATH || '../../configBackup.json'
20+ const organization = process . env . ORGANIZATION
21+ const organizationHomepage = process . env . ORGANIZATION_HOMEPAGE
22+ const organizationGithubUrl = process . env . ORGANIZATION_GITHUB_URL
23+ const adminPassword = process . env . ADMIN_PASSWORD
1924const proxyOption = {
2025 target : 'http://localhost:' + port + '/' ,
2126 pathRewrite : { '^/api' : '' } ,
@@ -66,7 +71,6 @@ process.on('exit', () => {
6671const server = http
6772 . createServer ( ( req , res ) => {
6873 const route = url . parse ( req . url ) . pathname
69- const { adminPassword } = jsonfile . readFileSync ( configPath )
7074
7175 switch ( route ) {
7276 case '/data' :
@@ -84,12 +88,11 @@ const server = http
8488 } )
8589 break
8690 case '/config' :
87- var Config = jsonfile . readFileSync ( configPath )
8891 res . end (
8992 JSON . stringify ( {
90- organization : Config . organization ,
91- organizationHomepage : Config . organizationHomepage ,
92- organizationGithubUrl : Config . organizationGithubUrl ,
93+ organization : organization ,
94+ organizationHomepage : organizationHomepage ,
95+ organizationGithubUrl : organizationGithubUrl ,
9396 } )
9497 )
9598 break
@@ -154,7 +157,7 @@ const server = http
154157 res . end ( 'Permission denied\n' )
155158 return
156159 }
157- var { organization , includedRepositories } = jsonfile . readFileSync (
160+ var { includedRepositories } = jsonfile . readFileSync (
158161 configPath
159162 )
160163 API . getRepositories ( organization ) . then ( ( repositories ) => {
@@ -297,9 +300,10 @@ const server = http
297300 // Add this contributor in the data.json
298301 const data = jsonfile . readFileSync ( dataPath )
299302 API . getContributorInfo (
300- Config . organization ,
303+ organization ,
301304 username ,
302- Config . includedRepositories
305+ Config . includedRepositories ,
306+ Config . startDate
303307 ) . then ( ( result ) => {
304308 if (
305309 result . avatarUrl !== '' &&
0 commit comments