gmail-to-exchange365
Version:
Complete Gmail to Exchange 365 migration tool with UI - Migrate emails, attachments, and folders seamlessly
49 lines (39 loc) • 1.25 kB
text/typescript
import express from "express";
import bodyParser from "body-parser";
import cors from "cors";
import session from "express-session";
import FileStore from "session-file-store";
import path from "path";
import routes from "./routes";
const FileStoreSession = FileStore(session);
const app = express();
// Middleware
app.use(cors());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
// Session configuration
app.use(
session({
secret: process.env.SESSION_SECRET || "your-secret-key-change-this",
resave: false,
saveUninitialized: false,
store: new FileStoreSession({
path: path.join(__dirname, "../../sessions")
}),
cookie: {
secure: process.env.NODE_ENV === "production",
httpOnly: true,
maxAge: 24 * 60 * 60 * 1000 // 24 hours
}
})
);
// Serve static UI files
app.use(express.static(path.join(__dirname, "../ui")));
// API routes
app.use("/", routes);
// Error handling middleware
app.use((err: any, req: express.Request, res: express.Response, next: express.NextFunction) => {
console.error("Error:", err);
res.status(500).json({ error: err.message || "Internal server error" });
});
export default app;