You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
992 B
36 lines
992 B
require('dotenv').config();
|
|
import express from "express";
|
|
import cors from "cors";
|
|
import { IngredientsController } from "./controllers/ingredients.controller";
|
|
import { RecipesController } from "./controllers/recipes.controller";
|
|
import { StepsController } from "./controllers/steps.controller";
|
|
|
|
let helmet = require("helmet");
|
|
const app = express();
|
|
app.use(helmet.hidePoweredBy());
|
|
|
|
// Configuration du middleware CORS pour autoriser toutes les origines
|
|
app.use(cors({
|
|
origin: '*',
|
|
}));
|
|
|
|
app.get('/', (req, res) => {
|
|
res.status(200).send('Hello from express and typescript!');
|
|
});
|
|
|
|
app.use('/ingredients', IngredientsController);
|
|
app.use('/recipes', RecipesController);
|
|
app.use('/steps', StepsController);
|
|
|
|
const port = Number(process.env.PORT) || 3000;
|
|
|
|
export const startServer = (port_to_use: number) => {
|
|
return app.listen(port_to_use, () => console.log(`App listening on PORT ${port_to_use}`));
|
|
};
|
|
|
|
if (require.main === module) {
|
|
startServer(port);
|
|
}
|
|
|
|
export default app;
|