This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | Joi.validate(userEntity, SCHEMA_RES_LINKS).then((userEntity) => { | |
| res.send(userEntity); | |
| }).catch((reason) => res.status(400).send(`Something appears to be wrong with this account: ${reason}`)); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | const { Joi } = require(‘celebrate’); | |
| const links_POST_schema = Joi.object().keys({ | |
| access_token: Joi.string(), | |
| id_token: Joi.string(), | |
| url: Joi.string().required(), | |
| title: Joi.string().required() | |
| }).xor(‘access_token’, ‘id_token’); | |
| module.exports = links_POST_schema; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | const SCHEMA_POST_LINKS = require(‘. / request_schemas / link_collection_routes / links_POST_schema.js’); | |
| app.post(‘/user/links’, Celebrate({ | |
| body: SCHEMA_POST_LINKS | |
| }), (req, res) => { | |
| logger.info(‘POST received…\ tCreateUser’); /* hey look, | |
| a logging mistake I just | |
| discovered because | |
| I forgot to change what I c/p’d | |
| (I am not kidding); | |
| */ | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | app.post(‘/user/links’, Celebrate({ | |
| body: Joi.object().keys({ | |
| important_value: Joi.string().required(), // look, type enforcement! | |
| data1: Joi.number().integer(), | |
| data2: Joi.string().default(‘admin’) // hey, and defaults! | |
| }), | |
| query: { | |
| token: Joi.string().token().required() // you can use one object to | |
| // validate body, query, | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | const express = require(‘express’); | |
| const BodyParser = require(‘body - parser’); | |
| const Celebrate = require(‘celebrate’); | |
| const { Joi } = Celebrate; | |
| const app = express(); // use whatever name you like, I tend to default to app | |
| app.use(BodyParser.json()); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | app.post(‘/linksforuser’, function (req, res) { | |
| if (!req.body.important_value) { | |
| logger.debug(‘USER UPDATE POST FAILED: MISSING IMPORTANT VALUE’, { | |
| request_body: req.body | |
| }); | |
| res.status(400).send(‘Body Important Value Missing: ‘+req.body); | |
| } | |
| if (!req.body.data1) { | |
| logger.debug(‘USER UPDATE POST FAILED: MISSING DATA1 VALUE’, { | |
| request_body: req.body | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | app.post(‘/user/links’, function (req, res) { | |
| if (!req.body.important_value || !req.body.data1 || !req.body.data2) { | |
| logger.debug(‘USER UPDATE POST FAILED: MISSING VALUES’, { | |
| request_body: req.body | |
| }); | |
| res.status(400).send(‘Body Properties Missing: ‘ + req.body); | |
| } | |
| /* actual thing you want to do with this route */ | |
| }); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | var express = require('express'); | |
| var router = express.Router(); | |
| var request = require('request'); | |
| var util = require('util'); | |
| var stationChooser = require('./../stationChooser.js'); | |
| var fetchStationStatus = require('./../fetchStationStatus.js'); | |
| var bodyParser = require('body-parser'); | |
| var jsonParser = bodyParser.json(); | |
| var twilio = require('twilio'); |