<?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: Collins Kesuibai</title>
    <description>The latest articles on DEV Community by Collins Kesuibai (@collinskesuibai).</description>
    <link>https://dev.to/collinskesuibai</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%2F361936%2Fad9b6c7f-0910-4383-9701-9f983f90a193.jpg</url>
      <title>DEV Community: Collins Kesuibai</title>
      <link>https://dev.to/collinskesuibai</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/collinskesuibai"/>
    <language>en</language>
    <item>
      <title>Understanding Problem Matchers in Visual Studio Code</title>
      <dc:creator>Collins Kesuibai</dc:creator>
      <pubDate>Fri, 31 Jan 2025 07:00:45 +0000</pubDate>
      <link>https://dev.to/collinskesuibai/understanding-problem-matchers-in-visual-studio-code-70b</link>
      <guid>https://dev.to/collinskesuibai/understanding-problem-matchers-in-visual-studio-code-70b</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Visual Studio Code (VS Code) is a powerful and extensible code editor widely used by developers across various domains. One of its essential features is the ability to run tasks, which allows you to automate repetitive workflows such as compiling code, linting, and running development servers. However, when executing tasks that continuously watch for changes—like TypeScript compilation, Webpack bundling, or linting—VS Code needs a way to track and highlight issues effectively. This is where &lt;strong&gt;problem matchers&lt;/strong&gt; come in.&lt;/p&gt;

&lt;p&gt;Problem matchers in VS Code act as interpreters that scan terminal output for errors, warnings, and information messages. They extract useful details like filenames, line numbers, and error descriptions, enabling developers to quickly navigate and resolve issues without manually searching the console.&lt;/p&gt;

&lt;p&gt;This blog post provides a deep dive into &lt;strong&gt;what problem matchers are, how they work, and how you can create and customize them&lt;/strong&gt; for your specific use cases.&lt;/p&gt;




&lt;h2&gt;
  
  
  What is a Problem Matcher?
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;problem matcher&lt;/strong&gt; in VS Code is a configuration that allows the editor to recognize patterns in task output and display them as errors, warnings, or informational messages in the "Problems" panel. This means that instead of manually scanning through console logs for issues, VS Code can automatically extract relevant details and make debugging more efficient.&lt;/p&gt;

&lt;p&gt;For example, if you run a TypeScript watch mode (&lt;code&gt;tsc --watch&lt;/code&gt;), the compiler might output an error like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;src/index.ts(10,5): error TS2339: Property 'foo' does not exist on type 'Bar'.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Without a problem matcher, you would need to manually locate this error. With a properly configured matcher, VS Code can highlight &lt;code&gt;index.ts&lt;/code&gt; at line 10, column 5, displaying the message &lt;strong&gt;"Property 'foo' does not exist on type 'Bar'."&lt;/strong&gt; directly in the "Problems" panel.&lt;/p&gt;




&lt;h2&gt;
  
  
  How Problem Matchers Work
&lt;/h2&gt;

&lt;p&gt;Problem matchers rely on &lt;strong&gt;regular expressions (regex)&lt;/strong&gt; to extract structured information from unstructured console output. The extracted information typically includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;File name&lt;/strong&gt; where the issue occurred&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Line number&lt;/strong&gt; of the issue&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Column number&lt;/strong&gt; (if available)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Error message&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Error severity&lt;/strong&gt; (error, warning, or information)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These matchers are configured inside the &lt;code&gt;.vscode/tasks.json&lt;/code&gt; file and can be either &lt;strong&gt;built-in&lt;/strong&gt; or &lt;strong&gt;custom&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Built-in Problem Matchers
&lt;/h2&gt;

&lt;p&gt;VS Code provides several built-in problem matchers for common tools. You can use them directly in your tasks without defining complex regular expressions.&lt;/p&gt;

&lt;p&gt;Here are some popular built-in problem matchers:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Problem Matcher&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;$tsc-watch&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;TypeScript compiler (watch mode)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;$eslint-stylish&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;ESLint (stylish format)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;$gcc&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;GCC compiler&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;$msCompile&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Microsoft C++ compiler&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;$lessCompile&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Less CSS compiler&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Example: Running TypeScript compilation with VS Code detecting errors automatically:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"label"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Run TypeScript"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"shell"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"tsc -w"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"problemMatcher"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"$tsc-watch"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This configuration tells VS Code to use the built-in TypeScript problem matcher to identify compilation errors and warnings.&lt;/p&gt;




