feat(express backend): basic structure implemented

This commit is contained in:
2024-10-07 12:19:51 +02:00
parent 6b1bde7a5d
commit 84d8aea1eb
7 changed files with 1800 additions and 0 deletions

23
back-express/src/app.ts Normal file
View File

@@ -0,0 +1,23 @@
import express, { Request, Response } from "express";
import config from "./config";
import cors from "cors";
const app = express();
const port = config.port;
if (config.enableCors) {
app.use(cors());
}
app.use((req, res, next) => {
console.log(`${req.method} request for ${req.url}`);
next();
});
app.get("/", (req: Request, res: Response) => {
res.send("Hello, TypeScript Express!");
});
app.listen(port, () => {
console.log(`Server running at http://localhost:${port}`);
});

View File

@@ -0,0 +1,10 @@
import { configDotenv } from "dotenv";
configDotenv();
const config = {
enableCors: false,
port: process.env.PORT || 3000,
};
export default config;

View File