import dotenv from "dotenv";
dotenv.config({ path: ".env" });

import express, { Application } from "express";

const app: Application = express();
const port: number = parseInt(process.env.PORT as string) || 3000;

//Middleware
app.use(express.json());
app.use(express.urlencoded({ extended: true }));

//Setting up for EJS
app.set("views", `./src/views`);
app.set("view engine", "ejs");

//Static route
app.use(express.static(`${__dirname}/../public`));

//check and send index ejs
app.get("/", (_req, res) => {
	res.render("index");
});

app.listen(port, (): void => {
	console.log(`Server is running on port ${port}`);
});