&lt;h2&gt;
  
  
  Creating a Custom Problem Matcher
&lt;/h2&gt;

&lt;p&gt;Sometimes, the default matchers don't work perfectly for your needs, especially if you're using a tool with unique error formatting. In such cases, you can define a &lt;strong&gt;custom problem matcher&lt;/strong&gt; in &lt;code&gt;.vscode/tasks.json&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example: Custom Problem Matcher for Webpack
&lt;/h3&gt;

&lt;p&gt;Suppose you are using Webpack in watch mode with this command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"watch"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"webpack --watch"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Webpack might output errors like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ERROR in ./src/index.js 10:5
Module not found: Error: Can't resolve 'lodash' in '/project/src'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A custom problem matcher for this output could be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"label"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"webpack watch"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"npm"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"script"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"watch"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"problemMatcher"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"owner"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"webpack"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"pattern"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"regexp"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ERROR in (.*) (&lt;/span&gt;&lt;span class="se"&gt;\d&lt;/span&gt;&lt;span class="s2"&gt;+):(&lt;/span&gt;&lt;span class="se"&gt;\d&lt;/span&gt;&lt;span class="s2"&gt;+)"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"file"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"line"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"column"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"message"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Module error detected"&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Explanation
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;regexp&lt;/code&gt;&lt;/strong&gt;: A regex pattern to match Webpack's error message.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;file&lt;/code&gt;&lt;/strong&gt;: Captures the file path.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;line&lt;/code&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;code&gt;column&lt;/code&gt;&lt;/strong&gt;: Extracts the line and column numbers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;message&lt;/code&gt;&lt;/strong&gt;: Displays a generic message for matched errors.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once configured, VS Code will automatically highlight Webpack errors in the "Problems" panel.&lt;/p&gt;




&lt;h2&gt;
  
  
  Problem Matcher Fields Explained
&lt;/h2&gt;

&lt;p&gt;A problem matcher can contain multiple fields to fine-tune its behavior. Here’s a breakdown of the most important ones:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Field&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;owner&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Defines the system owning the errors (e.g., &lt;code&gt;typescript&lt;/code&gt;, &lt;code&gt;webpack&lt;/code&gt;).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;pattern&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Specifies the regex pattern used to detect issues.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;regexp&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The actual regex used to parse error messages.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;file&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Captures the filename where the issue occurred.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;line&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Extracts the line number of the error.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;column&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Extracts the column number.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;severity&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Can be &lt;code&gt;error&lt;/code&gt;, &lt;code&gt;warning&lt;/code&gt;, or &lt;code&gt;info&lt;/code&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;message&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Extracts the actual error message.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Debugging Problem Matchers
&lt;/h2&gt;

&lt;p&gt;If your problem matcher isn't working correctly:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Check the regex pattern&lt;/strong&gt; using an online tool like &lt;a href="https://regex101.com/" rel="noopener noreferrer"&gt;regex101&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Look at the terminal output&lt;/strong&gt; and ensure it matches the expected format.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Enable task debugging&lt;/strong&gt; by running &lt;code&gt;Tasks: Run Task&lt;/code&gt; in the Command Palette (&lt;code&gt;Ctrl+Shift+P&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test a simpler problem matcher&lt;/strong&gt; before adding complex patterns.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Problem matchers in VS Code are a powerful way to enhance your debugging workflow by automatically recognizing errors and warnings from task output. Whether you're working with TypeScript, Webpack, ESLint, or custom tools, problem matchers help surface critical issues without requiring manual inspection of logs.&lt;/p&gt;

&lt;p&gt;If you’re using a common tool, &lt;strong&gt;try built-in problem matchers&lt;/strong&gt; like &lt;code&gt;$tsc-watch&lt;/code&gt; or &lt;code&gt;$eslint-stylish&lt;/code&gt;. If those don't work, &lt;strong&gt;define your own custom matcher&lt;/strong&gt; in &lt;code&gt;.vscode/tasks.json&lt;/code&gt; using regex.&lt;/p&gt;

&lt;p&gt;By mastering problem matchers, you can streamline your development process, reduce debugging time, and improve overall productivity.&lt;/p&gt;

