|
@ -5,6 +5,8 @@ import fetch from 'node-fetch'; |
|
|
import { stringify as stringifyQuery } from 'querystring'; |
|
|
import { stringify as stringifyQuery } from 'querystring'; |
|
|
import chalk from 'chalk'; |
|
|
import chalk from 'chalk'; |
|
|
|
|
|
|
|
|
|
|
|
const URL = 'https://api.now.sh/registration'; |
|
|
|
|
|
|
|
|
const stdin = process.openStdin(); |
|
|
const stdin = process.openStdin(); |
|
|
|
|
|
|
|
|
function readEmail () { |
|
|
function readEmail () { |
|
@ -19,13 +21,8 @@ function readEmail () { |
|
|
|
|
|
|
|
|
async function getVerificationToken (email) { |
|
|
async function getVerificationToken (email) { |
|
|
const data = JSON.stringify({ email }); |
|
|
const data = JSON.stringify({ email }); |
|
|
const res = await fetch('http://localhost:3001/', { |
|
|
const res = await fetch(URL, { |
|
|
method: 'POST', |
|
|
method: 'POST', |
|
|
mode: 'cors', |
|
|
|
|
|
headers: { |
|
|
|
|
|
'Content-Type': 'application/json', |
|
|
|
|
|
'Content-Length': data.length |
|
|
|
|
|
}, |
|
|
|
|
|
body: data |
|
|
body: data |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
@ -43,8 +40,7 @@ async function verify (email, verificationToken) { |
|
|
token: verificationToken |
|
|
token: verificationToken |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
const res = await fetch('http://localhost:3001/verify?' + stringifyQuery(query)); |
|
|
const res = await fetch(`${URL}/verify?${stringifyQuery(query)}`); |
|
|
|
|
|
|
|
|
const body = await res.json(); |
|
|
const body = await res.json(); |
|
|
return body.token; |
|
|
return body.token; |
|
|
} |
|
|
} |
|
|