<?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 Wahyu Endy Santoso on Medium]]></title>
        <description><![CDATA[Stories by Wahyu Endy Santoso on Medium]]></description>
        <link>https://medium.com/@endySantoso?source=rss-d56b2d4b5e4c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*_VPa3Bf58unOtezK.</url>
            <title>Stories by Wahyu Endy Santoso on Medium</title>
            <link>https://medium.com/@endySantoso?source=rss-d56b2d4b5e4c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 06:46:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@endySantoso/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[File path configuration with Jest & Nestjs]]></title>
            <link>https://medium.com/@endySantoso/file-path-configuration-with-jest-nestjs-f68a37e4369b?source=rss-d56b2d4b5e4c------2</link>
            <guid isPermaLink="false">https://medium.com/p/f68a37e4369b</guid>
            <category><![CDATA[unit-testing]]></category>
            <category><![CDATA[nestjs]]></category>
            <category><![CDATA[jest]]></category>
            <category><![CDATA[node]]></category>
            <dc:creator><![CDATA[Wahyu Endy Santoso]]></dc:creator>
            <pubDate>Tue, 06 Aug 2024 07:41:02 GMT</pubDate>
            <atom:updated>2024-08-06T07:41:02.257Z</atom:updated>
            <content:encoded><![CDATA[<p>Sometimes life is easy, and sometimes is hard. We face the morning and face the night. In life, we have a man &amp; woman, sea &amp; land, fire &amp; water, etc.. many things have an intersection.</p><p>As a programmer, we face this every day. sometimes is easy and sometimes is hard until very frustrating. For example, for me as a newbie developer, it’s hard for me to do unit testing in NestJs before.</p><p>Usually, I get error messages like this</p><pre>Cannot find module &#39;@users/users.service&#39; or its corresponding type declarations.</pre><p>the import path in unit testing is different from a normal import path.</p><p>I hope this article can help us to set up a file path configuration when we initiate a new project with nestJs.</p><ol><li>First, install the dependency<br><em>npm install — save-dev ts-jest </em><a href="http://twitter.com/types/jest"><em>@types/jest</em></a></li></ol><p>2. With the first project. we need to modify our tsconfig.json. We change the path of the base URL &amp; set the alias for each of our folders</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e6bpHyya4EeJIFfUtgkMjg.png" /></figure><p>With this, before we import the file from this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xo_2LIuSKAENsIOCy-fb5w.png" /></figure><p>We use the <a href="http://twitter.com/users">@users</a> alias to access files in the users folder. So every time we add a new folder module, we need to update our paths too.</p><p>3. Add a new tsconfig.spec.json in the root directory, with this config</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MeURpUT7N4Eg3Q-9dkiMwA.png" /></figure><p>4. update or create jest.config.js if not exist, we can add to the root directory</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lDfvuW_F3LUITBVCIprfJg.png" /></figure><p>Thats all… Congratz.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f68a37e4369b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Make HTTPS with Ec2, Docker, & Caddy]]></title>
            <link>https://medium.com/@endySantoso/make-https-with-ec2-docker-caddy-37cee41755ae?source=rss-d56b2d4b5e4c------2</link>
            <guid isPermaLink="false">https://medium.com/p/37cee41755ae</guid>
            <category><![CDATA[caddy-server]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[nestjs]]></category>
            <category><![CDATA[ec2]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Wahyu Endy Santoso]]></dc:creator>
            <pubDate>Wed, 17 Jan 2024 22:46:48 GMT</pubDate>
            <atom:updated>2024-01-17T22:46:48.059Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>PART 1</blockquote><p>We can create one Ec2 instance to run our server.</p><p>After setting up the Ec2, don’t forget to open the 80 &amp; 443 ports in security groups. These ports will be used with Caddy to generate the HTTPS protocol</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KwmE0W-XTARZDBMd3gMGhA.png" /></figure><p>we can try to connect to our instance from the terminal</p><p>Connect to Ec2 instance from local</p><pre># download .pem file from ec2 dashboard<br># move the .pem file into ~/.ssh<br># add ec2 key pair <br>    chmod 400 ~/.ssh/example_name.pem<br># connect to ec2 instance terimal<br>    ssh -i &quot;~/.ssh/example_name.pem&quot; ec2_User_Type@Public_IPv4_DNS<br>    example:<br>      ssh -i &quot;~/.ssh/nest-ec2-docker-test.pem&quot; ec2-user@ec2-54-255-201-129.ap-southeast-1.compute.amazonaws.com</pre><p>Since we are using Docker, we need a command for Docker setup in our instance</p><pre># sudo yum install docker <br># sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose<br># sudo chmod +x /usr/local/bin/docker-compose<br># docker-compose version<br># sudo chmod 666 /var/run/docker.sock</pre><p>Also, we set our Vscode to connect our ec2 instance, we only need to add these in ‘~/.ssh/config’</p><pre># example<br>Host nest-ec2-docker-test<br>  HostName ec2-54-255-201-129.ap-southeast-1.compute.amazonaws.com<br>  User ec2-user<br>  IdentityFile ~/.ssh/nest-ec2-docker-test.pem</pre><p>After that, we can connect directly from Vscode</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1HYZRpLWhbCxXZqDSt0HSw.png" /></figure><blockquote>PART 2</blockquote><p>After cloning <strong>your server repository</strong>, we need to try our docker configuration. After your docker-compose is successful. You can access the server from IP public ec2, but it will be an HTTP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/472/1*GYNNnP2M1h8sJfBY0FefzQ.png" /></figure><p>To use Caddy, we have 2 options:</p><ol><li>Execute Caddy directly</li><li>Using Docker Image. If you want to</li></ol><p>If you choose option 1, try to set up Caddy in your ec2 instance. Caddy Docs have a step by step to do that. You only need aware of your ec2 operating system. We have a few steps to use caddy.</p><ol><li>create a Caddyfile in a root project</li></ol><pre># make a domain / sub-domain that will be our HTTPS.<br># this domain will automatically redirect to our server that running locally in the ec2 instance<br><br>coba2.tatos.co.id {<br> reverse_proxy 127.0.0.1:3000<br>}</pre><p>2. register the new record</p><p>Open your domain configuration, and register a new record. The record will contain the IP public from the ec2 instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5VFT8ZolLoeiLzIXyQ5-jg.png" /></figure><p>3. execute the Caddyfile</p><pre>caddy run --config ./Caddyfile --watch</pre><p>after running this command, you can check your domain / sub-domain with <strong>https://</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZHFxNAmWkNKgyVw5bgQT-w.png" /></figure><p>Another way is to use Caddy with docker-compose like this,</p><pre># Example: add this into docker compose<br># Run the caddy server  <br>services:<br>  # existing service...<br>      <br>  caddy:<br>    image: caddy/caddy:2.2.1-alpine<br>    container_name: caddy-service<br>    restart: unless-stopped<br>    ports:<br>      - &quot;80:80&quot;<br>      - &quot;443:443&quot;<br>      - &quot;443:443/udp&quot;<br>    volumes:<br>      - ./Caddyfile:/etc/caddy/Caddyfile<br>      - ./site:/srv<br>      - caddy_data:/data<br>      - caddy_config:/config<br>    depends_on:<br>      - nest-docker-postgres<br><br>volumes:<br>  caddy_data:<br>  caddy_config: </pre><p>If something error when running docker-compose build. Maybe because port 443 is used by another service.</p><p>To check</p><pre># check 443 port<br>sudo netstat -tulpen |grep 443<br><br># kill 443 port<br>sudo kill -9 $(sudo lsof -t -i:443)</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=37cee41755ae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simple CI CD with GCP Cloud Build using Docker- part 2]]></title>
            <link>https://medium.com/@endySantoso/simple-ci-cd-with-gcp-cloud-build-using-docker-part-2-ffe29a233e70?source=rss-d56b2d4b5e4c------2</link>
            <guid isPermaLink="false">https://medium.com/p/ffe29a233e70</guid>
            <category><![CDATA[pipeline]]></category>
            <category><![CDATA[gcp]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Wahyu Endy Santoso]]></dc:creator>
            <pubDate>Mon, 23 May 2022 16:18:14 GMT</pubDate>
            <atom:updated>2022-05-23T16:18:14.507Z</atom:updated>
            <content:encoded><![CDATA[<p>Chill… take some drink and relax, this is a <a href="https://medium.com/@endySantoso/simple-ci-cd-with-gcp-cloud-build-using-docker-part-1-cf27bf3c2638"><strong>part 1</strong></a> of our chit chat</p><p>Glad to see you again… After doing some little things in part 1, we will continue to finish our pipeline</p><p>If you work with Docker, we can specify our pipeline to run that Docker file, just make a usual Docker file configuration &amp; <strong><em>setup the environment</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mrAkfGBqVZz-lRxg6kcjag.png" /></figure><p>after that, continue to create the <strong>.yaml </strong>file. This is like storytelling to our cloud builds, what need to do with our app, like:<br>- Build the container image<br>- Push the Docker container image to Container Registry<br>- Deploy Docker container image to Cloud Run<br>- etc</p><p>We can define a task with “<em>steps</em>”. When you confuse about it, please open this <a href="https://cloud.google.com/build/docs/configuring-builds/create-basic-configuration">link</a> and read slowly. Don&#39;t worry, you will understand that.</p><p>Task 1 — Build the container image</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gyuF13TGP_ERVIyZbGWUKw.png" /></figure><p>every step in the .yaml will be defined with name &amp; args. The name usually is already provided by GCP, we only need to change the args commands. It&#39;s like our command we run in the terminal. the difference is only we split the command from “white space”, and convert it into an array. So technically you can run that command in the terminal to test it</p><blockquote>build -t gcr.io/cv-data-collection/YOUR_PROJECT_NAME:$COMMIT_SHA — file=./Dockerfile-dev .</blockquote><ul><li>“<strong><em>build</em></strong>” command is a GCP command line in our terminal</li></ul><p>Task 2 — Push the Docker container image to Container Registry</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xLug1jcm5kp00ZQHKrtNbQ.png" /></figure><ul><li>“$COMMIT_SHA” is the local variable from the cloud build, we no need to change it</li></ul><p>Task 3 — Deploy Docker container image to Cloud Run</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9nVmEpGy9pA0xawLQY28Ew.png" /></figure><p>I think this is the most custom part of the command in our step, we need to define a GCP command that also can run in our terminal *like a step one.</p><blockquote>run deploy bipt-frontend-dev — image gcr.io/cv-data-collection/bipt-frontend-dev:$COMMIT_SHA — region asia-southeast2 — platform managed — port 8080 — allow-unauthenticated</blockquote><p>we need to define:<br>- a trigger cloud build name<br>- image location<br>- region<br>- port</p><p>Task 3 — define the Docker image location</p><p>This is a command outside the “steps”, just define a Docker image location in GCP</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZEo5n_UONhcCe0_uM-kjlw.png" /></figure><p>So our pipeline commands are ready and this is a sample for the .yaml file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MzcPqztoUEwLYViFqb5LlA.png" /></figure><p>After that, you can test your pipeline with a common Git lifecycle. To check if our pipeline is a success or failure, we can check our trigger in History Tabs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GdkB6PYgaQMZWKJ4RpWFfA.png" /></figure><p>Also, you can check the Cloud Run, your services will be there if your build is successful. And if you want to check the logger, that&#39;s will be available in your Cloud run services -&gt; Logs tab</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hsFFwFafL42bFd6V0-D_TQ.png" /></figure><p>Congratzzzz… and have a nice day</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ffe29a233e70" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simple CI CD with GCP Cloud Build using Docker- part 1]]></title>
            <link>https://medium.com/@endySantoso/simple-ci-cd-with-gcp-cloud-build-using-docker-part-1-cf27bf3c2638?source=rss-d56b2d4b5e4c------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf27bf3c2638</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[cloud-build]]></category>
            <category><![CDATA[gcp]]></category>
            <dc:creator><![CDATA[Wahyu Endy Santoso]]></dc:creator>
            <pubDate>Mon, 23 May 2022 09:45:25 GMT</pubDate>
            <atom:updated>2022-05-23T16:46:15.226Z</atom:updated>
            <content:encoded><![CDATA[<p>I believe everyone will absolutely like the concept of automation. Those are some concepts that will help our messy lives or give us extra time to do things.</p><p>like Tesla cars, if you want to go somewhere just need to do some settings and the car will run automatically.</p><p>Or if you have an injured spine, it’s like a massage chair that will cheer you up.</p><p>So everyone like automation, even in our frustrating job.<br>Like every time push GitHub, test, deploy, etc...</p><p>Many articles on Medium already talk about it and bring joy to us.</p><p>And I want to share my little note to do some CI/CD with nodejs &amp; GCP, hopefully, can help you at the correct time</p><p>if you create some App with Javascript event for Frontend or Backend. GCP has many interesting services for you.</p><p>It will be the same as using an API Gateway, Lambda, etc in AWS.</p><p>To do this in GCP we need to use some services like: <br>- Cloud run for hosting our app<br>- Cloud build for doing some automation for us<br>- A repository for storing our code like GitHub<br>- And also the .yaml file to specify our command</p><p>Open the GCP dashboard -&gt; Cloud Build and create some triggers.<br>Fill in the name and description for our build, like amazing_app-DEV, amazing_app-PROD, etc if you want to <strong>specify the build for every environment</strong>. Also checklist the “<em>Push to a branch</em>” in the Event section. <strong><em>This will specify our Cloud Build to do some pipeline every time a new code is pushed into our selected branch. </em></strong>Don&#39;t forget to select the nearest region from your current location.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iz9Q0lt99F95iUdiUceDuQ.png" /><figcaption>GCP cloud build</figcaption></figure><p>after that, scroll to the bottom a little bit, and select your <em>repository </em>and the<em> branch.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X1T75aaJjxI7Kb0axkxMzQ.png" /></figure><p>We can use a cloud repository or another repository like <a href="https://github.com/">GitHub</a> or <a href="https://bitbucket.org/">BitBucket</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qyTfdnHTanOPaDU4f-p1EQ.png" /></figure><p>Since we will specify our command pipeline in the <strong>.yaml</strong> file (*we have not yet created it), we need to checklist “<strong>Cloud Build configuration file (yaml or json)</strong>” and checklist the “<strong>Repository</strong>” in the location section.</p><p>Make sure you put a correct name file same as your <strong>.yaml</strong> file in your current directory project</p><p>This will be telling our Cloud Build to look at a command list in the .yaml file in our root directory project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0RUnhRIAh_Fz_kxaurtb4A.png" /></figure><p>After that, Save our cloud build and grab some drink…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf27bf3c2638" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simple spinner for your amazing Vue project]]></title>
            <link>https://medium.com/@endySantoso/simple-spinner-for-your-amazing-vue-project-d870db9ec646?source=rss-d56b2d4b5e4c------2</link>
            <guid isPermaLink="false">https://medium.com/p/d870db9ec646</guid>
            <category><![CDATA[endy-santoso]]></category>
            <category><![CDATA[vue-3]]></category>
            <category><![CDATA[vue]]></category>
            <category><![CDATA[vue-router]]></category>
            <category><![CDATA[spinner]]></category>
            <dc:creator><![CDATA[Wahyu Endy Santoso]]></dc:creator>
            <pubDate>Sun, 02 Jan 2022 13:52:43 GMT</pubDate>
            <atom:updated>2022-01-02T13:52:43.016Z</atom:updated>
            <content:encoded><![CDATA[<p>I believe you will be bored if you wait for something.. especially when you open the browser or the mobile apps, you waiting without something eye-catching</p><p>everyone wants fast, including you &amp; your project manager. 🤣</p><p>even you know what happens in the Back-End side, the complexity, must hit many end-point, etc..</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FiywZ2e4SwSuwU%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FiywZ2e4SwSuwU%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FiywZ2e4SwSuwU%2F200.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="202" frameborder="0" scrolling="no"><a href="https://medium.com/media/80be07757d21839325b683ceec76c2db/href">https://medium.com/media/80be07757d21839325b683ceec76c2db/href</a></iframe><p>you probably waiting to see this Nissan Skyline run on the road, you spend around 3 seconds and still see that nice car, this happens because that Gif presents something eye-catching.</p><blockquote>That’s what a Spinner will do on your application. It will be very nice for the user see something on the screen when waiting data is fetch</blockquote><p>There a 1 great resource to get a spinner HTML and the CSS, you can check in here: <a href="https://tobiasahlin.com/spinkit/">tobiasahlin.com/spinkit</a>.</p><p>This is a small todo list to make a spinner on our Vue project</p><ul><li>hide component until data fetch</li><li>add a property containing a boolean value on every component</li><li>hide / show that component based on that property property</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8WhgS2qEvPKTqYzGodvQGg.png" /><figcaption>simple code</figcaption></figure><p>We show a components based on <em>isReady </em>value and set a false as a default value, so the Spinner will always show when component is loaded. After the fetch process is finished in created method, we set <em>isReady </em>to true and the main component can finally show.</p><p>Btw this is only 1 component, how if we have many component? We can still use this <em>tricks</em> but we will waste our time because we need to copy a code and use the same pattern.</p><p>Luckily, we can use <a href="https://vuejs.org/v2/guide/mixins.html"><strong><em>mixins</em></strong></a> in Vue, with this we can set an initial data &amp; methods for all component that consume our mixins</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XDvqINKtHEpWRYPv79vgyw.png" /><figcaption>simple mixin</figcaption></figure><p>the mixin code its same like our vue components, it can contain all Vue data, method &amp; lifecycle. This will make out state is reusable</p><p>to use that mixin, we only add this one line on our components. After that we can use the state &amp; methods from our mixin</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7WgbUaXixRiS0Dw6TTmjnQ.png" /></figure><p>There’s will be a chance the same property name on the mixin and the component, you need caution about a name. usually, we add a unique name for the mixin property like mixinName_property.</p><p>I know this is a simple. If you want to look a code, please go <a href="https://github.com/pisangGoreng/vue-spinner">here</a></p><p>If you want more fancy, you can use <a href="https://www.npmjs.com/package/nprogress"><strong><em>nprogress</em></strong></a><strong><em>. </em></strong>With this, you can show a progess bar above on your page..</p><p>Thanks for coming, I really appreciate 🍻</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d870db9ec646" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Receive and Parse a CSV file with NestJs — Part 1]]></title>
            <link>https://medium.com/@endySantoso/receive-and-parse-a-csv-file-with-nestjs-part-1-15a6a31eeefc?source=rss-d56b2d4b5e4c------2</link>
            <guid isPermaLink="false">https://medium.com/p/15a6a31eeefc</guid>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[express]]></category>
            <category><![CDATA[nestjs]]></category>
            <category><![CDATA[endy-santoso]]></category>
            <category><![CDATA[node]]></category>
            <dc:creator><![CDATA[Wahyu Endy Santoso]]></dc:creator>
            <pubDate>Sun, 26 Dec 2021 08:41:24 GMT</pubDate>
            <atom:updated>2021-12-26T08:41:24.567Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Receive and Parse a CSV file with NestJs — Part 1</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WbUbyX1EWdLH5I-o" /><figcaption>Photo by <a href="https://unsplash.com/@p_kuzovkova?utm_source=medium&amp;utm_medium=referral">Polina Kuzovkova</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>If you learn typescript I think you are not a stranger anymore with NestJs, this is a powerful tool to help us develop a backend project. In this article we will try to receive a CSV file and parse it before storing it</p><p>In the first time, we need to generate our project, we can doing that with run.</p><pre>nest new project_na</pre><p>This command will help us to auto-generate our project.</p><p>With NestJs we can separate our modules &amp; make them modular, this is helpful when we work on large projects to simplify our code structure. And Nestjs already provide a few terminal commands to create modules, controller, service, etc.</p><p>To make it easier, we only create and use module &amp; controller</p><pre>npx @nestjs/cli g module asset</pre><pre>npx @nestjs/cli g controller asset</pre><p>In NestJs , we place all routers in our controller. But before doing that, we need to import the HTTP method decorators from Nestjs</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LSLblF9MMKdj2evUhaggxg.png" /></figure><p>We can do our job with a many ways, but in our case, we will do like this</p><p>1. Take a file, with a FileInterceptor</p><p>2. Save it into our local directory, with diskStorage</p><p>3. Read the file in local directory</p><p>4. Parse it</p><p>5. Store it</p><p><strong><em>FileInterceptor</em></strong> is a built-in decorators from <strong><em>@nestjs/platform-express</em></strong><em>, </em>we use this to receive the file from front end or <a href="https://www.postman.com/">postman</a>, but we need to decide a name property used. In our example we use the “<em>file_asset</em>” <em>name</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*psCOKSMU3Qy-mgvzR9YK_w.png" /><figcaption>postman</figcaption></figure><p>Now our server is ready to receive the file, we continue to save it into our local directory. To do that, we use the <strong><em>diskStorage</em></strong> from <a href="https://www.npmjs.com/package/multer">multer</a></p><blockquote>The disk storage engine gives you full control on storing files to disk.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/1*_j7EhHLjigbIT80Axm8Rpw.png" /><figcaption>code</figcaption></figure><p>When use <strong><em>diskStorage, </em></strong>we need to set a destination path for storing a files with destination property. With a combination of <strong><em>FileInterceptor</em></strong> and <strong><em>diskStorage </em></strong>our controller will looks like this.</p><p>we finished our code for step 1 and 2, next we will read a new file that sent into our server with <strong><em>readFileSync </em></strong>from <strong><em>fs</em></strong> package.</p><blockquote><strong>readFileSync</strong> will help us to reads the entire contents of a file, we just need a directory path of the file</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*F9r37GIdZkX6D0CEMSQKpw.png" /><figcaption>read file with readFileSync method</figcaption></figure><p>to parse the CSV file, there one really helpful package to do that. The name is <a href="https://www.npmjs.com/package/papaparse"><strong><em>papaparse</em></strong></a>, and we just need a <strong><em>parse </em></strong>method</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*plMfcXwjLY8Z5vd_3MXcFA.png" /><figcaption>parse the csv file with papaparse</figcaption></figure><p>Nice Job to you 👍, until this process, our server can receive the CSV file &amp; parse that data. We will continue to part 2 article to store to the Firebase.</p><p>I be back soon</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fh5ElOrUiWom3PGmhkB%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fh5ElOrUiWom3PGmhkB%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2Fh5ElOrUiWom3PGmhkB%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/11194929291905e93a4c34a5a9d5b1b2/href">https://medium.com/media/11194929291905e93a4c34a5a9d5b1b2/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=15a6a31eeefc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basic state management Vue]]></title>
            <link>https://medium.com/@endySantoso/basic-state-management-vue-267d3f05a17?source=rss-d56b2d4b5e4c------2</link>
            <guid isPermaLink="false">https://medium.com/p/267d3f05a17</guid>
            <category><![CDATA[state-management]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[endy-santoso]]></category>
            <dc:creator><![CDATA[Wahyu Endy Santoso]]></dc:creator>
            <pubDate>Sat, 25 Dec 2021 16:04:47 GMT</pubDate>
            <atom:updated>2021-12-25T16:04:47.226Z</atom:updated>
            <content:encoded><![CDATA[<p>after a few years in my journey in FE development, I try to use <a href="https://vuejs.org/">Vue</a> in my project. I think it’s easier to learn than react, but it’s just my personal opinion.</p><p>Btw… Anything framework we used on our project, even if you used another framework outside the Javascript language. We always need to know about how to <strong><em>change the data &amp; watch them</em></strong>.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FTI32JwHmWQEi4%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fknowledge-TI32JwHmWQEi4&amp;image=https%3A%2F%2Fmedia3.giphy.com%2Fmedia%2FTI32JwHmWQEi4%2Fgiphy.gif%3Fcid%3D790b7611763c00645d2e381fdd314cb29159c00579972173%26rid%3Dgiphy.gif%26ct%3Dg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="226" frameborder="0" scrolling="no"><a href="https://medium.com/media/3e25c3d903a87fc6977adf97ae0df8fe/href">https://medium.com/media/3e25c3d903a87fc6977adf97ae0df8fe/href</a></iframe><p>With that knowledge of how to do that in a specific framework, we can organize our state of data &amp; execute a method as needed</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e0j8kNtF6-aGGUgFJUka4Q.png" /><figcaption>Vue state</figcaption></figure><p>the simple state of Vue will look like this, we can use any type of data and use the props data (the data from the parent component). So everything inside the return is our state and we can use it in our Vue component.</p><p>To change the value in our state, we can simply run</p><pre>this.state_name = new_value</pre><p>notes:</p><ul><li>always remember to use this</li><li>we can run this command inside Vue methods like created, computed, watch, etc..</li><li>as far I know, this operation is Sync, so we no need to use promise or async /await syntax</li></ul><p>if we need to know the changed state, we can use the watch method, this is a built-in property from the Vue component</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*VlB48e93_O7WhRfiVdnYSg.png" /><figcaption>watch vue</figcaption></figure><p>we create a function inside the watch object. Usually, the function name will be the same as the state name inside the <strong>data()</strong>. in the above example, we will know every time the keyword state is changed &amp; and run our method. If you need to compare the old value and the new value, just simply add this parameter</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*8BjpjqjI95LtlcA68F2-LA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=267d3f05a17" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simple CRUD dengan Serverless Framework]]></title>
            <link>https://medium.com/@endySantoso/simple-crud-dengan-serverless-framework-5bc6f8e3b1f2?source=rss-d56b2d4b5e4c------2</link>
            <guid isPermaLink="false">https://medium.com/p/5bc6f8e3b1f2</guid>
            <category><![CDATA[serverless-framework]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Wahyu Endy Santoso]]></dc:creator>
            <pubDate>Wed, 23 Jan 2019 05:33:28 GMT</pubDate>
            <atom:updated>2019-01-23T05:33:46.629Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DIpg-kS0ZbdJ9XxThTp4kw.jpeg" /></figure><p>kalau kata seseorang yang namanya <a href="https://medium.com/u/8cb3ff087496">Kevin Dave</a>, sebetulnya sekarang sudah masuk ke ranah cloud computing.</p><p>Kita pakai bantuan <a href="https://serverless.com/">Serverless Framework</a> untuk membuat cloud function ke AWS.</p><p>Jadi step by step disini:</p><ul><li>Configurasi serverless.yml</li><li>Buat function nya</li><li>Tinggal Deploy</li></ul><h3><strong>1. Configurasi serverless.yml</strong></h3><p>Kita generate template untuk project kita, pakai command dari Serverless</p><pre>serverless create --template aws-nodejs </pre><p>Di project kita nanti akan ada beberapa file baru, yg perlu diperhatiin sekarang cukup <strong><em>serverless.yml.</em></strong></p><p>Ini file yang akan membantu menghubungkan Function yang kita buat nanti, dengan Cloud AWS. Btw format file nya .yml, Kalau bingung anggap aja ini seperti object JSON, cuman penulisan nya perlu pakai indentasi.</p><p>Coba kita edit serverless.yml seperti ini:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1e2810e4954729da79bb041c73167891/href">https://medium.com/media/1e2810e4954729da79bb041c73167891/href</a></iframe><p>Sebetulnya yang perlu kita perhatikan, cukup 3 bagian yaitu package, functions, plugins</p><p><strong>1. package -&gt; include</strong>, fungsi nya untuk memberi perintah ke serverless untuk mengcopy file yang ada di directory features &amp; models ke Cloud AWS. Kenapa? karena function CRUD yang akan kita buat, akan ada di dalam folder tersebut. Include akan otomatis mengcopy semua file ke Cloud AWS, jadi setiap ada penambahan project structure baru, WAJIB untuk mengedit bagian ini.</p><p><strong>2. functions, </strong>nah ini menu utama nya. Semua function yang kita buat akan kita definisikan juga disini. Apa aja yang di definiskan? Tentu nama function, lokasi function, event method, dll.</p><p><em>a. handler = </em>lokasi file yang ingin kita akses &amp; nama function nya</p><p><em>b. events -&gt; http -&gt; path</em> = URL address yang akan kita pakai untuk mengakses funcstion</p><p><em>c. events -&gt; http -&gt; </em>method = event method seperti get, post, put, delete, dll</p><p><strong>3. plugins</strong>, ini untuk list tool yang kita gunakan, selama pembuatan function, disini kita pakai <a href="https://www.npmjs.com/package/serverless-offline">serverless-offline</a> untuk mengetest function di local komputer kita.</p><h3>2. Buat function nya</h3><p>kita buat folder <em>features</em> untuk lokasi function CRUD .</p><p>a. features/read.js</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3a859819178a6eb5e617dc6490dfefb7/href">https://medium.com/media/3a859819178a6eb5e617dc6490dfefb7/href</a></iframe><p>b. features/create.js</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/10a2e5c44029633c6e0359a6ebd86f38/href">https://medium.com/media/10a2e5c44029633c6e0359a6ebd86f38/href</a></iframe><p>c. features/update.js</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/10bd337518fcef20543736dd880d5382/href">https://medium.com/media/10bd337518fcef20543736dd880d5382/href</a></iframe><p>d. features/delete.js</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a5ed1e411bc23290d053e328223d841f/href">https://medium.com/media/a5ed1e411bc23290d053e328223d841f/href</a></iframe><h3>3. Tinggal deploy</h3><p>Setelah konfiguasi serverless.yml &amp; membuat function, sekarang tinggal deploy, jalankan perintah ini di terminal root directory.</p><pre>serverless deploy</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i0tkAFXA7CqKkWggFh-Oqg.png" /><figcaption>serverless deploy</figcaption></figure><p>Setelah berhasil, di terminal akan ada bagian endpoints. Nah url yang di generate ini yang kita pakai untuk mengakses function yang kita buat.</p><p>Anyway, jika bingung &amp; ingin lihat2 bisa langsung ke repo <a href="https://github.com/pisangGoreng/simple-crud-serverless">ini</a>.</p><p>Terima Kasih</p><p>Semoga tidak mencerahkan, memang itu tujuan nya. Bye</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5bc6f8e3b1f2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Receh #1 — Cara mudah buat default value untuk function javascript]]></title>
            <link>https://medium.com/@endySantoso/receh-1-cara-mudah-buat-default-value-untuk-function-javascript-a84c22489806?source=rss-d56b2d4b5e4c------2</link>
            <guid isPermaLink="false">https://medium.com/p/a84c22489806</guid>
            <category><![CDATA[programmer-indonesia]]></category>
            <category><![CDATA[spread-operator]]></category>
            <category><![CDATA[javascript-tips]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Wahyu Endy Santoso]]></dc:creator>
            <pubDate>Sun, 20 Jan 2019 15:37:49 GMT</pubDate>
            <atom:updated>2019-01-20T15:37:49.282Z</atom:updated>
            <content:encoded><![CDATA[<h3>Receh #1 — Cara mudah buat default value untuk function javascript</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/934/1*8MzVRFu1WmG4B_-jI8ehFg.jpeg" /></figure><p>Receh ceh ceh….</p><p>Anyway, di dunia javascript biasanya kita butuh default value di dalam function. Ini bisa kita lakukan dengan beberapa cara, contoh:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fcf5ab48404336e3385ae56c06965b94/href">https://medium.com/media/fcf5ab48404336e3385ae56c06965b94/href</a></iframe><p>Secara otomatis, nilai parameter b <strong>jika</strong> tidak di isi akan menjadi 1.</p><p>Atau mau pakai logical operator juga bisa</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ab6687eab0ab3fd97017adf509b12018/href">https://medium.com/media/ab6687eab0ab3fd97017adf509b12018/href</a></iframe><p>Kalau mau kode nya lebih singkat, boleh pakai spread operator, Salah satu fungsi spread operator cuma untuk menggabungkan 2 variabel menjadi 1 array, CMIIW</p><p>Nah, jika implementasi nya dipakai untuk menggabungkan 2 object, apabila <strong>nama properti</strong> object nya sama, nilai nya akan otomatis tertimpa</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/99ab3a57a7454a87948ac1bc30179d4b/href">https://medium.com/media/99ab3a57a7454a87948ac1bc30179d4b/href</a></iframe><p>Semoga tidak mencerahkan, Bye</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a84c22489806" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Well,, ini yang katanya Async Await]]></title>
            <link>https://medium.com/@endySantoso/well-ini-yang-katanya-async-await-97169a8cb46f?source=rss-d56b2d4b5e4c------2</link>
            <guid isPermaLink="false">https://medium.com/p/97169a8cb46f</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[indonesia]]></category>
            <category><![CDATA[asyncawait]]></category>
            <category><![CDATA[promises]]></category>
            <category><![CDATA[es6]]></category>
            <dc:creator><![CDATA[Wahyu Endy Santoso]]></dc:creator>
            <pubDate>Sun, 18 Mar 2018 11:35:59 GMT</pubDate>
            <atom:updated>2018-03-18T11:35:59.059Z</atom:updated>
            <content:encoded><![CDATA[<p>Well… “Anjing,, kode gw panjang amat..”</p><p>Ini kata — kata mutiara sebelum ketemu yang namanya Async Await, dulu temen gw di kantor Ql*e yang namanya Eri Irawan yang sekarang sudah jadi bos travel ke jepang, sampai sakit kepala karena kode nya terlalu banyak .then() . Sekalinya bisa Async Await, wew… dia girang — girang..</p><p>Men… bayangin, kode yang 10++ baris, bisa jadi 5 baris. Tapi ya dibayangin doang belum cukup, perlu diketik juga lah..</p><p>Jadi kalau gw engk salah, mungkin beginilah perkembangan javascript untuk menangani error handling</p><p>Callback → Try Catch → Promise → Async Await</p><p>Jadi, apa an tuh Async Await??</p><p>Gini.. gini.. Kita tau yang namanya function biasa itu akan bersifat <strong>Synchronous</strong>, dia jalankan kode 1 per 1.. Ya bayangin aja badan lw udah pegel2 &amp; mau ke panti pijat:</p><ul><li>Googling dulu tempat rekomendasi di wilayah tertentu.</li><li>Setelah dapat namanya, tanya2 ke Subes yang lw kenal mengenai tempat itu.</li><li>Setelah confirm tempat itu memang oke, lw mulai googling nocan2 yang bisa jadi target beserta service nya.</li><li>Informasi sudah dapat, sekarang waktunya meluncur..</li><li>Ini yang paling penting.. Coy,, jangan lupa Sedekah nya..</li></ul><p>Umumnya, sepengalaman gw.. <strong>Synchronous</strong> enggak bisa dipakai ketika kita melakukan proses Fetching. Ya.. masalahnya 1, jeda waktu pengambilan data nya.</p><blockquote>“Makanya, kalau gw boleh kasih saran, coba ngertiin konsep Async Await. Bukan supaya kode lw lebih efisien, bukan juga supaya lw lebih pinter, tapi yaaaaaa biar bisa ***** gitu.. hahaha.. *Pesan Moral”</blockquote><p>Oke.. jadi hanya butuh 2 keyword untuk membuat function lw lebih rapih, yaitu… ya Async &amp; Await.</p><p><strong>Async: untuk mendifiniskan function biasa, menjadi asynchronous. ( async function fetchAsync() {…})</strong></p><ul><li>Lw baru bisa pakai keyword await, setelah lw definisiin async di nama function.</li><li>Secara otomatis mengubah sifat function menjadi Promised.</li><li>Apapun Value yang di return, ini akan masuk kedalam resolve / then() .</li></ul><p><strong>Await: menghentikan proses eksekusi kode sampai proses asynchronous selesai ( let response = await fetching() )</strong></p><ul><li>Keyword await hanya bisa dipakai di dalam async functions</li></ul><p>// Sample code dengan async await</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7a4f295af40cf0c90d1b2765385b2ed5/href">https://medium.com/media/7a4f295af40cf0c90d1b2765385b2ed5/href</a></iframe><p>// Sample code dengan promise</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b82b80d202379ccd7a4553c28c4fbc1e/href">https://medium.com/media/b82b80d202379ccd7a4553c28c4fbc1e/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=97169a8cb46f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>