<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: dhamola</title>
    <description>The latest articles on DEV Community by dhamola (@samueloduba).</description>
    <link>https://dev.to/samueloduba</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F872791%2Fe08f6b0a-5f27-46e5-b45c-1668ed78daf5.jpeg</url>
      <title>DEV Community: dhamola</title>
      <link>https://dev.to/samueloduba</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/samueloduba"/>
    <language>en</language>
    <item>
      <title>Solving a Complex Backend Challenge: Integrating OpenAI and Termii for Multilingual SMS Delivery</title>
      <dc:creator>dhamola</dc:creator>
      <pubDate>Fri, 28 Jun 2024 21:59:09 +0000</pubDate>
      <link>https://dev.to/samueloduba/solving-a-complex-backend-challenge-integrating-openai-and-termii-for-multilingual-sms-delivery-5fmd</link>
      <guid>https://dev.to/samueloduba/solving-a-complex-backend-challenge-integrating-openai-and-termii-for-multilingual-sms-delivery-5fmd</guid>
      <description>&lt;p&gt;I encountered a challenging problem while working on a personal project, which involved consuming the OpenAI endpoint. The project's goal was to translate message content into various languages, providing a multilingual communication experience. To achieve this, I needed to integrate the functionalities of OpenAI for translation and Termii for reliable SMS delivery.&lt;/p&gt;

&lt;p&gt;Let me give a practical example of how the service could be useful.  imagine a church that has members from different language backgroundss. With this service, the church can send personalized messages to each member in their preferred languages.&lt;/p&gt;

&lt;p&gt;Up until that point, my experience had primarily been in building endpoints rather than consuming APIs, making this task particularly difficult.&lt;/p&gt;

&lt;p&gt;What I did?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I repeatedly read the documentation for the OpenAI and Termii APIs to understand their requirements and functionalities.&lt;/li&gt;
&lt;li&gt;I had to search online, including Stack Overflow, to find any existing solutions or similar issues faced by other developers.&lt;/li&gt;
&lt;li&gt;I reached out to my mentor, sharing all the research I had done and the specific issues I was facing. This made it easier for my mentor to understand the problem and guide me.&lt;/li&gt;
&lt;li&gt;I applied the suggestions and solutions provided by my mentor, which helped me overcome the challenges and successfully integrate the APIs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;My journey into technology has been unconventional. I began with a Bachelor's degree in Business Education from Ekiti State University. After completing my NYSC in 2018/2019, I joined GTBank, one of Nigeria's largest banks, as an entry-level employee. There, we utilized Excel for reporting, analyzing data and engaging in peer-to-peer reviews with other banks to guide business decisions. It was during this time that I developed a keen interest in software development and its potential to transform traditional business practices.&lt;br&gt;
Driven by this newfound curiosity, I decided to transition into tech while still working as a graduate trainee at GTBank. I enrolled in Altschool Africa's software development program and became proficient in HTML, CSS, JavaScript, Node.js, MongoDB, and SQL. I also dedicated time to learning tools like JMeter, Cypress, and Postman for automation on Udemy. After earning a diploma in Backend Engineering from Altschool Africa, I transitioned into IT and moved to Access Bank. There, I tested the bank's products before they were deployed to production. In my role at Access Bank, I have worked closely with developers and product owners to ensure that all requirements are met and that the final product is of the highest quality.&lt;br&gt;
Breaking into tech wasn't easy; I had to balance both my work and learning,and even take on unpaid internships just to gain the necessary skills. However, through dedication and consistency, I acquired the expertise to become a QA Engineer and Backend Developer. Over the years, I have worked on various projects and in different organizations, adapting to their unique cultures and dynamics. &lt;/p&gt;

&lt;p&gt;As a QA Engineer, I've had the opportunity to work closely with data teams,developers, gaining valuable insights into codebases, data-driven decision-making processes. &lt;/p&gt;

