2 changed files with 80 additions and 0 deletions
@ -0,0 +1,45 @@ |
|||||||
|
import fetch from 'node-fetch'; |
||||||
|
|
||||||
|
process.stdin.resume(); |
||||||
|
process.stdin.setEncoding('utf8'); |
||||||
|
let input = []; |
||||||
|
process.stdin.on('data', (data) => { |
||||||
|
input.push(data); |
||||||
|
}); |
||||||
|
|
||||||
|
const token = |
||||||
|
'1234567812345678123456781234567812345678123456781234567812345678'; |
||||||
|
|
||||||
|
const hostname = 'http://localhost:3333'; |
||||||
|
const headers = { 'Content-Type': 'application/json' }; |
||||||
|
|
||||||
|
process.stdin.on('end', async () => { |
||||||
|
for (let event_line of input.join('').split('\n')) { |
||||||
|
const [ |
||||||
|
facebook_id = '', |
||||||
|
location_name = '', |
||||||
|
place_id = '', |
||||||
|
name = '', |
||||||
|
start = '', |
||||||
|
ticket_url = '' |
||||||
|
] = event_line.split('¤'); |
||||||
|
|
||||||
|
let event = { |
||||||
|
draft: false, |
||||||
|
canceled: false, |
||||||
|
facebook_id, |
||||||
|
location_name, |
||||||
|
place_id: Number(place_id), |
||||||
|
name, |
||||||
|
start: Number(start), |
||||||
|
ticket_url |
||||||
|
}; |
||||||
|
|
||||||
|
let res = await fetch(`${hostname}/events/?token=${token}`, { |
||||||
|
method: 'POST', |
||||||
|
body: JSON.stringify(event), |
||||||
|
headers |
||||||
|
}); |
||||||
|
console.log(await res.text()); |
||||||
|
} |
||||||
|
}); |
||||||
@ -0,0 +1,35 @@ |
|||||||
|
import events from './events.json' assert { type: 'json' }; |
||||||
|
|
||||||
|
const dl = '¤'; |
||||||
|
|
||||||
|
console.log( |
||||||
|
`canceled${dl}created${dl}draft${dl}end${dl}facebook_id${dl}host${dl}id${dl}location${dl}name${dl}start${dl}ticket_url${dl}updated` |
||||||
|
); |
||||||
|
|
||||||
|
events.forEach( |
||||||
|
({ |
||||||
|
canceled, |
||||||
|
created, |
||||||
|
draft, |
||||||
|
end, |
||||||
|
facebook_id, |
||||||
|
host, |
||||||
|
id, |
||||||
|
location, |
||||||
|
name, |
||||||
|
start, |
||||||
|
ticket_url, |
||||||
|
updated |
||||||
|
}) => { |
||||||
|
const line = `${canceled}${dl}${created}${dl}${draft}${dl}${end}${dl}${facebook_id}${dl}${host}${dl}${id}${dl}${location}${dl}${name}${dl}${start}${dl}${ticket_url}${dl}${updated}`; |
||||||
|
|
||||||
|
if (line.split(`${dl}`).length != 12) { |
||||||
|
console.error(id, name); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
console.log( |
||||||
|
`${canceled}${dl}${created}${dl}${draft}${dl}${end}${dl}${facebook_id}${dl}${host}${dl}${id}${dl}${location}${dl}${name}${dl}${start}${dl}${ticket_url}${dl}${updated}` |
||||||
|
); |
||||||
|
} |
||||||
|
); |
||||||
Loading…
Reference in new issue