aboutsummaryrefslogtreecommitdiff
path: root/src/lib/config/actions.ts
blob: 2a60ce0cc95d33b7cdb73c9f462d85d89ba062fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//
// ~~~ action configs
//

// imports
import { readFileSync } from "node:fs"

import type ActionsConfig from "@lib/config/actionss.types.ts"

// load config
const configFile = "data/actions.json"
let actionsConfig: ActionsConfig = {}

try {
    actionsConfig = JSON.parse(readFileSync(configFile, "utf8"))
} catch(e) {
    console.error("!> cannot read actions config")
}

// get all actions
const allActions = Object.keys(actionsConfig).map((action) => {

    const actionInfo = actionsConfig[action]

    return {
        ...actionInfo,
        id: action
    }

})

export default allActions