&lt;p&gt;I'm incredibly excited about the HNG 11 cohort. I participated in the last cohort but was dropped at the 5th stage. Although I completed the task, I was informed that my implementation wasn't quite right. The project involved video translation. Despite this setback, I am a resilient individual and firmly believe that I can succeed this time.&lt;br&gt;
I believe that getting to the final stage and finishing the program will give me a sense of fulfilment.In this internship, I want to get international jobs, network with great and like minds and be part of a community.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://hng.tech/internship" rel="noopener noreferrer"&gt;https://hng.tech/internship&lt;/a&gt; &lt;a href="https://hng.tech/hire" rel="noopener noreferrer"&gt;https://hng.tech/hire&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Multilingual SMS Translation Service built with Hapi, Nodejs and Javascript</title>
      <dc:creator>dhamola</dc:creator>
      <pubDate>Mon, 07 Aug 2023 09:01:48 +0000</pubDate>
      <link>https://dev.to/samueloduba/multilingual-sms-translation-service-built-with-hapi-nodejs-and-javascript-1kbn</link>
      <guid>https://dev.to/samueloduba/multilingual-sms-translation-service-built-with-hapi-nodejs-and-javascript-1kbn</guid>
      <description>&lt;p&gt;Hey there! I've created this awesome service that makes sending bulk SMS messages super easy! But that's not all – it goes beyond the usual and lets you translate your messages into any language you want. How cool is that?&lt;/p&gt;

&lt;p&gt;I've integrated the powerful features of OpenAI and Termii to make sure your messages get translated accurately and delivered on time. No more worrying about language barriers or missing out on reaching your audience!&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;Before starting, please ensure that you have Node.js and npm installed as prerequisites. If you don't have them already, you can download and install them from the official Node.js website: &lt;a href="https://nodejs.org" rel="noopener noreferrer"&gt;https://nodejs.org&lt;/a&gt;.&lt;br&gt;
This service leverages the power of OpenAI and Termii to ensure seamless translation and efficient delivery of SMS messages.&lt;/p&gt;
&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Install Node.js and npm on your system.&lt;/li&gt;
&lt;li&gt;Clone this repository to your local machine.&lt;/li&gt;
&lt;li&gt;Navigate to the project directory and install the required 
dependencies using npm install.&lt;/li&gt;
&lt;li&gt;Create a .env file in the root directory and add the necessary 
environment variables:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Hapi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@hapi/hapi&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;axios&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;axios&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;dotenv&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;dotenv&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;dotenv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;config&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Package and tools
&lt;/h2&gt;

&lt;p&gt;This documentation offers a comprehensive overview of the external API utilized in the project.&lt;/p&gt;
&lt;h2&gt;
  
  
  OPENAI:
&lt;/h2&gt;

