app.post('/register', async (req, res) => {
let body = req.body
let response = {status:'', title:'', text:''}
if (await checkUniqueEmail(body.email)) {
response.status = 'success'
} else {
response.status = 'error'
response.title = 'E-Mail адрес занят'
response.text = 'Используйте другой'
}
res.json(response)
});
function checkUniqueEmail (email) {
return pool.query(`SELECT * FROM users WHERE 'email' = $1`, [email]).then(res => {
if (res.rowCount !== 0) {
return Promise.resolve(false)
} else {
return Promise.resolve(true)
}
}).catch(err => Promise.reject(err))
}
app.post('/register', async (req, res) => {
let body = req.body
let response = {status:'', title:'', text:''}
checkUniqueEmail(body.email, function (err, result) {
if (result.rowCount === 0) {
response.status = 'success'
} else {
response.status = 'error'
response.title = 'E-Mail адрес занят'
response.text = 'Используйте другой'
}
res.json(response)
})
});
function checkUniqueEmail (email, callback) {
pool.query(`SELECT * FROM users WHERE 'email' = $1`, [email], (err, result) => {
callback(err, result)
})
}
proxies: {
type: new GraphQLList(ProxiesType),
resolve: function () {
fetch('http://localhost:8090/get-proxies')
.then(res => res.json())
.then(json => {
});
}