'use strict'; const path = require('path'); // Server-side paths, relative to this directory (the app's writable storage // on-device — nodejs-mobile-cordova copies nodejs-project here at runtime). process.env.DB_PATH = path.join(__dirname, 'data', 'bills.db'); process.env.BACKUP_PATH = path.join(__dirname, 'backups'); process.env.PORT = process.env.PORT || '3000'; process.env.BIND_HOST = '127.0.0.1'; const cordova = require('cordova-bridge'); // Wait for the WebView to hand over the device-bound encryption key (stored // in Android Keystore / iOS Keychain — see src/crypto.ts) before starting the // server, so encryptionService.js picks up TOKEN_ENCRYPTION_KEY on first use. cordova.channel.on('message', function (msg) { if (msg && msg.type === 'encryptionKey' && typeof msg.key === 'string') { process.env.TOKEN_ENCRYPTION_KEY = msg.key; require('./server/server.js'); } }); cordova.channel.post('message', { type: 'ready' });