You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
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(res.status, await res.text());
|
|
|
|
|
}
|
|
|
|
|
});
|