<?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: Om Bharti</title>
    <description>The latest articles on DEV Community by Om Bharti (@om0509).</description>
    <link>https://dev.to/om0509</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%2F1189097%2F0e857e42-46d3-42f9-9346-b966987b867b.jpg</url>
      <title>DEV Community: Om Bharti</title>
      <link>https://dev.to/om0509</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/om0509"/>
    <language>en</language>
    <item>
      <title>Want to deploy Puppeter or chrome-browser</title>
      <dc:creator>Om Bharti</dc:creator>
      <pubDate>Wed, 12 Jun 2024 12:11:28 +0000</pubDate>
      <link>https://dev.to/om0509/want-to-deploy-pupeeter-or-chrome-browser-lk4</link>
      <guid>https://dev.to/om0509/want-to-deploy-pupeeter-or-chrome-browser-lk4</guid>
      <description>&lt;p&gt;&lt;code&gt;&lt;br&gt;
Dockerfile&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
# Use the official Node.js image as the base
FROM node:22
# Set the working directory
WORKDIR /app

# Copy package.json and pnpm-lock.yaml to the container
COPY package.json pnpm-lock.yaml ./


# Install Google Chrome or Chromium
# Install Google Chrome
RUN apt-get update \
    &amp;amp;&amp;amp; apt-get install -y wget gnupg \
    &amp;amp;&amp;amp; wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
    &amp;amp;&amp;amp; echo "deb http://dl.google.com/linux/chrome/deb/ stable main" &amp;gt;&amp;gt; /etc/apt/sources.list.d/google.list \
    &amp;amp;&amp;amp; apt-get update \
    &amp;amp;&amp;amp; apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf \
      --no-install-recommends \
    &amp;amp;&amp;amp; rm -rf /var/lib/apt/lists/*

# Install pnpm globally and install dependencies
RUN npm install -g pnpm &amp;amp;&amp;amp; pnpm install

# Copy the rest of the application code
COPY . .

# Set environment variable for the port
ENV PORT=3000
ENV CHROME_PATH=/usr/bin/google-chrome

# Build the application
RUN pnpm build

# Expose the port the app runs on
EXPOSE 3000

# Command to start the application
CMD ["pnpm", "start"]

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Example function for your chrome-browser
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;utils.ts&lt;/code&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 lighthouse, { Flags } from "lighthouse";
import * as ChromeLauncher from "chrome-launcher";

export const detail = async (isHtml: boolean, webURL: string) =&amp;gt; {
  const chrome = await ChromeLauncher.launch({
    chromeFlags: ["--headless", "--no-sandbox", "--disable-setuid-sandbox"],
    chromePath: "/usr/bin/google-chrome",
    logLevel: "info",
  });

  const options: Flags = {
    logLevel: "verbose",
    output: isHtml ? "html" : "json",
    onlyCategories: ["performance"],
    port: chrome.port,
  };
  const runnerResult = await lighthouse(webURL, options);
  if (chrome) {
    chrome.kill();
  }

  if (runnerResult) {
    const report = runnerResult.report;
    if (typeof report === `string`) return isHtml ? report : JSON.parse(report);
    else return isHtml ? report : JSON.parse(report[0]);
  }
  return null;
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;it's lighthouse setup also&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Docker Puppeeteer Node Railway</title>
      <dc:creator>Om Bharti</dc:creator>
      <pubDate>Tue, 16 Apr 2024 09:29:00 +0000</pubDate>
      <link>https://dev.to/om0509/docker-puppeeteer-node-railway-2lla</link>
      <guid>https://dev.to/om0509/docker-puppeeteer-node-railway-2lla</guid>
      <description>&lt;h2&gt;
  
  
  Want to use puppeteer in node node and then deploy it on railway.app or any related hosting platform, here is my working docker file and puppeteer config. You can use it
&lt;/h2&gt;

&lt;p&gt;-------------------------------------------------------------------------------------------DOCKER CONFIG FILE--------------------------------------------------------------------------------------------------------------------------------------------------------------&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Use the latest Node.js LTS (Long Term Support) version as the base image
FROM node:21.7.3-slim

RUN apt-get update &amp;amp;&amp;amp; apt-get install gnupg wget -y &amp;amp;&amp;amp; \
  wget --quiet --output-document=- https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor &amp;gt; /etc/apt/trusted.gpg.d/google-archive.gpg &amp;amp;&amp;amp; \
  sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" &amp;gt;&amp;gt; /etc/apt/sources.list.d/google.list' &amp;amp;&amp;amp; \
  apt-get update &amp;amp;&amp;amp; \
  apt-get install google-chrome-stable -y --no-install-recommends &amp;amp;&amp;amp; \
  rm -rf /var/lib/apt/lists/*

# Set the working directory to /app
WORKDIR /app

# Copy the package.json and pnpm-lock.yaml files
COPY package.json pnpm-lock.yaml ./

# Install dependencies using pnpm
RUN npm install -g pnpm &amp;amp;&amp;amp; pnpm install

# Copy the rest of the application code
COPY . .

# Set the DATABASE_URL environment variable
ENV DATABASE_URL="postgres://postgres.&amp;lt;passwoedtodb&amp;gt;.supabase.com:5432/postgres"

# Set the NEXT_PUBLIC_API_URL environment variable
ENV NEXT_PUBLIC_API_URL="https://example.com"

# Build the TypeScript code and run Prisma migrations
RUN pnpm run build

# Expose the port that your Express.js app is running on
EXPOSE 3000

# Start the application
CMD ["pnpm", "start"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  --------------------------------------------------------------------------------------------import puppeteer from "puppeteer";
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;const browser = await puppeteer.launch({&lt;br&gt;
    // headless: false,&lt;br&gt;
    executablePath: '/usr/bin/google-chrome',&lt;br&gt;
    args: ["--no-sandbox", "--disable-setuid-sandbox"],&lt;br&gt;
  });&lt;br&gt;
  const page = await browser.newPage();&lt;/code&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>docker</category>
      <category>javascript</category>
      <category>node</category>
    </item>
    <item>
      <title>NextJs with ReactQuery</title>
      <dc:creator>Om Bharti</dc:creator>
      <pubDate>Thu, 19 Oct 2023 10:50:36 +0000</pubDate>
      <link>https://dev.to/om0509/nextjs-with-reactquery-cj2</link>
      <guid>https://dev.to/om0509/nextjs-with-reactquery-cj2</guid>
      <description>&lt;p&gt;I want to know should be use reactquery with nextjs application, and if yes then what we should use for calling to backend fetch or axios. I am asking this as fetch of next has inbuild caching mechanism. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://stackoverflow.com/q/77323202/18761588" rel="noopener noreferrer"&gt;https://stackoverflow.com/q/77323202/18761588&lt;/a&gt;&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>react</category>
      <category>axios</category>
      <category>reactquery</category>
    </item>
  </channel>
</rss>