&lt;p&gt;Happy Typing :)&lt;/p&gt;

&lt;p&gt;Photo by &lt;a href="https://unsplash.com/@jakewalker?utm_content=creditCopyText&amp;amp;utm_medium=referral&amp;amp;utm_source=unsplash" rel="noopener noreferrer"&gt;Jake Walker&lt;/a&gt; on &lt;a href="https://unsplash.com/photos/black-flat-screen-computer-monitor-MPKQiDpMyqU?utm_content=creditCopyText&amp;amp;utm_medium=referral&amp;amp;utm_source=unsplash" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

</description>
      <category>vscode</category>
      <category>typescript</category>
      <category>webpack</category>
    </item>
    <item>
      <title>Splitting and Serving PDF Files Efficiently with Firebase Storage and Buffer in Node.js(The knight way⚔️)</title>
      <dc:creator>Collins Kesuibai</dc:creator>
      <pubDate>Wed, 24 May 2023 14:22:10 +0000</pubDate>
      <link>https://dev.to/collinskesuibai/splitting-and-serving-pdf-files-efficiently-with-firebase-storage-and-buffer-in-nodejsthe-knight-way-4gih</link>
      <guid>https://dev.to/collinskesuibai/splitting-and-serving-pdf-files-efficiently-with-firebase-storage-and-buffer-in-nodejsthe-knight-way-4gih</guid>
      <description>&lt;h2&gt;
  
  
  PROLOGUE 🛡️⚜️🛡️
&lt;/h2&gt;

&lt;p&gt;In the land of coding, where clients' wishes reign supreme, I stumbled upon a formidable challenge. The task at hand was to tame a wild PDF, splitting its unruly pages to keep the browser from throwing a fit. With the mighty Firebase Storage and the trusty Buffer by my side, I embarked on an epic quest. Join me as I unravel the secrets of slaying lag times and serving PDFs with finesse!&lt;/p&gt;

&lt;h2&gt;
  
  
  CHAPTER ONE🤺🤺(The Code)
&lt;/h2&gt;

&lt;p&gt;Once upon a time, in a digital realm not so far away, there was a mischievous PDF named "example.pdf." It was a hefty creature, notorious for causing browser mayhem and frustrating users with its laggy ways. Our brave developer, armed with code and determination, sought to bring order to this unruly document. Let's dive into the enchanted forest of code and witness the magic unfold:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;RequestHandler&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;express&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Config&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../../../utils/config&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;getFilePath&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../../../utils/helpers/common&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Storage&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@google-cloud/storage&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;mime&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;mime&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;PDFDocument&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;pdf-lib&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;getBookFileWithRange&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;RequestHandler&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;any&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;dummyFileURL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://dummy-firebase-storage.com/books/example.pdf&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;// Behold! The filename of our fearless PDF hero!&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;filename&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;example.pdf&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;// Preparing our trusty steed, the Firebase Storage&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;storage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Storage&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;bucket&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;storage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;bucket&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;storageBucket&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fileName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;// Venturing into Firebase Storage to fetch the mythical file&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;file&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;bucket&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;file&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;// Slaying the PDF dragon, one byte at a time&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;fileBuffer&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;file&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;download&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="c1"&gt;// Unlocking the ancient secrets of pdf-lib&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;firstDonorPdfDoc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;PDFDocument&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Uint8Array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Buffer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fileBuffer&lt;/span&gt;&lt;span class="p"&gt;)));&lt;/span&gt;

    &lt;span class="c1"&gt;// Creating an empty canvas for our newly crafted PDF masterpiece&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;pdfDoc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;PDFDocument&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="na"&gt;start&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;startPage&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;pageCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="na"&gt;end&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;endPage&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;// Carefully selecting and copying the desired pages&lt;/span&gt;
    &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;start&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;start&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="nx"&gt;end&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;start&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;pdfDoc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;copyPages&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;firstDonorPdfDoc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;start&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
      &lt;span class="nx"&gt;pdfDoc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;insertPage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;pageCount&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="nx"&gt;pageCount&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Polishing our creation, preparing it for the grand reveal&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;pdfBytes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;pdfDoc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;save&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="c1"&gt;// Identifying the magical essence of our creation (the content type)&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;contentType&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;mime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getType&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fileName&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;// Announcing to the world the type of our creation&lt;/span&gt;
    &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Content-Type&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;contentType&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nf"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;

    &lt;span class="c1"&gt;// The moment of triumph has arrived! Sending our masterpiece to the waiting world&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Buffer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;pdfBytes&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Oh no! The dragon proved too fierce:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Error downloading file&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  CHAPTER TWO🗡️⚔️(The deep dive)
