-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathimporter.js
30 lines (29 loc) · 883 Bytes
/
importer.js
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
const axios = require('axios')
const slug = require('slug')
const cuid = require('cuid')
const core = require('./core')
const config = require('./config')
async function fromStatusPageIO (url) {
const res = await axios.get(`${url}/api/v1/incidents.json`)
const body = res.data
const incidents = body.incidents
incidents.forEach(i => {
const ti = {
id: `${slug(i.name)}-${cuid.slug()}`.toLowerCase(),
title: i.name,
status: config.Statuses[i.status.toUpperCase()],
createdAt: i.created_at,
updatedAt: i.updated_at,
resolvedAt: i.resolved_at,
updates: i.incident_updates.map(u => {
return {
message: u.body,
status: config.Statuses[u.status.toUpperCase()],
updatedAt: u.created_at
}
})
}
core.createIncident(ti, false)
})
}
exports.fromStatusPageIO = fromStatusPageIO