print_r(array_map(function($base) { return 10*pow(4,-1 * $base); }, range(1,25)));
const express = require('express');
const bodyParser = require('body-parser');
const util = require('util');
const mysql = require('mysql');
const pool = mysql.createPool({
host: 'localhost',
port: 3306,
user: 'root',
password: '',
database: 'test'
});
pool.getConnection((err, connection) => {
if (err) {
console.error(err.code);
}
if (connection) connection.release();
});
pool.query = util.promisify(pool.query);
const app = express();
app.use(bodyParser.json());
app.post('/register', async (req, res) => {
const { email, firstname, password, role } = req.body;
const [{ counter }] = await pool.query('select count(*) as counter from users where email = ?', [email]);
if (!counter) {
await pool.query('insert into users set ?', { email, firstname, password, role });
}
res.send('ok');
});
app.listen(3000, () => {
console.log('app listening 3000!');
});