Create load_adapter()
ea9a302
verified
-
billing-service
Create billing-service/index.js
-
const express = require('express'); const bodyParser = require('body-parser'); const { Pool } = require('pg'); const Redis = require('ioredis'); const fetch = require('node-fetch'); const pool = new Pool({ connectionString: process.env.DATABASE_URL || 'postgresql:
Update const express = require('express'); const bodyParser = require('body-parser'); const { Pool } = require('pg'); const Redis = require('ioredis'); const fetch = require('node-fetch'); const pool = new Pool({ connectionString: process.env.DATABASE_URL || 'postgresql:/localhost/integral' }); const redis = new Redis(process.env.REDIS_URL || 'redis:/localhost:6379'); const app = express(); app.use(bodyParser.json()); redis.subscribe('payouts:created', () => console.log('listening for payouts')); redis.on('message', async (channel, msg) => { if (channel !== 'payouts:created') return; const { payoutId } = JSON.parse(msg); console.log('handle payout', payoutId); / naive: call settle endpoint try { await settlePayout(payoutId); } catch (err) { console.error(err); } }); async function settlePayout(payoutId) { / fetch payout const r = await pool.query('SELECT * FROM payouts WHERE id=$1 FOR UPDATE', [payoutId]); if (r.rowCount === 0) throw new Error('payout not found'); const payout = r.rows[0]; if (payout.status !== 'created') return; / mark queued await pool.query('UPDATE payouts SET status=$1 WHERE id=$2', ['processing', payoutId]); / Example: call external TMS / Accounting system / Payment Gateway / This is a stub — replace with real API call (e.g. TMS settlement API, or bank transfer). const remote = await fakePaymentGateway(payout); if (remote.success) { const txRef = remote.txRef; await pool.query('UPDATE payouts SET status=$1, tx_ref=$2, settled_at=now() WHERE id=$3', ['settled', txRef, payoutId]); await redis.publish('payouts:settled', JSON.stringify({ payoutId, txRef })); } else { await pool.query('UPDATE payouts SET status=$1 WHERE id=$2', ['failed', payoutId]); await redis.publish('payouts:failed', JSON.stringify({ payoutId })); } } async function fakePaymentGateway(payout) { / fake delay await new Promise(r => setTimeout(r, 600)); return { success: true, txRef: `TX-${Date.now()}-${Math.floor(Math.random()*1000)}` }; } app.post('/settle/:payoutId', async (req, res) => { try { const { payoutId } = req.params; await settlePayout(payoutId); res.json({ success: true }); } catch (err) { console.error(err); res.status(500).json({ success: false, error: err.message }); } }); app.listen(process.env.PORT || 3010, () => console.log('billing-service listening 3010'));
-
curl -X POST http:
Create curl -X POST http://localhost:3001/detect -H "Content-Type: application/json" -d '{"namespace":"satellite","type":"pothole-detection","location":{"lat":-29.12,"lon":26.22},"severity":2,"images":[],"provenance":{"source":"test"}}'
-
detection-service
Create detection-service/index.js
-
docker exec -i $(docker ps -q -f ancestor=postgres:15) psql -U integral -d integral -f postgres
Create docker exec -i $(docker ps -q -f ancestor=postgres:15) psql -U integral -d integral -f postgres/migrations/01_schema.sql
-
migrations
Update migrations/01_schema.sql
-
services
Create services/dashboard/package.json
-
verification-service
Create verification-service/index.js
-
1.52 kB
initial commit
-
75 Bytes
Create Bash
-
1.16 kB
Create README.md
-
265 Bytes
Create Readme.md
-
20 Bytes
Create adapters
-
451 Bytes
Create docker compose logs -f verification docker compose logs -f billing docker compose logs -f apollo
-
33 Bytes
Create docker compose up --build -d
-
1.64 kB
Create docker-compose.yml
-
127 Bytes
Create ini
-
14.2 kB
Upload integral-micro.zip
-
14.9 kB
Upload integral_apollo_server.js
-
15.4 kB
Upload integral_ml_and_dashboard.md
-
1.58 kB
Upload integral_react_dashboard.jsx
-
266 Bytes
Create load_adapter()
-
824 Bytes
Create lue
-
1.54 kB
Create schema-potholes.graphql
-
21.3 kB
Upload synthetic_pothole_dataset.zip