DEV Community

Discussion on: Creating a simple queue messaging application over HTTP using NodeJs

Collapse
 
miwels profile image
miwels

Thank you for the tutorial. I always used prebuilt queue systems like Amazon's SQS but I find it very interesting to understand how these systems work internally.

Can you explain this line?

const queryData = (url.parse(req.url, true).query) as unknown as Incoming;

url is not defined (I thought that maybe you wanted to use the 'URL' class but the parse method doesn't exist). Also I don't really understand the notation "as unknown as Incoming"

Thanks

Collapse
 
elasticrash profile image
Stefanos Kouroupis • Edited

Sorry I didn't include the imports to save space. url is the node url module

import * as url from 'url';

I do have the code in a GitHub repo but I am not entirely sure it's identical

github.com/elasticrash/dpp-queue

As for the unknown...unknown is a type that can be assigned to something without type assertion...it's like saying I don't care what is it but I I want to assume is is Incoming

Collapse
 
miwels profile image
miwels

Many thanks, now is much more clear :)