mirror of
https://github.com/Sebclem/hassio-nextcloud-backup.git
synced 2024-11-14 21:42:58 +01:00
40 lines
980 B
TypeScript
40 lines
980 B
TypeScript
import cookieParser from "cookie-parser";
|
|
import cors from "cors";
|
|
import express from "express";
|
|
|
|
import morgan from "morgan";
|
|
import path from "path";
|
|
import { fileURLToPath } from "url";
|
|
import logger from "./config/winston.js";
|
|
import apiV2Router from "./routes/apiV2.js";
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = path.dirname(__filename);
|
|
|
|
const app = express();
|
|
|
|
app.use(
|
|
cors({
|
|
origin: true,
|
|
})
|
|
);
|
|
|
|
app.set("port", process.env.PORT || 3000);
|
|
if (process.env.ACCESS_LOG == "true") {
|
|
app.use(
|
|
morgan("dev", { stream: { write: (message) => logger.debug(message) } })
|
|
);
|
|
}
|
|
app.use(express.json());
|
|
app.use(express.urlencoded({ extended: false }));
|
|
app.use(cookieParser());
|
|
app.use(express.static(path.join(__dirname, "public")));
|
|
|
|
app.use("/v2/api/", apiV2Router);
|
|
/*
|
|
-----------------------------------------------------------
|
|
Error handler
|
|
----------------------------------------------------------
|
|
*/
|
|
|
|
export default app;
|