40 lines
No EOL
1.1 KiB
JavaScript
40 lines
No EOL
1.1 KiB
JavaScript
const express = require('express');
|
|
const mongodb = require('mongodb')
|
|
const bcrypt = require('bcryptjs');
|
|
|
|
const db = require('../data/database');
|
|
|
|
const router = express.Router();
|
|
|
|
router.post('/creerPost', async function (req,res) {
|
|
const postData = req.body;
|
|
const enteredTitre = postData.titre;
|
|
const enteredCommentaire = postData.commentairePost;
|
|
const post ={
|
|
titre: enteredTitre,
|
|
commentaire: enteredCommentaire,
|
|
isFinish: false,
|
|
}
|
|
await db.getDb().collection('posts').insertOne(post);
|
|
})
|
|
|
|
router.get('/hotLine', function (req,res) {
|
|
const postData = db.getDb().collection('posts').find().array();
|
|
res.render('hotLine', {postData: postData})
|
|
})
|
|
|
|
router.post('/commandeCrepe', async function (req, res) {
|
|
const crepeData = req.body;
|
|
const enteredCommentaire = crepeData.commentaire;
|
|
const enteredGarniture = crepeData.garniture;
|
|
|
|
const crepeCommande = {
|
|
garniture: enteredGarniture,
|
|
commentaire: enteredCommentaire,
|
|
finish: false
|
|
}
|
|
await db.getDb().collection('commande').insertOne(crepeCommande);
|
|
res.redirect("/hotLine");
|
|
})
|
|
|
|
module.exports = router; |