&lt;/h1&gt;

&lt;p&gt;In our whimsical adventure, we rely on several magical artifacts:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Express&lt;/code&gt;: The brave and reliable Express framework, guiding us through the treacherous routes of the web.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;pdf-lib&lt;/code&gt;: A wizardly library that lets us wield the power of PDF manipulation, enabling us to split, copy, and create PDF documents with ease.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Firebase Storage&lt;/code&gt;: A mystical cloud storage service, granting us the power to store and retrieve files securely.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;mime&lt;/code&gt;: A tiny library that helps us unveil the true identity of our PDF, revealing its content type to the awaiting world.&lt;/p&gt;

&lt;h2&gt;
  
  
  CHAPTER 3🛡🛡(The server side)
&lt;/h2&gt;

&lt;p&gt;In this whimsical tale, we not only embarked on a quest to split and serve PDF files but also discovered the magic of connecting our code to the server. Let's take a closer look at how we can integrate the PDF splitting functionality into our index.js or server.js file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;cors&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;cors&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;express&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;getBookFileWithRange&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./handlers/get/books/getBookFile&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;express&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;cors&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;

&lt;span class="c1"&gt;// Endpoint for serving PDF files with page range&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/book/file/by/url/:filename&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;getBookFileWithRange&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Your other API endpoints can be added here&lt;/span&gt;

&lt;span class="c1"&gt;// Start the server&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Server is running on port 3000&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;In the above code snippet, we first import the necessary libraries, such as cors and express, to handle server-related functionality. We then import the getBookFileWithRange function from our PDF handling module.&lt;/p&gt;

&lt;p&gt;Next, we create an instance of the Express application, configure it to use the cors middleware, and define our API endpoint for serving PDF files with a specific page range. You can add additional endpoints and routes to cater to your specific application needs.&lt;/p&gt;

&lt;p&gt;Finally, we start the server by calling the listen method and specifying the port number on which the server should listen. In this case, I set it to port 3000, but you can modify it according to your requirements.&lt;/p&gt;

&lt;h2&gt;
  
  
  CHAPTER 4⚔️(Making the API Call)
&lt;/h2&gt;

&lt;p&gt;Now that we have our splendid server up and running, it's time to unleash its powers by making an API call to retrieve our perfectly tailored PDF. The API endpoint we'll be hitting is &lt;code&gt;/book/file/by/url/:filename&lt;/code&gt;, and it accepts a few query parameters to customize the output. Let's dive in and explore how we can make the most of it!&lt;/p&gt;

&lt;h3&gt;
  
  
  Endpoint
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GET /book/file/by/url/:filename
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Query Parameters
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;startPage&lt;/code&gt; (required): Specifies the starting page number from where the PDF should be split. Must be a positive integer.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;endPage&lt;/code&gt; (required): Specifies the ending page number until where the PDF should be split. Must be a positive integer greater than or equal to the &lt;code&gt;startPage&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  CHAPTER 5 ⚜️(The end)
&lt;/h2&gt;

&lt;p&gt;With these enchanting tools in our possession, we embark on our noble quest to slay the dreaded lag times and deliver perfectly tailored PDFs to our users. The code comes alive, executing each step with precision and grace.&lt;/p&gt;

&lt;p&gt;In conclusion, by combining the capabilities of Firebase Storage, the pdf-lib library, and the Buffer object, we can efficiently split and serve PDF files in a secure and optimized manner. This solution allows for flexibility in managing large PDF files while ensuring a smooth user experience.&lt;/p&gt;

