Examples
Two minimal templates are included:
Static weather
import { createServer } from '@sylan/provider-express'
const { app, listen } = createServer({
apiId: '0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef',
consensus: '0x81B78B79775C04F5c30DfBC17d9710EA5C3CB166',
chainId: 80002,
signKey: '0xPROVIDER_SIGNER_PRIVATE_KEY',
ttlMs: 60000,
})
app.get('/weather', (_req, res, next) => { res.locals.data = { city: 'Doha', tempC: 39, date: new Date().toISOString() }; next() })
listen(3000)Dynamic price
import { createServer } from '@sylan/provider-express'
const { app, listen } = createServer({
apiId: '0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef',
consensus: '0x81B78B79775C04F5c30DfBC17d9710EA5C3CB166',
chainId: 80002,
signKey: '0xPROVIDER_SIGNER_PRIVATE_KEY',
ttlMs: 0,
})
app.get('/price', async (_req, res, next) => { res.locals.data = { symbol: 'BTC', price: Math.round(30000 + Math.random()*1000), ts: Date.now() }; next() })
listen(3001)Last updated on