File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change 1
1
import * as shell from "shelljs" ;
2
+ import fs from "fs" ;
2
3
3
4
shell . cp ( "-R" , "src/public/fonts" , "dist/public/" ) ;
4
5
shell . cp ( "-R" , "src/public/images" , "dist/public/" ) ;
6
+
7
+ if ( shell . ls ( 'localhost.crt' ) . length == 0 ) {
8
+ shell . exec ( 'openssl req \
9
+ -new \
10
+ -newkey rsa:4096 \
11
+ -days 365 \
12
+ -nodes \
13
+ -x509 \
14
+ -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=localhost" \
15
+ -keyout localhost.key \
16
+ -out localhost.crt' ) ;
17
+ }
Original file line number Diff line number Diff line change @@ -10,9 +10,22 @@ import bluebird from "bluebird";
10
10
import cors from "cors" ;
11
11
12
12
// Create Express server
13
- //
14
13
const app = express ( ) ;
15
14
15
+ if ( [ "development" , "staging" , "production" ] . indexOf ( process . env . NODE_ENV ) == - 1 ) {
16
+ const https = require ( 'https' ) ;
17
+
18
+ // SSL
19
+ const sslkey = fs . readFileSync ( "localhost.key" ) ;
20
+ const sslcert = fs . readFileSync ( "localhost.crt" ) ;
21
+ const options = {
22
+ key : sslkey ,
23
+ cert : sslcert
24
+ } ;
25
+
26
+ https . createServer ( options , app ) . listen ( 443 ) ;
27
+ }
28
+
16
29
// Express configuration
17
30
//
18
31
app . set ( "port" , process . env . PORT || 8000 ) ;
You can’t perform that action at this time.
0 commit comments