Question from the Node.js test

Given an express server, what are the correct statements about it?

Hard

Considering the following express server :

const path       = require('path');
const express    = require('express');
const bodyParser = require('body-parser');

let app          = express();
let messages     = [];

app.use('/message', bodyParser.urlencoded({extended:true}));
app.use('/message/add', express.static(path.join(__dirname, 'messagesViews')));

app.post('/message/add', (req, res) => {
  let { username, message } = req.body;
  messages.push({ username, message });

  res.send('Message posté !');
});

app.get('/message', (req, res) => {
  res.json(messages);
});

app.listen(1337);

What statement are true?

Author: Jean-marie CléryStatus: PublishedQuestion passed 883 times
Edit
0
Community EvaluationsNo one has reviewed this question yet, be the first!