feat(express backend): basic structure implemented
This commit is contained in:
23
back-express/src/app.ts
Normal file
23
back-express/src/app.ts
Normal 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}`);
|
||||
});
|
||||
10
back-express/src/config.ts
Normal file
10
back-express/src/config.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { configDotenv } from "dotenv";
|
||||
|
||||
configDotenv();
|
||||
|
||||
const config = {
|
||||
enableCors: false,
|
||||
port: process.env.PORT || 3000,
|
||||
};
|
||||
|
||||
export default config;
|
||||
0
back-express/src/routes/users/users.routes.ts
Normal file
0
back-express/src/routes/users/users.routes.ts
Normal file
Reference in New Issue
Block a user