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.
50 lines
1.2 KiB
50 lines
1.2 KiB
const express = require("express");
|
|
const cors = require("cors");
|
|
const cookieSession = require("cookie-session");
|
|
|
|
const app = express();
|
|
|
|
var corsOptions = {
|
|
origin: "http://localhost:8080"
|
|
};
|
|
|
|
app.use(cors(corsOptions));
|
|
|
|
// parse requests of content-type - application/json
|
|
app.use(express.json()); /* bodyParser.json() is deprecated */
|
|
|
|
// parse requests of content-type - application/x-www-form-urlencoded
|
|
app.use(express.urlencoded({ extended: true })); /* bodyParser.urlencoded() is deprecated */
|
|
|
|
app.use(
|
|
cookieSession({
|
|
name: "MickaelNode-session",
|
|
secret: "3Z~gU7p4Lct4+.c|DW2=",
|
|
httpOnly: true,
|
|
sameSite: 'strict'
|
|
})
|
|
);
|
|
|
|
const db = require("./app/models/model");
|
|
|
|
db.sequelize.sync();
|
|
|
|
// drop the table if it already exists
|
|
// db.sequelize.sync({ force: true }).then(() => {
|
|
// console.log("Supprime and re-synchronise, la base de données.");
|
|
// });
|
|
|
|
// simple route
|
|
app.get("/", (req, res) => {
|
|
res.json({ message: "Bienvenue dans l'application de mickaël Poupion." });
|
|
});
|
|
|
|
// routes
|
|
require("./app/route/voiture.route")(app);
|
|
|
|
// set port, listen for requests
|
|
const PORT = process.env.PORT || 8080;
|
|
app.listen(PORT, () => {
|
|
console.log(`Le serveur fonctionne sur le port ${PORT}.`);
|
|
});
|