Hi everyone, just finished my Request Header Parser Microservice!:
https://request-header-parser-88d.herokuapp.com/
I am using the ua-parser module for the user agent header and accepts module for the accept-language header!
Any feedback to improve the code appreciated!
Hi Jackson, what does this code do in your app?:
var ip = request.headers[‘x-forwarded-for’] ||
request.connection.remoteAddress ||
request.socket.remoteAddress ||
request.connection.socket.remoteAddress;
I was having trouble getting an IPv4 address - I kept getting IPv6. This was a snippet I got from stack overflow that fixed my issue, but I’ve seen other examples since that didn’t need this, so I’ll revisit it some time to see how necessary it really is and how to simplify it.
I notice we use different ua parser modules - that may be where my issue was with my ip.
yeah im using this one https://www.npmjs.com/package/ua-parser , which works fine for me
Live project link
GitHub source code
Happy to hear any opinions, comments, suggestions, etc.
Nice - does chalk just pretty up the console logging?
Yep, it just gives you the ability to make console.logs different colors. Definitely not necessary, but makes life a tad more fun and/or occasionally easier.
From Chalk’s readme:
"Windows
If you’re on Windows, do yourself a favor and use cmder instead of cmd.exe."
True dat, chalkie
1 Like
Project link: https://req-header-parser.gomix.me/
Code: https://github.com/svmi3195/req-header-parser
I tried to do it with node only, I hope it works for all (kinda does for me, but haven’t tested much yet)
Project link https://github.com/davidpickup/headerparser
This was quite straightforward after the micro service. Just had to work out the regex for parsing the OS.
muchris
January 13, 2017, 1:35am
20
Hi All! Please take a moment and let me know if this app is working correctly for you.
https://fcc-microservice-header.herokuapp.com/
Thank you!
Chris
arw2015
January 13, 2017, 12:18pm
21
https://github.com/ARWL2016/req-header-parser-microservice
https://serene-anchorage-56334.herokuapp.com/
This one seemed pretty straightforward, but testing is tricky. Does anyone know a way of mocking GET requests from other IP addresses?