&lt;p&gt;And now, as the sun sets on our coding adventure, I, Knight⚔️ Collins, must bid you farewell. Don't forget to like❤️,🦄 and share😁.&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>express</category>
      <category>firebase</category>
      <category>node</category>
    </item>
    <item>
      <title>Show/hide android soft keyboard with kotlin - 31 seconds of code.</title>
      <dc:creator>Collins Kesuibai</dc:creator>
      <pubDate>Tue, 01 Sep 2020 20:23:37 +0000</pubDate>
      <link>https://dev.to/collinskesuibai/show-hide-android-soft-keyboard-android-31-seconds-of-code-1297</link>
      <guid>https://dev.to/collinskesuibai/show-hide-android-soft-keyboard-android-31-seconds-of-code-1297</guid>
      <description>&lt;h5&gt;
  
  
  What you will need and use.
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;InputMethodManager&lt;/code&gt; - The &lt;a href="https://developer.android.com/reference/android/view/inputmethod/InputMethodManager" rel="noopener noreferrer"&gt;InputMethodManager&lt;/a&gt; is a client side API that exists in each application context and manages interactions.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;View&lt;/code&gt; - Currently focused view.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Context&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;windowToken&lt;/code&gt; -Get windowToken from the window containing your currently focused view.&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;
  
  
  Showing the keyboard ⬆
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nc"&gt;View&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;showKeyboard&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;imm&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getSystemService&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;INPUT_METHOD_SERVICE&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nc"&gt;InputMethodManager&lt;/span&gt;
        &lt;span class="n"&gt;imm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toggleSoftInput&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;InputMethodManager&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;SHOW_FORCED&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

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

&lt;/div&gt;



&lt;h5&gt;
  
  
  Hiding the keyboard ⬇
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nc"&gt;View&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;hideKeyboard&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;imm&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getSystemService&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;INPUT_METHOD_SERVICE&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nc"&gt;InputMethodManager&lt;/span&gt;
        &lt;span class="n"&gt;imm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;hideSoftInputFromWindow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;windowToken&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Have a question don't hesitate to ask.Have a good day😊or night.&lt;code&gt;hideKeyboard()// end of post ,share away.&lt;/code&gt;
&lt;/h5&gt;

</description>
      <category>android</category>
      <category>kotlin</category>
    </item>
    <item>
      <title>{Git fun🎭}</title>
      <dc:creator>Collins Kesuibai</dc:creator>
      <pubDate>Mon, 13 Jul 2020 15:35:51 +0000</pubDate>
      <link>https://dev.to/collinskesuibai/git-fun-2fok</link>
      <guid>https://dev.to/collinskesuibai/git-fun-2fok</guid>
      <description>&lt;p&gt;As she walked down the street, he looked at her, there and then felt that spark✴️.&lt;br&gt;
&lt;code&gt;"{git init}"&lt;/code&gt; he said for it was a journey he was willing to take.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;"{git status}?"&lt;/code&gt; He asked, and surprised he was, she had no master, no one she was planning to commit to.&lt;/p&gt;

&lt;p&gt;With a little courage &lt;code&gt;"{git config}"&lt;/code&gt; with his name he began.&lt;/p&gt;

&lt;p&gt;The two branches were perfect for each other no conflict one would say, &lt;code&gt;{git add .}&lt;/code&gt; to the many things they had in common.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;{git log}&lt;/code&gt; over time and they were old enough to &lt;code&gt;{git merge}&lt;/code&gt;, with too many moments staged together. A simple wedding was all they needed.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;{git push}&lt;/code&gt; with the plan they began and the commitment was successful.&lt;code&gt;{git config}&lt;/code&gt;  was again needed for her name had changed.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;{git branch}&lt;/code&gt; came soon enough and they now had a family of four. Ten years past and everything was good until &lt;code&gt;{git checkout}&lt;/code&gt; happened.&lt;/p&gt;

&lt;p&gt;She was tired of having a master and &lt;code&gt;{git diff}&lt;/code&gt;, she felt the need to find someone different.&lt;code&gt;{git fork}&lt;/code&gt; the new guy did, with no hesitation and soon &lt;code&gt;{git request-pull}&lt;/code&gt; as expected a divorce had been filed.&lt;/p&gt;

&lt;p&gt;He was devastated. Left alone with his kids but what choice did he have, &lt;code&gt;{git merge}&lt;/code&gt; he had to, for all he wanted was to be her &lt;code&gt;origin&lt;/code&gt;, but it was no more. &lt;/p&gt;

&lt;p&gt;Everyday &lt;code&gt;{git log}&lt;/code&gt; into the past never knowing where he went wrong💔.&lt;/p&gt;

</description>
      <category>github</category>
      <category>git</category>
    </item>
  </channel>
</rss>
