<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: forgeora</title>
    <description>The latest articles on DEV Community by forgeora (@forgeora).</description>
    <link>https://dev.to/forgeora</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1657778%2Fa18aedae-2d8f-4b9c-a3e5-41f05fc69804.webp</url>
      <title>DEV Community: forgeora</title>
      <link>https://dev.to/forgeora</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/forgeora"/>
    <language>en</language>
    <item>
      <title>[Boost]</title>
      <dc:creator>forgeora</dc:creator>
      <pubDate>Mon, 03 Feb 2025 03:37:31 +0000</pubDate>
      <link>https://dev.to/forgeora/-3alc</link>
      <guid>https://dev.to/forgeora/-3alc</guid>
      <description>&lt;div class="ltag__link"&gt;
  &lt;div class="ltag__link__content"&gt;
    &lt;div class="missing"&gt;
      &lt;h2&gt;Article No Longer Available&lt;/h2&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;


</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>node</category>
      <category>backend</category>
    </item>
    <item>
      <title>The best API caching lib in NodeJS</title>
      <dc:creator>forgeora</dc:creator>
      <pubDate>Mon, 03 Feb 2025 03:31:24 +0000</pubDate>
      <link>https://dev.to/cozeniths/the-best-api-caching-lib-in-nodejs-58a6</link>
      <guid>https://dev.to/cozeniths/the-best-api-caching-lib-in-nodejs-58a6</guid>
      <description>&lt;p&gt;I have seen one of the library that can store our payload in memory cache &amp;amp; get faster response.&lt;/p&gt;

&lt;p&gt;The library name is &lt;strong&gt;api-cache&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cache a route&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import express from 'express'
import apicache from 'apicache'

let app = express()
let cache = apicache.middleware

app.get('/api/collection/:id?', cache('5 minutes'), (req, res) =&amp;gt; {
  // do some work... this will only occur once per 5 minutes
  res.json({ foo: 'bar' })
})

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Cache all routes&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let cache = apicache.middleware

app.use(cache('5 minutes'))

app.get('/will-be-cached', (req, res) =&amp;gt; {
  res.json({ success: true })
})

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Use with Redis
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import express from 'express'
import apicache from 'apicache'
import redis from 'redis'

let app = express()

// if redisClient option is defined, apicache will use redis client
// instead of built-in memory store
let cacheWithRedis = apicache.options({ redisClient: redis.createClient() }).middleware

app.get('/will-be-cached', cacheWithRedis('5 minutes'), (req, res) =&amp;gt; {
  res.json({ success: true })
})

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Cache grouping and manual controls
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import apicache from 'apicache'
let cache = apicache.middleware

app.use(cache('5 minutes'))

// routes are automatically added to index, but may be further added
// to groups for quick deleting of collections
app.get('/api/:collection/:item?', (req, res) =&amp;gt; {
  req.apicacheGroup = req.params.collection
  res.json({ success: true })
})

// add route to display cache performance (courtesy of @killdash9)
app.get('/api/cache/performance', (req, res) =&amp;gt; {
  res.json(apicache.getPerformance())
})

// add route to display cache index
app.get('/api/cache/index', (req, res) =&amp;gt; {
  res.json(apicache.getIndex())
})

// add route to manually clear target/group
app.get('/api/cache/clear/:target?', (req, res) =&amp;gt; {
  res.json(apicache.clear(req.params.target))
})

/*

GET /api/foo/bar --&amp;gt; caches entry at /api/foo/bar and adds a group called 'foo' to index
GET /api/cache/index --&amp;gt; displays index
GET /api/cache/clear/foo --&amp;gt; clears all cached entries for 'foo' group/collection
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;I recommended this api middleware you can use. in that database where they are rarely update. like country, city and validators api data.&lt;/p&gt;

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


&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
      &lt;div class="c-embed__cover"&gt;
        &lt;a href="https://cozeniths.com/" class="c-link s:max-w-50 align-middle" rel="noopener noreferrer"&gt;
          &lt;img alt="" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.cozeniths.com%2Fimages%2Fcozeniths%2Flogo.png" height="400" class="m-0" width="800"&gt;
        &lt;/a&gt;
      &lt;/div&gt;
    &lt;div class="c-embed__body"&gt;
      &lt;h2 class="fs-xl lh-tight"&gt;
        &lt;a href="https://cozeniths.com/" rel="noopener noreferrer" class="c-link"&gt;
          Cozeniths
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;p class="truncate-at-3"&gt;
          Cozeniths is providing web services, app development and seo optimization
        &lt;/p&gt;
      &lt;div class="color-secondary fs-s flex items-center"&gt;
          &lt;img alt="favicon" class="c-embed__favicon m-0 mr-2 radius-0" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcozeniths.com%2Fimages%2Fcozeniths%2Flogo.png" width="800" height="400"&gt;
        cozeniths.com
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;



</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>node</category>
      <category>backend</category>
    </item>
    <item>
      <title>React Native download remote file</title>
      <dc:creator>forgeora</dc:creator>
      <pubDate>Thu, 20 Jun 2024 14:31:44 +0000</pubDate>
      <link>https://dev.to/cozeniths/react-native-download-remote-file-6a4</link>
      <guid>https://dev.to/cozeniths/react-native-download-remote-file-6a4</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  import RNFetchBlob from 'rn-fetch-blob'


// code for component
   const toast = useToast();

 const downloadCSV = async () =&amp;gt; {
        if (loading) return;
        setLoading(true)
        const { fs } = RNFetchBlob;
        let downloadsDir = fs.dirs?.DownloadDir; // Directory where downloaded files are saved
        const fileUrl = 'https://filename'; // URL of the CSV file
        const fileName = 'Sample-Data-' + Date.now() + '.csv'; // Name to save the file with
        // Config for the download
        const configOptions = {
            trusty: true,
            session: "test",
            fileCache: true,
            addAndroidDownloads: {
                useDownloadManager: true,
                notification: true,
                path: `${downloadsDir}/${fileName}`,
                // description: 'Downloading CSV file.',
            },
        };
        // Trigger the download
        let res = await RNFetchBlob.config(configOptions).fetch('GET', fileUrl);
        if (res) {
            toast.show({ title: "Download successfully !" });
            setTimeout(() =&amp;gt; {
                setLoading(false);
            }, 500)
        }
    };

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
      &lt;div class="c-embed__cover"&gt;
        &lt;a href="https://www.cozeniths.com/" class="c-link s:max-w-50 align-middle" rel="noopener noreferrer"&gt;
          &lt;img alt="" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.cozeniths.com%2Fimages%2Fcozeniths%2Flogo.png" height="400" class="m-0" width="800"&gt;
        &lt;/a&gt;
      &lt;/div&gt;
    &lt;div class="c-embed__body"&gt;
      &lt;h2 class="fs-xl lh-tight"&gt;
        &lt;a href="https://www.cozeniths.com/" rel="noopener noreferrer" class="c-link"&gt;
          Cozeniths
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;p class="truncate-at-3"&gt;
          Cozeniths is providing web services, app development and seo optimization
        &lt;/p&gt;
      &lt;div class="color-secondary fs-s flex items-center"&gt;
          &lt;img alt="favicon" class="c-embed__favicon m-0 mr-2 radius-0" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.cozeniths.com%2Fimages%2Fcozeniths%2Flogo.png" width="800" height="400"&gt;
        cozeniths.com
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;



</description>
      <category>reat</category>
      <category>android</category>
      <category>reactnative</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
