feat: add core modules - dienstService, whatsappApi, messageHandler, webhook server
This commit is contained in:
parent
f8a708c9d0
commit
3e6b33f103
4 changed files with 163 additions and 0 deletions
24
src/dienstService.js
Normal file
24
src/dienstService.js
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
let dienstenCache = null
|
||||
|
||||
function loadDiensten() {
|
||||
if (dienstenCache) return dienstenCache
|
||||
const jsonPath = process.env.DIENSTEN_JSON
|
||||
const raw = fs.readFileSync(jsonPath, 'utf-8')
|
||||
dienstenCache = JSON.parse(raw)
|
||||
return dienstenCache
|
||||
}
|
||||
|
||||
function findDienst(dienstnummer) {
|
||||
const diensten = loadDiensten()
|
||||
return diensten.find(d => d.dienstnummer === dienstnummer) || null
|
||||
}
|
||||
|
||||
function getPngFilePaths(dienst) {
|
||||
const pngDir = process.env.DIENSTEN_PNG
|
||||
return dienst.paginas.map(p => path.join(pngDir, p.bestandsnaam))
|
||||
}
|
||||
|
||||
module.exports = { loadDiensten, findDienst, getPngFilePaths }
|
||||
Loading…
Reference in a new issue