DEV Community

Thanh Tien Phat Nguyen
Thanh Tien Phat Nguyen

Posted on

Check Telescope posts' availability

Introduction

This week, I was assigned to add a new feature to check if a post from Telescope is available for my link checker CLI. Before digging any deeper, I would like to introduce a bit about Telescope.

It enables us to keep track of students' work through blog posts written by Seneca College students. By fetching data from multiple blogging sites such as Medium, Dev, WordPress,.. all blog posts of students will be automatically updated to the website whenever a new post is published.

Set up the environment to work with Telescope.

To run Telescope locally, it asks us to put extra effort into setting up an appropriate environment. I am required to install WSL2, Redis, Elasticsearch, and Docker before starting the work. This is probably the most challenging part of the assignment this week. Therefore, I did counter some troubles while setting up the environment.

Elasticsearch not running after installation could be a thing. I had to make some diagnoses and realized my JDK was not compatible. It took me a considerable amount of time to fix it. Or I got trouble while installing the Linux subsystem since my disk was low in storage. However, these problems could be solved by doing research on Google. The point is you have to be resilient enough.

Coding part

The coding part doesn't require a lot of work. I created an API handler that manages to make a GET request to the local Telescope API, and I check the availability of each URL response by the API.

const telescopeCheck = (api) => {
    axios.get(api)
    .then(response => {
        console.log("CONNECT TO TELESCOPE SUCCESSFULLY!!!");
        console.log("====================================")

        for (i = 0; i < response.data.length; i++)
        {
            checkURL(api+`/${response.data[i].id}`);
        }
    })
    .catch(err => console.log("Cannot connect to local API, please double check to make sure the API is initiated!!!"))
}
Enter fullscreen mode Exit fullscreen mode

Gist it done

Gist is a quick and instant tool that enables us to share code snippets without unnecessary work. To get technical notes between two commits, we simply use the command git diff old_commit...new_commit.

I am still not satisfied with the code snippets above. Therefore, any recommendation will be welcome. Thank you for spending your time reading my blog.

Top comments (0)