11const fs = require ( 'fs' ) ;
22const NodeRSA = require ( 'node-rsa' ) ;
3- const { config } = require ( 'process' ) ;
43const logger = require ( '../logger' ) . global ;
54
65const keysFile = '/data/keys.json' ;
@@ -18,7 +17,8 @@ const configure = () => {
1817 } catch ( err ) {
1918 // do nothing
2019 }
21- if ( configData ?. database && configData ?. database ?. engine ) {
20+
21+ if ( configData && configData . database ) {
2222 logger . info ( `Using configuration from file: ${ filename } ` ) ;
2323 instance = configData ;
2424 return ;
@@ -48,8 +48,8 @@ const configure = () => {
4848 logger . info ( `Using Sqlite: ${ envSqliteFile } ` ) ;
4949 instance = {
5050 database : {
51- engine : 'knex-native' ,
52- knex : {
51+ engine : 'knex-native' ,
52+ knex : {
5353 client : 'sqlite3' ,
5454 connection : {
5555 filename : envSqliteFile
@@ -62,7 +62,7 @@ const configure = () => {
6262 // Get keys from file
6363 if ( ! fs . existsSync ( keysFile ) ) {
6464 generateKeys ( ) ;
65- } else if ( ! ! process . env . DEBUG ) {
65+ } else if ( process . env . DEBUG ) {
6666 logger . info ( 'Keys file exists OK' ) ;
6767 }
6868 try {
@@ -106,8 +106,8 @@ module.exports = {
106106 has : function ( key ) {
107107 instance === null && configure ( ) ;
108108 const keys = key . split ( '.' ) ;
109- let level = instance ;
110- let has = true ;
109+ let level = instance ;
110+ let has = true ;
111111 keys . forEach ( ( keyItem ) => {
112112 if ( typeof level [ keyItem ] === 'undefined' ) {
113113 has = false ;
@@ -140,7 +140,7 @@ module.exports = {
140140 */
141141 isSqlite : function ( ) {
142142 instance === null && configure ( ) ;
143- return instance . database ? .knex && instance . database ? .knex ? .client === 'sqlite3' ;
143+ return instance . database . knex && instance . database . knex . client === 'sqlite3' ;
144144 } ,
145145
146146 /**
@@ -159,7 +159,7 @@ module.exports = {
159159 */
160160 getPublicKey : function ( ) {
161161 instance === null && configure ( ) ;
162- return instance ? .keys ? .pub
162+ return instance . keys . pub ;
163163 } ,
164164
165165 /**
@@ -169,7 +169,7 @@ module.exports = {
169169 */
170170 getPrivateKey : function ( ) {
171171 instance === null && configure ( ) ;
172- return instance ? .keys ? .key ;
172+ return instance . keys . key ;
173173 } ,
174174
175175 /**
0 commit comments