import tickets from "./src/controllers/ticket-controllers";
import users from "./src/controllers/user-controllers";
import * as express from "express";
import * as Knex from "knex";
import * as bodyParser from "body-parser";
import * as cors from "cors";

const app = express();
const port = 8000;

const knex = Knex({
  client: "postgres",
  connection: {
    host: "127.0.0.1",
    user: "postgres",
    password: "sa",
    database: "test"
  }
});

app.use(cors());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());

app.set("knex", knex);
app.use("/tickets", tickets);
app.use("/user", users);

app.listen(port, () => console.log(`Example app listening on port ${port}!`));
