<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ernesto Jara Olveda on Medium]]></title>
        <description><![CDATA[Stories by Ernesto Jara Olveda on Medium]]></description>
        <link>https://medium.com/@enetoolveda?source=rss-e1fbf5206c1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*PE6nEJjkbzRAgkSM</url>
            <title>Stories by Ernesto Jara Olveda on Medium</title>
            <link>https://medium.com/@enetoolveda?source=rss-e1fbf5206c1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 05:07:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@enetoolveda/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Typescript the “what no body teaches you" series episode 1]]></title>
            <link>https://enetoolveda.medium.com/typescript-the-what-no-body-teaches-you-series-episode-1-c194e9eb675?source=rss-e1fbf5206c1------2</link>
            <guid isPermaLink="false">https://medium.com/p/c194e9eb675</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[node]]></category>
            <dc:creator><![CDATA[Ernesto Jara Olveda]]></dc:creator>
            <pubDate>Mon, 13 Sep 2021 14:58:54 GMT</pubDate>
            <atom:updated>2021-09-15T03:23:05.057Z</atom:updated>
            <content:encoded><![CDATA[<h4>Required Dependencies</h4><p>For this fist episode I am going to show you how to do a Generic Component. For this component All you’ll need is to have install</p><pre>$ npm i react react-dom &amp;&amp; npm i -D @types/react</pre><p>Let’s start with `import React from &quot;react&quot;;`</p><p>Next the first thing is to define a generic type that will be useful for any html component</p><pre>type HTML = <em>keyof</em> JSX.IntrinsicElements;</pre><p>now we are going to the auto competition of all them html components, let’s use that into our components.</p><pre>interface GenericProps&lt;H=HTMLElement&gt; extends React.HTMLAttributes&lt;H&gt; {<br>    html: keyof JSX.IntrinsicElements;<br>}</pre><p>The component would be some sort of small and it looks like this:</p><pre>const Generic: React.FC&lt;GenericProps&gt; = props=&gt; {<br>   const { html: Tag, …attributes } = props;<br>   return &lt;Tag {…attributes} /&gt;;<br>};</pre><p>we just set them default props and export it and we is done.</p><pre>Generic.defaultProps = {<br>   tag: &quot;section&quot;,<br>};</pre><pre>export default Generic;</pre><p>if you did it as I did you. have some like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PG090BkkejaCTUw9JvHnsg.png" /></figure><p>now to use it you have to pass a prop call html which is any html tag.</p><pre>&lt;Generic html=&quot;a&quot; /&gt;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c194e9eb675" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PWA and Create React App]]></title>
            <link>https://enetoolveda.medium.com/pwa-and-create-react-app-4f854401fa5d?source=rss-e1fbf5206c1------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f854401fa5d</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[service-worker]]></category>
            <category><![CDATA[pwa]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[progressive-web-app]]></category>
            <dc:creator><![CDATA[Ernesto Jara Olveda]]></dc:creator>
            <pubDate>Sat, 20 Mar 2021 00:32:58 GMT</pubDate>
            <atom:updated>2021-03-20T00:32:58.272Z</atom:updated>
            <content:encoded><![CDATA[<p>We are going to create a progressive web app with CRA. the code will be at the end</p><p>To begin with let’s start a new cra.</p><pre>$ <strong>npx</strong> create-react-app wb-example <strong>&amp;&amp; cd</strong> wb-example</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/312/1*dior6jIQFiIRMN5JiZpHIg.png" /></figure><p>CRA on the newstest versions remove the <strong><em>serviceWorker.js, </em></strong>so let’s start with it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/336/1*w8vJsKqAs8v8SdOiAOTyuA.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2f8cb279dadd4494c327abddac0bd4b7/href">https://medium.com/media/2f8cb279dadd4494c327abddac0bd4b7/href</a></iframe><p>Copy the above code and paste it on yow <strong><em>serviceWorker.js. </em></strong>That code will let you register a service-worker on localhost.<br>Modified your index.js</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*XHNW_VF1uCqZv-PzkEXMZA.png" /></figure><pre><strong><em>// ADD THE IMPORT AT THE TOP</em></strong><br><strong>const</strong> config <strong>= {</strong><br>  /** <strong>@param</strong> <strong>{ServiceWorkerRegistration}</strong> registration */<br>  onSuccess<strong>: (</strong>registration<strong>) =&gt; {</strong><br>    <strong>console.log(</strong><em>&quot;onSuccess&quot;</em>, registration<strong>);</strong><br>  },<br>  /** <strong>@param</strong> <strong>{ServiceWorkerRegistration}</strong> registration */<br>  onUpdate<strong>: (</strong>registration<strong>) =&gt; {</strong><br>   <strong>console.log(</strong><em>&quot;onUpdate&quot;</em>, registration<strong>);</strong><br>  }<br>}<br><strong>register(</strong>config<strong>);</strong></pre><p>Now we have it as it used to be. it’s time to really work on what we came here</p><p>create a file call <strong><em>./src/service-worker.js</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/322/1*iUJk9Ng0pjlK0haXiK486A.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/946363cc6c53b5c81b809718d20dcd3e/href">https://medium.com/media/946363cc6c53b5c81b809718d20dcd3e/href</a></iframe><p>build yow code</p><pre>npm run build</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/359/1*SgGjFHqMrptoJq0CDsGsaw.png" /></figure><p>now you can</p><pre>$ serve -s build</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f854401fa5d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to get the Profile Pic of instagram w/out anything else than a pc.]]></title>
            <link>https://enetoolveda.medium.com/how-to-get-the-profile-pic-of-instagram-w-out-anything-else-than-a-pc-c690006f88fc?source=rss-e1fbf5206c1------2</link>
            <guid isPermaLink="false">https://medium.com/p/c690006f88fc</guid>
            <category><![CDATA[instagram]]></category>
            <category><![CDATA[profile]]></category>
            <category><![CDATA[photos]]></category>
            <dc:creator><![CDATA[Ernesto Jara Olveda]]></dc:creator>
            <pubDate>Mon, 04 Jan 2021 14:08:51 GMT</pubDate>
            <atom:updated>2021-01-04T14:08:51.597Z</atom:updated>
            <content:encoded><![CDATA[<p>first of all I want to mention that the next content is only for learning purposes and I will not be responsable for your actions. As Instagram/facebook have copyright on yow sh*t. Let’s start.</p><p>I will be the victim I mean the I’ll use my profile as example go to <a href="https://www.instagram.com/enetojara/?hl=es-la">https://www.instagram.com/enetojara</a></p><p>once you get into my profile hit the follow button. <br>xDD I’m just kidding, do it if you could get the pic.</p><p>Next thing you have to do is….</p><h4>NOTE</h4><p>forgot to mention that to do this you need to be on a computer it doesn&#39;t work on phones and stuff.</p><p>… on my profile do a right click an select the option “inspect”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AJpbMJpSdtzPbVSNlNld8A.png" /></figure><p>something like that will appear. then with that thing open make sure to reload the page, you can do so by pressing the “F5” or clicking the rounded arrow next to the little house on the top of the browser.</p><p>Now on at the inspect section find the “Console” tab</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4jzrv1M27LZAo8iTYYHLvA.png" /></figure><p>in my case it is next to elements if by any reasons you do not see it all the way to the right there are 3 dots click on them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/316/1*qUFEPpV7N1RIodyqIMyU3g.png" /></figure><p>click where it says show console drawer</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J0Irbd4Fws4VZk9SVOGANA.png" /></figure><p>bunch of crap will come out don&#39;t worry click on the icon that looks like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/24/1*9xt9OZp3Y5FPmtR1Nso22Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/130/1*bML_owXZzsuC-ZBXR1DPLw.png" /></figure><p>you&#39;ll find it at the left side of your screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yoi5hvbDMG9bkAceopH_4w.png" /></figure><p>now with the console clean we is ready to hit some commands on it. click on the little arrow it is bellow the clean button we just pressed. you’ll see that it is blinking just like an input field and that&#39;s what we are going to do we are going to type “_sharedData” hit enter</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/329/1*720M2GpbOX-z8jZ3hHjjdw.png" /></figure><p>something like this will appear expand it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/753/1*Wk1UAOmLJyJRhH3hURAqgQ.png" /></figure><p>among that something call “entry_data” will be click on it. It contains the “ProfilePage”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/276/1*45r-SZHN9M8v0aZ5kqmRzQ.png" /></figure><p>expand that as well</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/396/1*XntqGbQLQFUo6m2ncRwvEw.png" /></figure><p>also expand the “0” then you’ll be able to see something call user click on it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*INVNsROQ9W-KVk1wWci-Ww.png" /></figure><p>once you expand user find where it says “profile_pic_url”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/270/1*7mfYfq10Si9umpBF8rj1Aw.png" /></figure><p>now with your skills of copy paste copy the url of profile_pic_url_hd, once you copy it go open a new tab and paste the link there</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YWKP5dnbxTOt6rrnee-sUA.png" /></figure><p>tara! there you have it, now go back to my profile and follow me xDDD.</p><p>once again this is only for study purposes I am responsible for nothing.</p><p>bye.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c690006f88fc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Get Remove them ORMs from your Projects.]]></title>
            <link>https://enetoolveda.medium.com/get-remove-them-orms-from-your-projects-523bd567408c?source=rss-e1fbf5206c1------2</link>
            <guid isPermaLink="false">https://medium.com/p/523bd567408c</guid>
            <category><![CDATA[object-oriented]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Ernesto Jara Olveda]]></dc:creator>
            <pubDate>Mon, 04 Jan 2021 13:24:47 GMT</pubDate>
            <atom:updated>2021-01-04T13:24:47.776Z</atom:updated>
            <content:encoded><![CDATA[<p>I mean our connector will be kind of basic, do not over hope or you will end up disappointed xDDD.</p><p>Our project will have the following structure.</p><pre>src/<br>-- mysql<br>---- mysql.ts<br>---- pool-connector.ts<br>package.json<br>tsconfig.json</pre><p>b4 we start we need to install some dependencies.</p><pre>npm i -D @types/mysql @types/node tslib typescript &amp;&amp; npm i mysql</pre><p>our mysql functions will be at the mysql.ts file, which has the following structure.</p><pre>export abstract class MySQL {<br>  private _pool: mysql.Pool;<br>  <br>  protected constructor (config);</pre><pre>  private getConnection ();<br>  private runQuery (connection,sql,opts);<br>  private beginTransaction (connection);<br>  private commitTransaction (connection);</pre><pre>  protected read (sql, opts);<br>  protected write (sql, opts);</pre><pre>}</pre><p>yes it is right we are going to use an abstract class &lt;/3</p><p>the private attribute <strong><em>_pool</em></strong> will be the one dispatching them connections.</p><h4>Private methods</h4><ul><li><strong>getConnection </strong>— gets a connection from the pool.</li><li><strong>runQuery</strong> — executes an sql statement.</li><li><strong>beginTransaction</strong> — as the name says.</li><li><strong>commitTransaction</strong> — write data into them tables.</li></ul><p>Those methods are for internal use only it is why they are “private” and</p><h4>Protected Methods</h4><ul><li><strong>read </strong>— runs none transactional sql statements such as selects.</li><li><strong>write</strong> — runs transactional sql statements such as inserts.</li></ul><p>read and write are only accessible by the sons of our class it is why they are “protected”</p><p>with that been said.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e693b234751f17db178d730925ebc560/href">https://medium.com/media/e693b234751f17db178d730925ebc560/href</a></iframe><p>Next the son of our connector. The son class does not do sh*t or at least it shouldn’t implement anything it only defines the unfamous <strong><em>what </em></strong>the how will be implemented on great sons of our mysql class xDD xDD xDD. I mean yow bros I did not invent POO</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uH4KOZvOVlMbQZOrPbQpTw.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fae62de678d795e97090c95072023336/href">https://medium.com/media/fae62de678d795e97090c95072023336/href</a></iframe><p>OKi just like in every other orm we have the save, findby … … bla bla bla.</p><p>now let’s create the <strong>accounts</strong> class and to do so we are going to start with the interface for this example is going to be some kind of simple</p><pre>export interface AccountsProps {<br>  id: number;<br>  name: string;<br>  last: string;<br>}</pre><p>now the class</p><pre>export class Accounts extends PoolConnector&lt;AccountsProps&gt; {</pre><pre>}</pre><p>if we do so youll see that vscode or any other code editor will complain bcuz you need to implement them methods</p><p>once you implement them the error will be gone</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c2a3aed0e0523633472c3c6906962cec/href">https://medium.com/media/c2a3aed0e0523633472c3c6906962cec/href</a></iframe><p>I Hope it can help by any means.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=523bd567408c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fetch ES6 Class]]></title>
            <link>https://enetoolveda.medium.com/fetch-es6-class-7ca54ef8ec59?source=rss-e1fbf5206c1------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ca54ef8ec59</guid>
            <category><![CDATA[fetch]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[class]]></category>
            <category><![CDATA[es6]]></category>
            <dc:creator><![CDATA[Ernesto Jara Olveda]]></dc:creator>
            <pubDate>Mon, 04 Jan 2021 11:42:17 GMT</pubDate>
            <atom:updated>2021-01-04T11:42:17.792Z</atom:updated>
            <content:encoded><![CDATA[<p>If you do not need to support them ugly browsers out there. IE you know we are talking about you. npm package and git repo will be at the end. lets start.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PX0az84lP5a1pUEf" /><figcaption>Photo by <a href="https://unsplash.com/@giorgiotrovato?utm_source=medium&amp;utm_medium=referral">Giorgio Trovato</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Let’s start by defining the methods that our class will have:</p><h3>Methods</h3><h4>request</h4><p>A method in which you can customise the request</p><h4>uploadFile</h4><p>This method will send a file to backend.</p><h4>cacheFirst</h4><p>We first check if this url is already fetched if so, we just return it, else we trigger the <em>HTTP</em> request then we cached the result if it doesn&#39;t have an error.</p><h4>GET</h4><p>The <em>HTTP GET</em> method requests a representation of the specified resource. Requests using <em>GET</em> should only be used to request data <strong>they shouldn’t include data</strong>.</p><h4>Post</h4><p>The <em>HTTP POST</em> method sends data to the server. The type of the body of the request is indicated by the `<em>Content-Type</em>` header.</p><blockquote>The difference between <strong>PUT</strong> and <strong>POST</strong> is that PUT is idempotent: calling it once or several times successively has the same effect that is no side effect, where successive identical <strong>POST</strong> may have additional effects, like passing an order several times.</blockquote><h4>Delete</h4><p>The <em>HTTP DELETE</em> request method deletes the specified resource.</p><h4>Put</h4><p>The <em>HTTP PUT</em> request method creates a new resource or replaces a representation of the target resource with the request payload.</p><h4>Patch</h4><p>The <em>HTTP PATCH</em> request method applies partial modifications to a resource.</p><p><em>PATCH</em> is somewhat analogous to the <strong>update</strong> concept found in `<em>CRUD`</em> (in general, <em>HTTP</em> is different than <em>`CRUD`</em>, and the two should not be confused).</p><p>A <em>PATCH</em> request is considered a set of instructions on how to modify a resource. Contrast this with <em>PUT</em>; which is a complete representation of a resource. A <em>PATCH</em> is not necessarily idempotent, although it can be. Contrast this with <em>PUT</em>; which is always idempotent. The word <strong>idempotent</strong> means that any number of repeated, identical requests will leave the resource in the same state.</p><p>For example if an <strong>auto-incrementing</strong> counter field is an integral part of the resource, then a <em>PUT</em> will naturally overwrite it (since it overwrites everything), but not necessarily so for <em>PATCH</em>. <em>PATCH</em> (like <em>POST</em>) may have side-effects on other resources.</p><p>So far our class looks like this:</p><pre>class Fetch {</pre><pre>public request();<br>public uploadFile();<br>public cacheFirst();<br>public get();<br>public post();<br>public put();<br>public delete();<br>public patch();</pre><pre>}</pre><pre>export default Fetch;</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/463deb6301690b55e04f1277d93d89a7/href">https://medium.com/media/463deb6301690b55e04f1277d93d89a7/href</a></iframe><p>There once you copy the class the way to implement it is very easy. let’s create the user class</p><pre>class UserApi extends Fetch {</pre><pre>  public login (username:string, password: string) {<br>     return this.post(&quot;https://www.url.com/api/login&quot;,   {username,password})</pre><pre>  }<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ca54ef8ec59" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create an upload file like a champ using React]]></title>
            <link>https://enetoolveda.medium.com/create-an-upload-file-like-a-champ-using-react-8606f4913353?source=rss-e1fbf5206c1------2</link>
            <guid isPermaLink="false">https://medium.com/p/8606f4913353</guid>
            <category><![CDATA[es6]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[file-sharing]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[upload]]></category>
            <dc:creator><![CDATA[Ernesto Jara Olveda]]></dc:creator>
            <pubDate>Mon, 03 Aug 2020 17:09:02 GMT</pubDate>
            <atom:updated>2020-08-06T20:30:28.549Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*ki4BbYYdS-CsrgulOK5Htw.png" /></figure><p>Youll find the code at the end.</p><p>Here I am again, this pandemic left me w/out a job so I have free time and of course a bunch of bills to pay…</p><p>In today’s adventure I’ll help you with and upload file/image button built on <strong><em>create-react-app.</em></strong></p><h4>NOTE: Styles go on you xD</h4><pre>$ create-react-app appname</pre><p>Oki then, once all the lovely dependencies and stuff are downloaded, create a new file I called it ./src/upload.js</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/805/1*RIxnm_HZnui3tZj3bqOiZw.png" /><figcaption>The code is at the bottom</figcaption></figure><p>Inside your file create a component I named mine ImageUpload. <br>We are going to do it only with images, but It’ll work for any file… maybe ;3</p><p>go to google.com and grab a defaults user profile pic like the one in facebook.</p><p>We add to properties into our state:</p><ul><li><strong><em>file: </em></strong>This is what we are going to send to backend</li><li><strong><em>imagePreviewUrl</em></strong>: we convert the blob to display the image we choose.</li></ul><p>Well to upload a file first we need and input of type file add it to the return method</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/1*NNpxrqiCQkByb1nxGHHdTw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/1*mPYY71LCPKFL0Kl2rW76AA.png" /></figure><p>As you might notice it Im mexican, there for my browser is in spanish.<br>To play around with this input lets create a ref.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*zvZfcQy4YzkKGYqQB6qP4w.png" /></figure><p>With the ref know we can interact with the input via react and stuff.</p><p>So now that we have that let us do the handler.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*HXy2e37IJQLwBHSZ8YxkDw.png" /></figure><p>For some excuses I mean for security purposes the path of the pic is been hidden so you dont see where the pic at so when the <strong><em>onChange </em></strong>event triggers it comes with a fake path.</p><p>event triggers and in the parameter we get from the window, there is an object call target, with it comes and array of files… maybe, thats why we first check if file is not undefined, if not we tell the reader to read the content as a dataURL. then the onloaded callback is call</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/483/1*c7Oy8vqnzr7hGNL4fcurbA.png" /></figure><p>once it loads it has a result property we set it to our image preview and the file to our file let’s see it… not just yet, we need a image preview thingy.</p><p>under our input lets put an img tag and set the value equals to the preview state</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/1*ewlyN7IqjWVEvNktqMiuwQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/1*c1iIDLptFooq9h7p1rjiDg.png" /></figure><p>so add a pic to it, click on it and choose yow pic</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*KNspta0v91F44m0JWuQXXA.png" /></figure><p>It is done by that, but lets do lil more in heaw. open the app.css and hide the input</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/447/1*yyL3qeH37x4NavnPblrekQ.png" /></figure><p>any where it can fit, it is just to not show the input xDDD this is why we created the ref</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/1*KuRy-dnFhH2jVSRI-A3Uhw.png" /></figure><p>now the input is not displayed, then add a button at the bottom of your jsx.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*7hTfO-p-mecKW8Iql8eL6Q.png" /></figure><p>as the input “does not” exists anymore we need to fake a click on the button, in our button xDDD we click a button with another button TROLL xDD</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/1*jEMjaPzoJfL8IpgrfmwIag.png" /></figure><p>but then what if I choose a wrong pic just like I did, I need to be remove lets hndle that</p><p>first create and If component</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*pjKMQS-eWsJbz4FQHJfeag.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*vfkweZmgGDKmAm9JE_HHqQ.png" /></figure><p>we add the remove handler and. it sets the file to null and put default pic back.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*7H78lgYXFg1KPY_NFNNW9g.png" /></figure><p>we can call it a done</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/258/1*LmlXs9HSIYZX5bHNRUnW9g.gif" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/79ce070b9af64eacb762e07c9da2b1f0/href">https://medium.com/media/79ce070b9af64eacb762e07c9da2b1f0/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8606f4913353" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Make your own slider on ReactJS]]></title>
            <link>https://enetoolveda.medium.com/how-to-make-your-own-slider-on-reactjs-a54fce1a89e2?source=rss-e1fbf5206c1------2</link>
            <guid isPermaLink="false">https://medium.com/p/a54fce1a89e2</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[slider]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[carousel]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Ernesto Jara Olveda]]></dc:creator>
            <pubDate>Sat, 18 Jul 2020 02:23:44 GMT</pubDate>
            <atom:updated>2020-07-18T02:27:06.478Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SCy7KifytrRrQ7AOze3_zw.jpeg" /><figcaption>I also do not know why this picture is here, was the first one that medium showed.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*anOiKRY2LBGvUTXEVEhKkQ.png" /></figure><p><a href="https://gist.github.com/EnetoJara/2aaf1dff3cbf31df50d0a923d2a91805">code</a><br>If you are not very good as css just like me. I recommend you to use <a href="https://animista.net/">animista</a>, they do not pay me, but I do not pay them as well and this is kind of my way to show my gratitude. xDDD.</p><p>and as I do not have pictures I’ll be using <a href="https://placeholder.com/">placeholder</a>, same as above.</p><p>well on your react project create the file of your slider.</p><pre>import React from &quot;react&quot;;</pre><pre>export function Slider (props) {<br>  const { pics } = props;<br>  <em>const</em> [current, setCurrent] = React.useState(0);</pre><pre>  return (<br>   ...<br>  );</pre><pre>}</pre><p>Now days with them hooks everybody forgot about classes. ohh but if you have them what closure, scope and/or context are, we just say whatever wikipedia told us to say in the interview… well let’s continue.</p><p>The component expects an array of pictures, so let’s define it.<br>For the pictures we need.</p><ul><li>Path to where the pic at… :3</li><li>Unique id as react b*tchs about errthing.</li><li>and for SEO to be happy an alt text.</li></ul><p>So our “Interface” looks like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/336/1*8pUHfq5QfAqX-fmnt8YBxg.png" /></figure><pre><em>export</em> <em>interface</em> Pics {<br>  id: number;<br>  path: string;<br>  alt: string;<br>}</pre><p>So if the Component expects an array of pics then its interface might look like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/446/1*cccbHmwtI9B2oX3p6zTGqg.png" /></figure><p>That been said. here is the array pics the component will get.</p><pre><em>const</em> pics = [</pre><pre>{ id: 1, path: &quot;https://via.placeholder.com/600x350.png/20c997&quot;, alt: &quot;some alt and stuff1&quot; },</pre><pre>{ id: 2, path: &quot;https://via.placeholder.com/600x350.png/17a2b8&quot;, alt: &quot;some alt and stuff2&quot; },</pre><pre>{ id: 3, path: &quot;https://via.placeholder.com/600x350.png/20c997&quot;, alt: &quot;some alt and stuff3&quot; },</pre><pre>{ id: 4, path: &quot;https://via.placeholder.com/600x350.png/28a745&quot;, alt: &quot;some alt and stuff4&quot; },<br>{ id: 5, path: &quot;https://via.placeholder.com/600x350.png/08a745&quot;, alt: &quot;some alt and stuff5&quot; },<br>{ id: 6, path: &quot;https://via.placeholder.com/600x350.png/44a745&quot;, alt: &quot;some alt and stuff6&quot; },</pre><pre>];</pre><pre>....<br><strong><em>// Let’s first get the length of them pics</em></strong><br>const {length} = pics;</pre><pre><strong><em>// Then lets iterate over the array to display them pics</em></strong><br>const slides = pics.map((pic, index) =&gt; {<br>  &lt;div <em>key</em>=<em>{</em>item.id<em>}</em> <em>className</em>=<em>{</em>current !== index ? &quot;mySlides&quot; : &quot;current&quot;<em>}</em>&gt;<br>  &lt;div <em>className</em>=&quot;numbertext&quot;&gt;<br>   <em>{</em>index<em>}</em> / <em>{</em>length<em>}<br>  </em>&lt;/div&gt;<br>  &lt;img <em>src</em>=<em>{</em>item.path<em>}</em> <em>alt</em>=<em>{</em>item.alt<em>}</em> /&gt;<br>   &lt;span <em>className</em>=&quot;brand&quot;&gt;Name Of Your Site&lt;/span&gt;<br> &lt;/div&gt;<br>});</pre><pre>return (<br>....<br>)<br>....</pre><p>As it looks like 💩 here the pic</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P-a8JB84nxhqbsYaHv2rJQ.png" /></figure><p>now lets do the even handler aka the two arrows that will change the pic.</p><p>here the pic</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/1*rLbTkHKpaUdz-1mNlq0tJA.png" /></figure><p>First we prevent the default… I do not know I learned that on JQuery, it is one of them habits you kept by the time xDDDD. as I’m a lazy ass and do not want to do the useRef and all that crap, I just named the targets “plus” and “minus” 😆 and the rest you know it.</p><pre><em>const</em> onPicChanger = evt =&gt; {</pre><pre>evt.preventDefault();</pre><pre><em>const</em> { name } = evt.currentTarget;</pre><pre><em>const</em> operation = name === &quot;plus&quot; ? 1 : -1;</pre><pre><em>const</em> toShow = operation + current;</pre><pre><em>if</em> (toShow &gt;= length) {</pre><pre>setCurrent(0);</pre><pre>} <em>else</em> <em>if</em> (toShow &lt; 0) {</pre><pre>setCurrent(length - 1);</pre><pre>} <em>else</em> {</pre><pre>setCurrent(toShow);</pre><pre>}</pre><pre>};</pre><p>also if you click on the image from the bottom the current pic will change to that one, so let’s do that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*EKvB5Cp0gjNYYhkRV5aTog.png" /><figcaption>yes I use typescript and I believe everybody should do the same.</figcaption></figure><p>Again I’m lazy and for some I’m also consider fat, well who cares. let’s move on.</p><p>The pics from the bottom.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*sXCoL8PUleI7sCgbTKq2_Q.png" /></figure><p>here the code to be copied and pasted.</p><pre><em>const</em> thumn = pics.map((pic, index) =&gt; (</pre><pre>&lt;div <em>className</em>=&quot;column&quot;&gt;</pre><pre>&lt;button</pre><pre><em>type</em>=&quot;button&quot;</pre><pre><em>className</em>=<em>{</em>current === index ? &quot;demo active&quot; : &quot;demo&quot;<em>}</em></pre><pre><em>onClick</em>=<em>{</em>setImage<em>}</em></pre><pre><em>name</em>=<em>{</em>`<em>${</em>index<em>}</em>`<em>}</em></pre><pre>&gt;</pre><pre>&lt;img <em>src</em>=<em>{</em>pic.path<em>}</em> /&gt;</pre><pre>&lt;/button&gt;</pre><pre>&lt;/div&gt;</pre><pre>));</pre><p>Now lets create the return.</p><pre>return (<br>  &lt;div <em>className</em>=&quot;carrousel-container&quot;&gt;<br>    <em>{</em>slides<em>}<br>    </em>&lt;button<br>      <em>type</em>=&quot;button&quot;<br>      <em>className</em>=&quot;prev&quot;<br>      <em>onClick</em>=<em>{</em>onPicChanger<em>}<br>      name</em>=&quot;minus&quot;&gt;<br>        &amp;#10094;<br>    &lt;/button&gt;<br>    &lt;button<br>      <em>type</em>=&quot;button&quot;<br>      <em>className</em>=&quot;next&quot;<br>      <em>onClick</em>=<em>{</em>onPicChanger<em>}<br>      name</em>=&quot;plus&quot;&gt;<br>        &amp;#10095;<br>    &lt;/button&gt;<br>   &lt;div <em>className</em>=&quot;carrousel-row&quot;&gt;<br>     <em>{</em>thumn<em>}<br>   </em>&lt;/div&gt;<br>&lt;/div&gt;<br>);</pre><p>I mean the BigO notation might be crying with it, but it fulfill the acceptance criteria the smart ones will say.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7f27682099b8b574e25de1d62799dd2c/href">https://medium.com/media/7f27682099b8b574e25de1d62799dd2c/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a54fce1a89e2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Encrypt and Decrypt data with NodeJs crypto]]></title>
            <link>https://enetoolveda.medium.com/how-to-encrypt-and-decrypt-data-with-nodejs-crypto-a56fbba8fa19?source=rss-e1fbf5206c1------2</link>
            <guid isPermaLink="false">https://medium.com/p/a56fbba8fa19</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[crypto]]></category>
            <dc:creator><![CDATA[Ernesto Jara Olveda]]></dc:creator>
            <pubDate>Thu, 16 Jul 2020 19:14:00 GMT</pubDate>
            <atom:updated>2020-07-16T19:14:00.618Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ajkEBDPjgkkINq0_iapwAg.jpeg" /></figure><p>Today I will show you what every do not tells you when encrypting and decrypting.</p><p>Lets start by importing crypto, as that is what we need xDD.</p><pre>const crypto = require(&quot;crypto&quot;);</pre><p>Something very important that almost everybody do not tells you on their tutorials and stuff, is the fact that to decrypt you need the same keys and stuff you used to encrypt the data.</p><p>so if you see something like this:</p><pre><em>const</em> someVarName = crypto.randomBytes(16);</pre><p>you might be able to encrypt yow data, but wont be able to decrypted back, the reason lives on the “randomBytes” name. that things returns random bytes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PI_LAPhcAxJ0Nref" /><figcaption>Photo by <a href="https://unsplash.com/@patrickian4?utm_source=medium&amp;utm_medium=referral">Patrick Fore</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>and youll end up finding yourself on stackoverflow. trying to fix then SSL configs.</p><p>so in our file lets add our secret keys and stuff.</p><pre>const crypto = require(&quot;crypto&quot;);</pre><pre>const iv = process.env.PROD_IV || &quot;not-prod&quot;;<br>const iv = process.env.PROD_KEY || &quot;not-prod-ass-well&quot;;</pre><p>lets also add the algorithm we are going to use</p><pre>....<br><em>const</em> algorithm = &quot;aes-256-cbc&quot;;</pre><p>then put the hasher xDD this method is going to hash your secrets.</p><pre><em><br>function</em> scrypt (num, secret) {<br>  <em>return</em> <em>new</em> Promise((res, rec) =&gt; {<br>    <em>return</em> crypto.scrypt(secret, &quot;salt&quot;, num, (err, key) =&gt; {<br>      <em>if</em> (err) <em>return</em> rec(err);<br>      <em>return</em> res(key);<br>    });<br>   });<br>}</pre><pre>// https://nodejs.org/api/crypto.html#crypto_crypto_scrypt_password_salt_keylen_options_callback</pre><p>As long as we pass the same parameters into that function, we are going to get the same data.</p><p>for the iv and the key we do.</p><pre><em>...<br>function</em> getIv () {<br>  <em>return</em> scrypt(8, iv).then((response) =&gt; response.toString(&quot;hex&quot;));<br>}</pre><pre><em>function</em> getKey () {<br>  <em>return</em> scrypt(32, key).then((response) =&gt; response);<br>}</pre><p>Now let us create the encrypter</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9f0e2785adc4e2a859a377c4848e503b/href">https://medium.com/media/9f0e2785adc4e2a859a377c4848e503b/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lgDw1n0DGQzkzdXEm6c55A.png" /></figure><p>Lets do the decrypter as well… lets put the whole thing together</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/864d84dfa2311eca29aeecfa556dab9a/href">https://medium.com/media/864d84dfa2311eca29aeecfa556dab9a/href</a></iframe><h4>Remember!!</h4><p>If you do not want to endup looking at why the F* SSL is not working</p><p>Do not forget to use the same iv and key for both methods</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a56fbba8fa19" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Download PornHub videos.]]></title>
            <link>https://enetoolveda.medium.com/how-to-download-pornhub-videos-c2ec166ce159?source=rss-e1fbf5206c1------2</link>
            <guid isPermaLink="false">https://medium.com/p/c2ec166ce159</guid>
            <category><![CDATA[videos]]></category>
            <category><![CDATA[free]]></category>
            <category><![CDATA[pornography]]></category>
            <category><![CDATA[ethical-hacking]]></category>
            <dc:creator><![CDATA[Ernesto Jara Olveda]]></dc:creator>
            <pubDate>Fri, 19 Jun 2020 17:04:51 GMT</pubDate>
            <atom:updated>2021-01-25T08:46:16.357Z</atom:updated>
            <content:encoded><![CDATA[<p>As we know on pornhub you are free to download their free videos, they even have a page full of ads…. I mean with the instructions to do so.<br>Or you can go to another websites and download tons of viruses! but no video.</p><blockquote>For that reason I’ll show you how to download the free videos.</blockquote><p>All you need is:</p><ul><li>Computer</li><li>Internet Connection</li><li>the link of the video you want</li><li>and of course.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/1*KtuN_pJfqeM4kmgG_mFfyw.png" /></figure><p>Imagine this is the page of the video you want.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I-trrcqjid5o9ILPVseAtA.png" /></figure><p>once you are on the page you want, right at the border of the video box… NOT IN THE VIDEO, OUT SIDE… on the white section of the image, right click on it. PS: Make sure you right click a section that is not a video or ads.<br>select the option <strong><em>inspect. </em></strong>The webTools will pop out.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gW6JBxqAQ06yYRhxyhR5-g.png" /><figcaption>donyt</figcaption></figure><p>dont worry, we do not need to know what is all that. Thats the Elements section, but we dont want this one. Look for <strong><em>“Console” </em></strong>click on it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X9sxM2ALkFRsoVonLeaWLQ.png" /></figure><p>youll get something like that. now lets clean all that.</p><p>write <strong><em>clear() </em></strong>and hit enter<strong><em>.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cXg5Bh8cU6QKxTVCyf8z-g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*nZiDLn07adioH6AoHcjvug.png" /></figure><p>NOW START TYPING “quality”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9l_xW6QOKH-AY5QhzlFRNA.png" /></figure><p>as you can imagine, those are the quality sizes of the video, choose the one you want. when you select the one you want hit enter. It returns the url where video is stored.</p><p>Edited:<br>select “qualityItems_RANDOM-strings” something like that will appear expand it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/271/1*UOWno58G2-nIHNAZkRXrIg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/879/1*VLzppz8MYad-myyhN_s7hQ.png" /></figure><p>Now use them copy paste skills you have gain all this time</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t-zyKJouel7GKfAwWDAEBg.png" /></figure><p>right click on the url and open on a new tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rhr9CzCG3XVPSbduRPV2rA.png" /></figure><p>now all you need to do is right click on the video and select save video as.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/1*eLlhT5ZP17M8Sb8NvAxcAA.png" /></figure><p>choose where you want to save the video, hit enter and wait for it to be downloaded.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/365/1*_jSyt3G-1fO_Wvw6E2C23g.png" /></figure><h3>I hope you enjoy it.</h3><h3><strong><em>Thanks for reading Do not forget to share it.</em></strong></h3><p>PS: want another page? leave a comment and I’ll take a look into it. I currently know how to do this on <strong><em>xnxx pornhub xvideos youjizz &amp; youporn</em></strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c2ec166ce159" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Handle Sequelize and Typescript like the Gods meant to!]]></title>
            <link>https://enetoolveda.medium.com/how-to-handle-sequelize-and-typescript-like-the-gods-meant-to-ba5a8d57d41c?source=rss-e1fbf5206c1------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba5a8d57d41c</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[sequelize]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Ernesto Jara Olveda]]></dc:creator>
            <pubDate>Sat, 23 May 2020 23:43:40 GMT</pubDate>
            <atom:updated>2020-05-23T23:43:40.890Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*61oYMIQQK-PpOfGnGpZfrw.jpeg" /><figcaption>troll</figcaption></figure><p>I do not have anything a gains the <strong><em>LEGACY decorators</em></strong>, but I just don’t like the 💩 they leave once you bundle the code it almost looks like <strong><em>PHP Code 😆 </em></strong>I’m joking I ❤️ Php in fact the most beautiful thing that I love of <em>PHP </em>is the fact that I have not ever used it b4. well let’s begin with this thing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vNuVmVq7X0xihnaN" /><figcaption>Photo by <a href="https://unsplash.com/@bernardhermant?utm_source=medium&amp;utm_medium=referral">Bernard Hermant</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>As always we first need to have a typescript project. so let us create our own.</p><pre>$ npm init -y</pre><p>that will generate a package.json with default values. Time to install dependencies</p><pre>$ npm i express body-parser cors sequelize pg-hstore pg</pre><p>As some of those repos don’t care about types. we need to get them types from @types</p><pre>$ npm i -D @types/node @types/express @types/body-parser @types/cors @types/bluebird typescript tslib</pre><p>We also install typescript and tslib.</p><p>at the root of your project create a folder call types</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/278/1*eo3oJNfwRO2Ddfadi8uXeA.png" /></figure><p>The name of the subfolders depend on you, but I always have a lib.d.ts file, thats where I usually set my env variables</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/824/1*C4-C5ifaqdgTmojE87hJfQ.png" /></figure><pre>/// &lt;reference <em>types</em>=&quot;node&quot; /&gt;<br>/// &lt;reference <em>types</em>=&quot;express&quot; /&gt;</pre><pre><em>declare</em> <em>namespace</em> NodeJS {<br>  <em>interface</em> ProcessEnv <em>{<br>    readonly</em> NODE_ENV: &quot;development&quot; | &quot;production&quot; | &quot;test&quot;;<br>    <em>readonly</em> PUBLIC_URL: string;<br>    <em>readonly</em> SERVER_DB_USER: string;<br>    <em>readonly</em> SERVER_DB_PASSWORD: string;<br>    <em>readonly</em> SERVER_DB_NAME: string;<br>    <em>readonly</em> SERVER_DB_HOST: string;<br>    <em>readonly</em> SERVER_DB_PORT: string;<br>    <em>readonly</em> SERVER_DIALET: &quot;mysql&quot; | &quot;postgres&quot; | &quot;sqlite&quot; | &quot;mariadb&quot; | &quot;mssql&quot; | undefined;</pre><pre>   }<br>}</pre><p>then inside types folder add a sub folder name it whatever you feel like: mine will be eneto-models.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/150/1*2fC7KA_wfucfUDHMKrjVTQ.png" /></figure><p>and inside of it create an index.d.ts file</p><p>in it we are going to declare our module.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/329/1*FikFVFabLn2n9t1XaDNbRw.png" /></figure><p>the name of the module does not have to match the name of the folder, but if it can have the same name, always go for it, I’ll just use a different name for the purpose of showing that it does not have to have the same name as my folder is call eneto-models and the module inside is call @eneto/models.</p><pre><em>interface</em> BaseAttributes {<br>   id: number;<br>   createdAt: Date;<br>   updatedAt: Date;<br>}</pre><p>as every single table is going to have those three columns and as I do not want to write them more than once I put them in side an interface</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/523/1*KJCHsG_xQlCyuKyjnt6KnQ.png" /></figure><p>Now let’s create our users “table”</p><pre><em>interface</em> UserAttributtes <em>extends</em> BaseAttributes {<br>  name: string;<br>  lastName: string;<br>  email: string;<br>}</pre><p>it might look like it only contains those three attributes, but in reality</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*4SM6nN1Falyy4raZo7qTsQ.png" /></figure><p>it has 6</p><pre><em>import</em> * <em>as</em> Bluebird <em>from</em> &quot;bluebird&quot;;<br><em>import</em> { BuildOptions, Model, Sequelize } <em>from</em> &quot;sequelize&quot;;</pre><p>At the very top import those types.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/593/1*al3_l7CkqEEX9SOJyuh5-A.png" /></figure><p>It’s time to add the two lil boys that will make the magic.</p><pre><em>interface</em> Entity&lt;T&gt; <em>extends</em> Model&lt;T, T&gt; {<br>   // If you have the eslint rule that no interface can be empty uncomment those three :3</pre><pre>  // id: number;<br>  // createdAt: Date;<br>  // updatedAt: Date;</pre><pre>}</pre><pre><em>type</em> Repository&lt;T&gt; = <em>typeof</em> Model &amp; {<br>   <em>new</em> (values?: object, options?: BuildOptions): Entity&lt;T&gt;;<br>};</pre><p>Now all you need to do on your actual code is to use those types. if by any means typescript cries because it is not able to find your types open your tsconfig.json</p><pre>.....<br>&quot;moduleResolution&quot;: &quot;node&quot;,<br>&quot;baseUrl&quot;: &quot;./node_modules&quot;,<br>&quot;paths&quot;: {<br>   &quot;*&quot;: [<br>       &quot;./*&quot;,<br>       &quot;./@types/*&quot;,<br>       &quot;../types/*&quot;<br>    ],<br>/*name of your module mine was @eneto/models*/<br>    &quot;@eneto/models&quot;: [<br>/*name of the path*/<br>       &quot;../types/eneto-models/*&quot;<br>     ]<br>},<br>....</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/074ed6bd32c87558dd17fb4e90101be3/href">https://medium.com/media/074ed6bd32c87558dd17fb4e90101be3/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba5a8d57d41c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>