44 lines
967 B
TypeScript
44 lines
967 B
TypeScript
import express, { Express } from "express";
|
|
import dotenv from "dotenv";
|
|
import logger from "./src/logger/logger";
|
|
import useragent from "express-useragent";
|
|
import cors from "cors";
|
|
|
|
dotenv.config();
|
|
|
|
import qrCodeRoutes from "./src/routes/qrcodeRoutes";
|
|
|
|
const app: Express = express();
|
|
const host = process.env.HOST || "localhost";
|
|
const port = Number(process.env.PORT) || 3000;
|
|
|
|
// set up middleware
|
|
/*
|
|
app.use(
|
|
cors({
|
|
origin: "*",
|
|
})
|
|
); */
|
|
app.use(useragent.express());
|
|
app.use("/", qrCodeRoutes);
|
|
|
|
app.use((req, res, next) => {
|
|
console.log("req not found, path:", req.path);
|
|
|
|
res.status(200);
|
|
//res.redirect(process.env.REDIRECT_URL as string);
|
|
});
|
|
|
|
app.use((err: any, req: any, res: any, next: any) => {
|
|
console.log("req err", err.stack);
|
|
|
|
res.status(200);
|
|
//res.redirect(process.env.REDIRECT_URL as string);
|
|
});
|
|
|
|
// start server
|
|
|
|
app.listen(port, host, () =>
|
|
logger.info(`⚡️[server]: Server is running at http://${host}:${port}`)
|
|
);
|