var express = require('express')
var cors = require('cors')
var bodyParser = require("body-parser");
const db = require('./utils/database')
var app = express();
const port = 5000
require("./utils/dbfunctions").connect();


//MiddleWares
app.use(cors());
app.use(express.urlencoded({extended:false}))
app.use(express.json())
app.use(express.static('public'));


// Routes

// Users
const login = require("./apis/users/login");
const selectUser = require("./apis/users/selectUser");
const createUser=require("./apis/users/createUser")
const updateUser = require("./apis/users/updateUser")
const deleteUser = require("./apis/users/deleteUser")
const changePass = require('./apis/users/userPasswordReset')


// complain
const createComplain=require("./apis/Complain/Create")
const updateComplain=require("./apis/Complain/Update")
const selectComplain=require("./apis/Complain/Select")
const deleteComplain=require("./apis/Complain/Delete")
// Routes Middleware

// User
app.use("/api/users", login);
app.use("/api/users", selectUser);
app.use("/api/users", createUser);
app.use("/api/users", updateUser);
app.use("/api/users", deleteUser);
app.use("/api/password", changePass);


//complain
app.use("/api/Complain",createComplain)
app.use("/api/Complain",updateComplain)
app.use("/api/Complain",deleteComplain)
app.use("/api/Complain",selectComplain)



app.get('/',(req,res)=>{
  res.send('Hello from fineBack')
})

//Server Listining
app.listen(port, "0.0.0.0", () => {
    console.log(`Example app listening at http://localhost:${port}`);
  });
