index.js 798 B

12345678910111213141516171819202122232425262728
  1. var database = require('./database');
  2. var register_feedback_message = require('./register-feedback-message');
  3. const express = require('express')
  4. const app = express()
  5. app.use(express.json());
  6. const port = 3102
  7. const host = 'http://localhost';
  8. const chalk = require('chalk')
  9. database.start().then(() => {
  10. app.post('/receive', (req, res) => {
  11. //console.log(`Received message at ${chalk.italic('\'/receive\'')}`);
  12. register_feedback_message(req.body).then(() => {
  13. res.status(200).end();
  14. })
  15. .catch((error) => {
  16. console.log(chalk.red(error));
  17. res.status(500).json(error);
  18. })
  19. })
  20. app.listen(port, () => {
  21. console.log(`Customer Feedback Service listening at ${chalk.cyan(`${host}:${port}`)}`);
  22. });
  23. })