Nasdaq price checker

this project has two different pitfalls, seriously

firstly the google api that we are supposed to use isn’t working anymore at all, personally me instead of looking for another service wrote my own microservice as a separate glitch app that gives random “prices” on request as a mock up and fetched the data from there with my “price” checker, i hope it is not cheating :3
here is the code of that microservice if you are interested (it’s front-end is the default glitch’s “tell me your hopes and dreams” app, lol):

app.get('/api/stocks', (req, res) => {
  const stock = req.query.stock
  if (stock !== undefined && stock !== "") {
    if (stock.length <= 5 && stock.match(/^[a-zA-Z]+$/) !== null) {
      res.json({stock: stock.toUpperCase(), price: (Math.random()*1000).toFixed(2)})
    }
    else {
      res.json("wrong ticker")
    }
  }
  else {
    res.json("wrong ticker")
  }
  })

the second pitfall is amusing, we are required to allow script loading from our server only, ok …but the front-end uses jquery and tries to load it from code.jquery.com, so helmet blocks jquery from loading and if you make an exception for jquery.com it forbids its execution anyway because the script is inline there (personally i don’t even generally bother to fix front-end of these back-end projects past the minimal functionality, it has to be completely rewritten for good and it is not what the challenges are about), so you have to make a separate script file to make the front-end works, not sure if this is intended

1 Like