From 4bd3d82c83f28ad54a8db8bf365341eafa57c10c Mon Sep 17 00:00:00 2001 From: david akor Date: Mon, 23 Feb 2026 11:12:33 -0800 Subject: [PATCH] chore: Move hardcoded server port to .env file - Add Express.js backend with dotenv configuration - Create .env.example file with PORT=3000 - Update server.js to use process.env.PORT || 3000 - Add package.json with express and dotenv dependencies - Update .gitignore for Node.js projects Closes #issue --- .env.example | 9 +++++++++ .gitignore | 44 ++++++++++++++++++++++++++++++++++++++++++++ package.json | 20 ++++++++++++++++++++ server.js | 39 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 112 insertions(+) create mode 100644 .env.example create mode 100644 package.json create mode 100644 server.js diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..2c23e49 --- /dev/null +++ b/.env.example @@ -0,0 +1,9 @@ +# Server Configuration +PORT=3000 + +# Environment +NODE_ENV=development + +# Stellar/Soroban Configuration (for future use) +STELLAR_NETWORK=testnet +SOROBAN_RPC_URL=https://soroban-testnet.stellar.org diff --git a/.gitignore b/.gitignore index fe42cc5..fdb8270 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,47 @@ **/*.rs.bk Cargo.lock .DS_Store + +# Node.js +node_modules/ +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Environment variables +.env +.env.local +.env.development.local +.env.test.local +.env.production.local + +# Logs +logs +*.log + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Coverage directory used by tools like istanbul +coverage/ + +# nyc test coverage +.nyc_output + +# Dependency directories +jspm_packages/ + +# Optional npm cache directory +.npm + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity diff --git a/package.json b/package.json new file mode 100644 index 0000000..e0f2e1b --- /dev/null +++ b/package.json @@ -0,0 +1,20 @@ +{ + "name": "tradeflow-core-backend", + "version": "1.0.0", + "description": "Backend API for TradeFlow-Core smart contracts", + "main": "server.js", + "scripts": { + "start": "node server.js", + "dev": "nodemon server.js" + }, + "dependencies": { + "express": "^4.18.2", + "dotenv": "^16.3.1" + }, + "devDependencies": { + "nodemon": "^3.0.1" + }, + "keywords": ["tradeflow", "stellar", "soroban", "blockchain"], + "author": "TradeFlow Team", + "license": "MIT" +} diff --git a/server.js b/server.js new file mode 100644 index 0000000..0f27891 --- /dev/null +++ b/server.js @@ -0,0 +1,39 @@ +const express = require('express'); +require('dotenv').config(); + +const app = express(); +const PORT = process.env.PORT || 3000; + +// Middleware +app.use(express.json()); + +// Basic health check endpoint +app.get('/health', (req, res) => { + res.json({ + status: 'OK', + message: 'TradeFlow-Core Backend API is running', + timestamp: new Date().toISOString() + }); +}); + +// API info endpoint +app.get('/', (req, res) => { + res.json({ + name: 'TradeFlow-Core Backend API', + version: '1.0.0', + description: 'Backend API for TradeFlow-Core smart contracts on Stellar/Soroban', + endpoints: { + health: '/health', + contracts: { + invoiceNft: 'Invoice NFT smart contract endpoints', + lendingPool: 'Lending Pool smart contract endpoints' + } + } + }); +}); + +// Start server +app.listen(PORT, () => { + console.log(`TradeFlow-Core Backend API server is running on port ${PORT}`); + console.log(`Health check available at: http://localhost:${PORT}/health`); +});