Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

index.js 1.1 KB

You have to be logged in to leave a comment. Sign In
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
  1. const fs = require('fs')
  2. const path = require('path')
  3. const walk = require('walk-sync')
  4. const { set } = require('lodash')
  5. const staticDir = path.join(__dirname, 'static')
  6. // compile contents of individual .payload.json files into a single object, with versions as top-level keys
  7. const payloads = {}
  8. // array of versions based on subdirectory names: lib/webhooks/static/<version>
  9. const versions = fs.readdirSync(staticDir)
  10. versions.forEach(version => {
  11. const payloadsPerVersion = {}
  12. const versionSubdir = path.join(staticDir, version)
  13. walk(versionSubdir, { includeBasePath: true })
  14. .forEach(payloadFile => {
  15. // payload file: /path/to/check_run.completed.payload.json
  16. // payload path: check_run.completed
  17. const payloadPath = path.basename(payloadFile).replace('.payload.json', '')
  18. set(payloadsPerVersion, payloadPath, formatAsJsonCodeBlock(require(payloadFile)))
  19. })
  20. payloads[version] = payloadsPerVersion
  21. })
  22. function formatAsJsonCodeBlock (payloadObj) {
  23. return '<div class="height-constrained-code-block">\n\n```json\n' + JSON.stringify(payloadObj, null, 2) + '\n```\n\n</div>'
  24. }
  25. module.exports = payloads
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...