"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const express_1 = require("express");
const data_source_1 = require("../data-source");
const auth_1 = require("../middleware/auth");
const User_1 = require("../entity/User");
const router = (0, express_1.Router)();
router.get('/users', auth_1.authentificationToken, async function (req, res) {
    let UserTypeRepository = data_source_1.AppDataSource.getRepository(User_1.User);
    let users = await UserTypeRepository.find();
    res.send(users);
});
router.put('/updateuser/:id', auth_1.authentificationToken, async function (req, res) {
    const UserTypeRepository = data_source_1.AppDataSource.getRepository(User_1.User);
    const user = await UserTypeRepository.findOneBy({ id: parseInt(req.params.id) });
    UserTypeRepository.merge(user, req.body);
    const results = await UserTypeRepository.save(user);
    res.send(results);
});
router.put('/resetpassword/:id', auth_1.authentificationToken, async function (req, res) {
    const UserTypeRepository = data_source_1.AppDataSource.getRepository(User_1.User);
    const user = await UserTypeRepository.findOneBy({ id: parseInt(req.params.id) });
    user.password = req.body;
    const results = await UserTypeRepository.save(user);
    res.send(results);
});
exports.default = router;
