@@ -7,11 +7,12 @@ import session from 'express-session';
7
7
import { createServer } from 'http' ;
8
8
import routes from './api/routes/api' ;
9
9
import commandExists from 'command-exists'
10
+ import config from 'config'
10
11
import execa from 'execa'
11
12
import opn from 'opn'
12
13
13
14
let params = process . argv ;
14
- let port = 3000 ;
15
+ let port = 57432 ;
15
16
let portIndex = params . indexOf ( '-port' ) ;
16
17
if ( portIndex != - 1 ) {
17
18
let reg = / [ 0 - 9 ] + / ;
@@ -58,31 +59,52 @@ app.use(bodyParser.urlencoded({extended: false}));
58
59
app . use ( cookieParser ( ) ) ;
59
60
app . use ( express . static ( path . join ( __dirname , 'public' ) ) ) ;
60
61
let sess = {
61
- secret : 'mydicebot987' ,
62
- cookie : { } ,
62
+ secret : 'mydicebot12323' ,
63
+ cookie : {
64
+ secure : false ,
65
+ maxAge : 1000 * 60 * 30 ,
66
+ httpOnly : true ,
67
+ } ,
63
68
resave : false ,
64
69
saveUninitialized : false
65
70
}
66
- if ( app . get ( 'env' ) === 'production' ) {
67
- app . set ( 'trust proxy' , 1 ) ;
68
- }
71
+ app . set ( 'trust proxy' , 1 ) ;
69
72
app . use ( session ( sess ) )
70
73
routes ( app ) ;
71
74
72
- let url = 'http://127.0.0.1:' + port + '/login' ;
73
- if ( [ 'win32' , 'darwin' ] . includes ( process . platform ) ) {
74
- opn ( url , {
75
- wait : false ,
76
- app :browser
77
- } )
78
- } else {
79
- try {
80
- const xdgOpenExists = commandExists ( 'xdg-open' )
81
- if ( ! xdgOpenExists ) {
82
- throw new Error ( 'xdg-open does not exist' )
75
+ if ( process . env . NODE_ENV == 'production' && typeof config . mydice == 'undefined' ) {
76
+ config . mydice = { } ;
77
+ config . mydice . auth = { } ;
78
+ config . mydice . chat = { } ;
79
+ config . mydice . oauth = { } ;
80
+ config . mydice . oauth . github = { } ;
81
+ config . mydice . oauth . google = { } ;
82
+ config . mydice . oauth . steem = { } ;
83
+ config . mydice . pkg = true ;
84
+ config . mydice . auth . url = 'https://auth.mydicebot.com/' ;
85
+ config . mydice . chat . url = 'https://chat.mydicebot.com/' ;
86
+ config . mydice . oauth . github . url = 'https://github.com/login/oauth/authorize?client_id=9f8842af70978390f78d' ;
87
+ config . mydice . oauth . google . url = 'https://accounts.google.com/o/oauth2/auth?response_type=code&access_type=offline&client_id=192445019791-rupf3vtns5708bhtpt1vrmbhqk817qrr.apps.googleusercontent.com&redirect_uri=http://localhost:57432/google/cb&scope=https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email' ;
88
+ config . mydice . oauth . steem . url = 'https://app.steemconnect.com/oauth2/authorize?client_id=mydicebot&redirect_uri=http://localhost:57432/steem/cb&scope=login&response_type=code' ;
89
+ }
90
+
91
+ console . log ( 'pkg:' , config . mydice . pkg ) ;
92
+ if ( config . mydice . pkg ) {
93
+ let url = 'http://localhost:' + port + '/login' ;
94
+ if ( [ 'win32' , 'darwin' ] . includes ( process . platform ) ) {
95
+ opn ( url , {
96
+ wait : false ,
97
+ app :browser
98
+ } )
99
+ } else {
100
+ try {
101
+ const xdgOpenExists = commandExists ( 'xdg-open' )
102
+ if ( ! xdgOpenExists ) {
103
+ throw new Error ( 'xdg-open does not exist' )
104
+ }
105
+ execa ( 'xdg-open' , [ url ] )
106
+ } catch ( _ ) {
107
+ log ( `Unable to open your browser automatically. Please open the following URI in your browser:\n\n${ oAuthURL } \n\n` )
83
108
}
84
- execa ( 'xdg-open' , [ url ] )
85
- } catch ( _ ) {
86
- log ( `Unable to open your browser automatically. Please open the following URI in your browser:\n\n${ oAuthURL } \n\n` )
87
109
}
88
110
}
0 commit comments