import { Pool } from 'pg';
import { hash } from 'bcrypt'

export default defineEventHandler(async (event) => {
    try {
        const pool = new Pool({
            user: "de-user10",
            host: 'de-db.ptk.itiscaf.ru',
            database: 'de-user10',
            port: 5441,
            password: 'fGz0uG18uK'
        })

        const body = await readBody(event);

        let { user_id, nameorder, date, pay } = body;

        const hash_password = hash(password, 10);

        const res = await pool.query('INSERT INTO users(user_id, nameorder, date, pay ) VALUES($1, $2, $3) RETURNING id', 
            [user_id, nameorder, date, pay ]
        );

    } catch (error) {
        console.log('server signUp error', error);
        
    }


})