&lt;p&gt;OpenAI is a dedicated artificial intelligence research laboratory focused on the development of safe and beneficial artificial general intelligence (AGI). To use their services, you can visit their official website and access the documentation at this link: (&lt;a href="https://platform.openai.com/docs/introduction" rel="noopener noreferrer"&gt;https://platform.openai.com/docs/introduction&lt;/a&gt;). By creating an account on their platform, you will gain access to an API key, which is essential for using their AI capabilities in your applications.&lt;br&gt;
OpenAI was seamlessly integrated  into the app, empowering users to effortlessly translate messages from one source language to their desired destination language. This powerful integration added a valuable language conversion feature to our application, enhancing its versatility and usability.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;translateText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;source_language&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;destination_language&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;apiKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;OPENAI_KEY&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;apiUrl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://api.openai.com/v1/chat/completions&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;gpt-3.5-turbo&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;system&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;You are a helpful assistant that translates text.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;user&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`Translate the following '&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;source_language&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;' text to '&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;destination_language&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;': &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;text&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="na"&gt;max_tokens&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;150&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;n&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;stop&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;temperature&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;

  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Make the request with a delay of 2 seconds&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;axios&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;apiUrl&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;Authorization&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`Bearer &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;apiKey&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Content-Type&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;application/json&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;translation&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;choices&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;content&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;trim&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;translation&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Error:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Termii :
&lt;/h2&gt;

&lt;p&gt;Termii is a platform that helps different companies send alerts. It helps other businesses authenticate user identities and transactions with one-time passwords (OTP).&lt;br&gt;
you can visit their official website and access the documentation at this link: (&lt;a href="https://developers.termii.com" rel="noopener noreferrer"&gt;https://developers.termii.com&lt;/a&gt;). By creating an account on their platform, you will gain access to an API key, which is plugged into the applications.&lt;br&gt;
After the message has been converted by openAI, we incorporated the Termii api into our app to deliver the message to the recipient.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;request&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="nx"&gt;convertedPhoneNumbers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;convertedPhoneNumber&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="na"&gt;to&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;convertedPhoneNumber&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;from&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;kokash&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;sms&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;translation&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;plain&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;channel&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;generic&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;api_key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;TERMII_KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;};&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="na"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;POST&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://termii.com/api/sms/send&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Content-Type&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;application/json&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;application/json&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
          &lt;span class="p"&gt;},&lt;/span&gt;
          &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="p"&gt;};&lt;/span&gt;

        &lt;span class="nf"&gt;request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
          &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;});&lt;/span&gt;
      &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Axios:
&lt;/h2&gt;

&lt;p&gt;Axios played a crucial role in our application, enabling us to effortlessly interact with external APIs. Its user-friendly API, promise-based design, and robust error handling capabilities streamlined the process of fetching and processing data from different sources. By acting as a reliable bridge, Axios ensured smooth communication and significantly improved the overall performance of our application.&lt;/p&gt;

&lt;h2&gt;
  
  
  .env.example
&lt;/h2&gt;

&lt;p&gt;environment variable offers all the configuration-related data needed.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Short URL generator built with Express, Nodejs and TypeScript.</title>
      <dc:creator>dhamola</dc:creator>
      <pubDate>Mon, 26 Jun 2023 14:32:51 +0000</pubDate>
      <link>https://dev.to/samueloduba/short-url-generator-built-with-express-nodejs-and-typescript-2hnd</link>
      <guid>https://dev.to/samueloduba/short-url-generator-built-with-express-nodejs-and-typescript-2hnd</guid>
      <description>&lt;p&gt;The shortUrl application was developed using Node.js, and it was designed to produce a short url from a given url as well as a barcode. Before using this feature, a user must first register and then log in. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites&lt;/strong&gt;&lt;br&gt;
Before starting, please ensure that you have Node.js and npm installed as prerequisites. If you don't have them already, you can download and install them from the official Node.js website: &lt;a href="https://nodejs.org" rel="noopener noreferrer"&gt;https://nodejs.org&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In addition to Node.js and npm, this project also utilizes MongoDB as the database and Render for deployment. If you need detailed instructions on how to use these tools, please refer to their respective documentation.&lt;/p&gt;

&lt;p&gt;Please note that this project was developed using TypeScript, so familiarity with TypeScript would be beneficial for understanding and working with the codebase.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2ixwoaq6vxgt2klidtox.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2ixwoaq6vxgt2klidtox.png" alt=" " width="433" height="141"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Package and Tools&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This documentation provides an overview of the packages and tools used in the project, along with their functionalities and installation instructions.&lt;/p&gt;

&lt;p&gt;MongoDB:&lt;br&gt;
Description: MongoDB is a popular NoSQL database used for storing and retrieving data.&lt;br&gt;
Installation: Visit the official MongoDB website (&lt;a href="https://www.mongodb.com" rel="noopener noreferrer"&gt;https://www.mongodb.com&lt;/a&gt;) to download and install MongoDB according to your operating system. Follow the installation instructions provided.&lt;/p&gt;

&lt;p&gt;EJS (Embedded JavaScript):&lt;/p&gt;

&lt;p&gt;Description: EJS is a simple templating language that allows dynamic rendering of HTML templates.&lt;br&gt;
Installation: EJS is a Node.js package and can be installed via npm. Open your terminal and run the following command:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy9r1u38slecm8gt9opkf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy9r1u38slecm8gt9opkf.png" alt=" " width="154" height="56"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Passport:&lt;/p&gt;

&lt;p&gt;Description: Passport is a middleware for Node.js that provides authentication functionality.&lt;br&gt;
Installation: Passport can be installed via npm. Open your terminal and run the following command:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw3896zf8robgt22hbwuk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw3896zf8robgt22hbwuk.png" alt=" " width="183" height="46"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;QRCode:&lt;/p&gt;

&lt;p&gt;Description: QRCode is a package that allows generating QR codes from text or URLs.&lt;br&gt;
Installation: QRCode can be installed via npm. Open your terminal and run the following command:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9qrh4c6ydrenchcq74te.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9qrh4c6ydrenchcq74te.png" alt=" " width="175" height="39"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Selenium WebDriver (for testing):&lt;/p&gt;

&lt;p&gt;Description: Selenium WebDriver is a popular tool for automating web browsers and performing automated testing.&lt;br&gt;
Installation: Selenium WebDriver requires additional setup. Visit the Selenium WebDriver documentation (&lt;a href="https://www.selenium.dev/documentation/en/webdriver/" rel="noopener noreferrer"&gt;https://www.selenium.dev/documentation/en/webdriver/&lt;/a&gt;) to download and install the WebDriver suitable for your preferred browser.&lt;/p&gt;

&lt;p&gt;shortId generator:&lt;/p&gt;

&lt;p&gt;Description: shortId is a package that generates short, unique, and URL-friendly IDs.&lt;br&gt;
Installation: shortId can be installed via npm. Open your terminal and run the following command:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmdlqk2ghizgjsrnlyhn3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmdlqk2ghizgjsrnlyhn3.png" alt=" " width="180" height="58"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Express:&lt;/p&gt;

&lt;p&gt;Description: Express is a fast and minimalist web application framework for Node.js.&lt;br&gt;
Installation: Express can be installed via npm. Open your terminal and run the following command:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx41kokih2v6zxks3ipqa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx41kokih2v6zxks3ipqa.png" alt=" " width="174" height="46"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;bcrypt:&lt;/p&gt;

&lt;p&gt;Description: bcrypt is a password hashing library used to securely store user passwords.&lt;br&gt;
Installation: bcrypt can be installed via npm. Open your terminal and run the following command:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffkd12zz95xcod2wberni.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffkd12zz95xcod2wberni.png" alt=" " width="171" height="44"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Rate-limit:&lt;/p&gt;

&lt;p&gt;Description: Rate-limit is a middleware that limits the number of requests a user can make within a certain time frame.&lt;br&gt;
Installation: Rate-limit can be installed via npm. Open your terminal and run the following command:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzf8644bwb2rd2bbxowxv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzf8644bwb2rd2bbxowxv.png" alt=" " width="241" height="55"&gt;&lt;/a&gt;&lt;br&gt;
Please note that the above installation commands assume you have npm and Node.js already installed. Make sure to run the commands from the root directory of your project.&lt;/p&gt;

&lt;p&gt;It's important to consult the official documentation for each package and tool for detailed usage instructions, configuration options, and API references.&lt;/p&gt;

&lt;p&gt;Refer to the readme file to set up the development environment&lt;br&gt;
&lt;a href="https://github.com/dhamolahedonist/short_url-generator/blob/main/README.md" rel="noopener noreferrer"&gt;https://github.com/dhamolahedonist/short_url-generator/blob/main/README.md&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Folder Structure&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Folder: config&lt;/p&gt;

&lt;p&gt;Files:&lt;br&gt;
ensureAuthenticated.ts: This file defines the ensureAuthenticated middleware function that checks if a user is authenticated before allowing access to a protected resource. If the user is not authenticated, it flashes an error message and redirects to the login page.&lt;br&gt;
Dependencies: The middleware uses the express library.&lt;/p&gt;

&lt;p&gt;Files:&lt;br&gt;
connectDB.ts: This file establishes a connection to the MongoDB database using the Mongoose library. It reads the MongoDB URI from the environment variables using the dotenv package.&lt;br&gt;
Dependencies: The configuration file uses the mongoose and dotenv libraries.&lt;/p&gt;

&lt;p&gt;Files:&lt;br&gt;
configurePassport.ts: This file configures the passport authentication strategy using the passport-local strategy. It defines the local strategy for username-password authentication and sets up serialization and deserialization of user objects. It uses the bcrypt library for password hashing and the User model for user-related operations.&lt;br&gt;
Dependencies: The service file uses the passport, mongoose, bcrypt, and User model.&lt;/p&gt;

&lt;p&gt;Folder: controllers&lt;/p&gt;

&lt;p&gt;File: shortUrlController.ts&lt;/p&gt;

&lt;p&gt;This file contains controller functions related to URL shortening, QR code generation, and link management. It includes functions for rendering short URLs, generating short URLs, retrieving short URLs, generating QR codes, validating URLs, and deleting links. The file imports the express, ShortUrl, and QRCode libraries.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwf27scsiobmp7llcxfkl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwf27scsiobmp7llcxfkl.png" alt=" " width="664" height="475"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;File: dashboardController.ts&lt;/p&gt;

&lt;p&gt;Description: This file contains controller functions related to the dashboard functionality. It includes functions for rendering the welcome page, rendering the dashboard page, rendering the index page with the user's short URLs, generating short URLs, retrieving short URLs, generating QR codes, validating URLs, and deleting short URLs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff0y8srwvw2wgq8ho26ez.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff0y8srwvw2wgq8ho26ez.png" alt=" " width="535" height="469"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;File: userController.ts&lt;/p&gt;

&lt;p&gt;Description: This file contains controller functions related to user management and authentication using Passport. It includes functions for rendering the login and registration pages, handling user registration, user login, and user logout.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo9joyofcq1igi3qapb4f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo9joyofcq1igi3qapb4f.png" alt=" " width="509" height="462"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;folder: model&lt;br&gt;
The ShortUrl model file defines the Mongoose schema for storing shortened URLs. It includes fields for the full URL, generated short URL, number of clicks, and a reference to the associated user.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F55jonnzhlc1ajsfh2usm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F55jonnzhlc1ajsfh2usm.png" alt=" " width="495" height="484"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The User model file defines the Mongoose schema for storing user information. It includes fields for the user's name, email, and password.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs2yjskhr0y6jg8co6r9u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs2yjskhr0y6jg8co6r9u.png" alt=" " width="548" height="439"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Both models are used to create MongoDB documents and are exported for use in other parts of the application.&lt;/p&gt;

&lt;p&gt;folder: routes&lt;/p&gt;

&lt;p&gt;file:&lt;br&gt;
shortUrlRoutes.ts: This is a route file that defines the routes for URL shortening and management. It imports controller functions from "shortUrlControllers" and "dashboardController". The routes include rendering the welcome page, rendering the dashboard page with authentication, rendering the URL page, generating a short URL, retrieving a short URL, generating a QR code, deleting a link, and logging out.&lt;/p&gt;

&lt;p&gt;file:&lt;br&gt;
userRoutes.ts:This is another route file that defines routes related to user authentication and URL management. It imports controller functions from "userController" and "shortUrlControllers". The routes include rendering the login and registration pages, registering a new user, logging in a user, and retrieving a short URL.&lt;/p&gt;

&lt;p&gt;Both files use the express Router and export the defined routes as the default export.&lt;/p&gt;

&lt;p&gt;folder: Views&lt;/p&gt;

&lt;p&gt;dashboard.ejs: This file represents a dashboard page with a heading, a welcome message with the user's name, and a button to go back to the home page.&lt;/p&gt;

&lt;p&gt;error.ejs: This file displays an error message with a back button if an invalid link is submited to generate barcode.&lt;/p&gt;

&lt;p&gt;home.ejs: This file represents the home page with a form to enter a URL and generate a shortened URL. It also displays a table with existing short URLs, including their full URL, short URL, and click count. It has a section to generate a QR code for a given URL and a logout button.&lt;/p&gt;

&lt;p&gt;layout.ejs: This file provides the basic structure for other pages, including a container div and necessary CSS and JS links.&lt;/p&gt;

&lt;p&gt;login.ejs: This file displays a login form with input fields for email and password.&lt;/p&gt;

&lt;p&gt;register.ejs: This file displays a registration form with input fields for name, email, password, and password confirmation.&lt;/p&gt;

&lt;p&gt;qrCode.ejs: This file displays a generated QR code for a given URL and provides options to download the barcode image or go back to the home page.&lt;/p&gt;

&lt;p&gt;welcome.ejs: This file represents a welcome page with a Node.js logo and options to register or login.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;db.js&lt;/strong&gt;&lt;br&gt;
All users and shortUrls data is kept in the mongdb database, which is connected to using db.js.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;.env.example&lt;/strong&gt;&lt;br&gt;
environment variable offers all the configuration-related data needed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;server.ts&lt;/strong&gt;&lt;br&gt;
All of the application's files are combined into one file called server.ts.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqrq0ipvvatr1xfxfbgoo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqrq0ipvvatr1xfxfbgoo.png" alt=" " width="359" height="362"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Deployement on Render.&lt;br&gt;
Refer to the documentation on how to deploy on ##Render&lt;br&gt;
&lt;a href="https://render.com/docs" rel="noopener noreferrer"&gt;https://render.com/docs&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>CHATBOT Built with Nodejs and Telegram as the user interface</title>
      <dc:creator>dhamola</dc:creator>
      <pubDate>Fri, 24 Mar 2023 09:08:48 +0000</pubDate>
      <link>https://dev.to/samueloduba/chatbot-built-with-nodejs-and-telegram-as-the-user-interface-4iab</link>
      <guid>https://dev.to/samueloduba/chatbot-built-with-nodejs-and-telegram-as-the-user-interface-4iab</guid>
      <description>&lt;p&gt;This chatbot was created with Node.js and is intended to have conversations with users. Users must provide particular input in order for it to function.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;You will be required to have Node JS and npm before starting. Make sure you already have them installed. If not you can find them here: &lt;a href="https://nodejs.org" rel="noopener noreferrer"&gt;https://nodejs.org&lt;/a&gt;. Additional tools like Mongodb and Render(for deployment), were utilized. If you'd want more specific instructions on how to use these tools, please refer to their documentation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvx0sxhdwfklvf77up3cc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvx0sxhdwfklvf77up3cc.png" alt=" " width="504" height="251"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Packages and Tools
&lt;/h2&gt;

&lt;p&gt;To get started you will need to Register a Bot Account&lt;/p&gt;

&lt;p&gt;You'll need a Telegram user account before you can create a Telegram bot. Head over to &lt;a href="https://telegram.org/" rel="noopener noreferrer"&gt;https://telegram.org/&lt;/a&gt; and create an account if you don't already have one.&lt;/p&gt;

&lt;p&gt;When you've signed in to Telegram, search for "BotFather" (a bot for managing all other Telegram bots) and start a new chat with it. Follow the steps below to register a new bot with the BotFather:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7r44qkib57q1btwiyf1l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7r44qkib57q1btwiyf1l.png" alt=" " width="382" height="177"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The BotFather will respond with a message containing an access token for your newly created bot. This access token will allow our application to access the Telegram API and tell our bot what to do when receiving different messages from users.&lt;/p&gt;

&lt;p&gt;To confirm that your bot was created successfully, search for the bot's username. You should be able to see it and start a conversation with it, although it won't respond as we haven't written the bot's logic yet.&lt;/p&gt;

&lt;p&gt;Refer to the readme file to set up the development environment &lt;a href="https://github.com/dhamolahedonist/Jumia-Food-Telegram-Bot" rel="noopener noreferrer"&gt;https://github.com/dhamolahedonist/Jumia-Food-Telegram-Bot&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The application makes use of a number of packages, including Mongoose and Telegraf. Please refer to the documentation provided with these packages for specific usage instructions.&lt;/p&gt;

&lt;p&gt;Telegraf as a library  was adopted to be able to develop our own app using javascript.refer to the documentation &lt;a href="https://telegraf.js.org/#features" rel="noopener noreferrer"&gt;https://telegraf.js.org/#features&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Mongoose is the preferred ORM to communicate with the database because we are using MongoDB&lt;/p&gt;

&lt;h2&gt;
  
  
  Folder Structure
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Controller
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;The stepsControllers.js file handles all the responses based on the user input&lt;/li&gt;
&lt;li&gt;The userControllers.js file look for the user; if none was found, a new user is created and the step the user is currently on is updated.&lt;/li&gt;
&lt;li&gt;Both the stepsControllers and the userControllers file are complied in the webhookController.js file which is now compiled in the index.js file&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  db.js
&lt;/h2&gt;

&lt;p&gt;All user and blog data is kept in the mongdb database, which is connected to using db.js.&lt;/p&gt;

&lt;h2&gt;
  
  
  .env.example
&lt;/h2&gt;

&lt;p&gt;environment variable offers all the configuration-related data needed.&lt;/p&gt;

&lt;h2&gt;
  
  
  index.js
&lt;/h2&gt;

&lt;p&gt;All of the application's files are combined into one file called index.js.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deployement on Render.
&lt;/h2&gt;

&lt;p&gt;Refer to the documentation on how to deploy on ##Render&lt;br&gt;
&lt;a href="https://render.com/docs" rel="noopener noreferrer"&gt;https://render.com/docs&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Design a blog API with Express, MongoDb and Heroku</title>
      <dc:creator>dhamola</dc:creator>
      <pubDate>Mon, 02 Jan 2023 11:33:18 +0000</pubDate>
      <link>https://dev.to/samueloduba/design-a-blog-api-with-express-mongodb-and-heroku-4i8o</link>
      <guid>https://dev.to/samueloduba/design-a-blog-api-with-express-mongodb-and-heroku-4i8o</guid>
      <description>&lt;p&gt;Several articles have been written about using NodeJs, Heroku, and the Express framework to build straightforward blogs. Here is yet another viewpoint and way of thinking that goes in the same direction.&lt;/p&gt;

&lt;p&gt;The most widely used NodeJs framework, Express, offers a number of abstracted functionalities for creating straightforward yet effective APIs.&lt;/p&gt;

&lt;p&gt;The blog initially uses APIs to handle articles for certain authors. Articles can be managed by authors as private or public.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites&lt;/strong&gt;&lt;br&gt;
You will be required to have Node JS and npm before starting. Make sure you already have them installed. If not you can find them here: &lt;a href="https://nodejs.org" rel="noopener noreferrer"&gt;https://nodejs.org&lt;/a&gt;. Additional tools like Mongodb and Heroku were utilized. If you'd want more specific instructions on how to use these tools, please refer to their documentation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Packages and Tools&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A number of packages, including Joi, bcryptjs, Mongoose, Passport, and jwt, are used by the application. For detailed usage information, please consult the documentation for these packages.&lt;/p&gt;

&lt;p&gt;In order to ensure that the payload is legitimate before being saved in the database, Joi is utilized in Post endpoints for payload validation. Bcryptjs was used to encrypt the data, including passwords, before it was put in the database.&lt;/p&gt;

&lt;p&gt;Mongoose is the preferred ORM to communicate with the database because we are using MongoDB. For authentication and authorization, the program additionally uses the passport and jwt packages.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Folder Structure&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Controllers&lt;/strong&gt;&lt;br&gt;
The controllers, which houses the business logic, is included in this.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The authenticationController.js file contains the middleware for "signup" and "login."
The "singup" middleware transmits the user's information to the succeeding middleware after saving the user's information to the database.
If not, an error is reported.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The "login" middleware verifies the user's identity using the specified email and password.&lt;br&gt;
If the user is located, the following middleware receives the user's information.&lt;br&gt;
If not, it reports an error.&lt;/p&gt;

&lt;p&gt;The following actions can be performed by the blogController.js: create a blog, delete a blog by an id produced by a certain user, alter blog properties by an id by the person who created the blog, get a blog by an id, increase the read count of the blog when viewed, etc.&lt;br&gt;
Additionally, it determines how long it takes to read a blog and retrieves every blog in the database.&lt;/p&gt;

&lt;p&gt;The userController.js is capable of carrying out these operations: retrieve a user by an id, change user properties by the user's id.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Middleware&lt;/strong&gt;&lt;br&gt;
The validation is housed in the middleware.&lt;br&gt;
Before signing up, the user must supply all required information, while the validateUser.js script checks to see if a token is included in the authorization headers before creating a blog. meaning that before publishing a blog post, the user must have registered and logged in.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Models&lt;/strong&gt;&lt;br&gt;
All of the input needed to create a blog post is specified in the BlogModel.js file.&lt;br&gt;
The userModel.js file outlines all the information needed to create a user.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Routes&lt;/strong&gt;&lt;br&gt;
Before adding the user to the database, authRoute.js verifies that the user has provided the necessary information. It also verifies that the user's information matches that in the database when the user logs in before issuing a token to the user.&lt;/p&gt;

&lt;p&gt;When a specific endpoint defined in the route is being called, the blogRoute.js merely applies the business logic defined in the blogContoller.js,&lt;br&gt;
When a certain endpoint specified in the route is being called, the userRoute.js merely implements the business logic provided in the userContoller.js.&lt;/p&gt;

&lt;p&gt;db.js&lt;br&gt;
All user and blog data is kept in the mongdb database, which is connected to using db.js.&lt;/p&gt;

&lt;p&gt;.env.example&lt;br&gt;
environment variable offers all the configuration-related data needed.&lt;/p&gt;

&lt;p&gt;app.js&lt;br&gt;
All of the application's files are combined into one file called app.js.&lt;/p&gt;

&lt;p&gt;The ReadMe file contains instructions on how to install the program and describes its features.&lt;/p&gt;

&lt;p&gt;Deployment on heroku &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install the heroku CLI so that it is accessible in the terminal. Log in to the app that will be deployed using the heroku CLI, for example, cd blog-api.
Type "heroku login" and then "heroku create" in the cmd window.
-Next, depending on the branch, type "git push heroku main" or "git push heroku master". Type "git branch" to find out the branch you are now editing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
Altschool Africa assigned this application as part of their grade. Please visit &lt;a href="https://github.com/dhamolahedonist/BloggingApi" rel="noopener noreferrer"&gt;https://github.com/dhamolahedonist/BloggingApi&lt;/a&gt; if you think the software needs further features.&lt;/p&gt;

</description>
      <category>emptystring</category>
    </item>
  </channel>
</rss>
