<?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: femtowork Inc.</title>
    <description>The latest articles on DEV Community by femtowork Inc. (@femtowork).</description>
    <link>https://dev.to/femtowork</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%2F1511450%2Fc26ae646-5a12-4480-afdf-18f78f6e456c.png</url>
      <title>DEV Community: femtowork Inc.</title>
      <link>https://dev.to/femtowork</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/femtowork"/>
    <language>en</language>
    <item>
      <title>How to Send i18n HTML Emails from Scripts Using React Email</title>
      <dc:creator>femtowork Inc.</dc:creator>
      <pubDate>Fri, 24 May 2024 14:05:24 +0000</pubDate>
      <link>https://dev.to/femtowork/how-to-send-i18n-html-emails-from-scripts-using-react-email-3lea</link>
      <guid>https://dev.to/femtowork/how-to-send-i18n-html-emails-from-scripts-using-react-email-3lea</guid>
      <description>&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://react.email/"&gt;React Email&lt;/a&gt; is a convenient tool that allows you to design HTML emails using React components. It supports styling with Tailwind and can automatically convert to Plain Text for email clients that don't support HTML emails, making it easier to manage emails. There are a few configurations required when sending emails using React Email from a script(such batch script), and I will share the idea here.&lt;/p&gt;

&lt;h3&gt;
  
  
  Challenges
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;TypeScript constraints&lt;br&gt;
Since we need to handle React components, errors occur in &lt;code&gt;.ts&lt;/code&gt; files.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;i18n settings
If the email content is multilingual, i18n-related settings are required.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Solutions
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Change the script extension to &lt;code&gt;.tsx&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With the &lt;a href="https://www.npmjs.com/package/tsx"&gt;tsx&lt;/a&gt; command, it is possible to execute &lt;code&gt;.tsx&lt;/code&gt; files.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm exec tsx ./scripts/send-mail.tsx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;i18n settings
Set up &lt;code&gt;i18next&lt;/code&gt; and &lt;code&gt;react-i18next&lt;/code&gt;, then wrap the React component with &lt;code&gt;I18nextProvider&lt;/code&gt; to render it.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Example Code
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// scripts/send-mail.tsx
import path, { join } from 'path'
import { fileURLToPath } from 'url'
import i18next from 'i18next'
import Backend from 'i18next-fs-backend'
import { I18nextProvider } from 'react-i18next'
import { renderAsync } from '@react-email/components'
import EmailComponent from './EmailComponent'

const lang = 'en'
const namespaces = ['common', 'mail']
const __dirname = path.dirname(fileURLToPath(import.meta.url)) // current directory

await i18next.use(Backend).init({
ns: namespaces,
lng: lang,
backend: {
loadPath: join(__dirname, '../public/locales/{{lng}}/{{ns}}.json'), // locale file path
},
})

const t = i18next.t // usable as the t function

const { html, text } = await renderReactEmail(
&amp;lt;I18nextProvider i18n={i18next}&amp;gt;
&amp;lt;EmailComponent /&amp;gt;
&amp;lt;/I18nextProvider&amp;gt;
)

// Send mail using html and text

async function renderReactEmail(react: ReactElement) {
const [html, text] = await Promise.all([
renderAsync(react),
renderAsync(react, { plainText: true }),
])
return { html, text }
}

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;We introduced a method for sending multilingual React emails from a script.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Efficient Data Management with Prisma, Fly.io, and LiteFS Configuration</title>
      <dc:creator>femtowork Inc.</dc:creator>
      <pubDate>Thu, 23 May 2024 01:00:44 +0000</pubDate>
      <link>https://dev.to/femtowork/efficient-data-management-with-prisma-flyio-and-litefs-configuration-hjm</link>
      <guid>https://dev.to/femtowork/efficient-data-management-with-prisma-flyio-and-litefs-configuration-hjm</guid>
      <description>&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://fly.io/"&gt;Fly.io&lt;/a&gt;  is a cloud platform that allows developers to easily deploy scalable applications. In this article, we will introduce how to manage databases effectively in an application using Remix, Prisma, and LiteFS on Fly.io.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is LiteFS?
&lt;/h2&gt;

&lt;p&gt;LiteFS is a replication tool for SQLite databases, designed for use in distributed environments. It operates in the same environment as the application, ensuring fast data reading and low latency. Additionally, with automatic scaling features, it offers low scaling costs and high availability. Distributed SQLite is one of the technologies gaining attention due to increasing demands for fast response times.&lt;/p&gt;

&lt;h2&gt;
  
  
  Limitations and Challenges of SQLite
&lt;/h2&gt;

&lt;p&gt;SQLite is a lightweight and easy-to-use database, but because it lacks a daemon process, checking and modifying data on the server requires accessing the application container and operating on the command line. For MySQL or PostgreSQL, you can use port forwarding to the DB server and DB client GUI apps (e.g., Sequel Ace, pgAdmin) to manipulate the data on the server, but this is difficult with SQLite.&lt;/p&gt;

&lt;h2&gt;
  
  
  Utilizing Prisma Studio
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.prisma.io/studio"&gt;Prisma Studio&lt;/a&gt; is a database management tool provided by Prisma that allows you to visually manipulate data in your browser. If your application uses Prisma as an ORM during development, utilizing Prisma Studio for data management is convenient.&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuration Steps
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Connect to the Application Container
&lt;/h3&gt;

&lt;p&gt;First, connect to the Fly.io server using SSH.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fly ssh console -a {your_application_name}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Start Prisma Studio
&lt;/h3&gt;

&lt;p&gt;Next, start Prisma Studio.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx prisma studio
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Set Up Port Forwarding
&lt;/h3&gt;

&lt;p&gt;Set up port forwarding to access Prisma Studio locally.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fly proxy 5555:5555 -a {your_application_name}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Access the Forwarded Local Port
&lt;/h3&gt;

&lt;p&gt;Open your browser and access the following URL.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://localhost:5555
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Security Considerations
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Starting and Stopping Studio
&lt;/h3&gt;

&lt;p&gt;In a properly operated service, there are not many cases where database investigation or manipulation is necessary. It is not desirable to always keep Prisma Studio running from both a security and memory efficiency perspective, so it is recommended to start it only when necessary.&lt;/p&gt;

&lt;h3&gt;
  
  
  Use Non-Public Ports
&lt;/h3&gt;

&lt;p&gt;Make sure to use a non-public port that cannot be accessed externally when starting Prisma Studio. Check your fly.toml configuration carefully.&lt;/p&gt;

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

&lt;p&gt;By leveraging LiteFS, a distributed SQLite, you can build scalable and high-performance applications. This article introduced how to efficiently manage data using Prisma Studio while considering security to address the data management challenges of SQLite.&lt;/p&gt;

</description>
      <category>deploy</category>
      <category>webdev</category>
      <category>prisma</category>
      <category>sqlite</category>
    </item>
    <item>
      <title>How to Improve Team Development Efficiency with Effective Use of Pull Requests and Code Comments</title>
      <dc:creator>femtowork Inc.</dc:creator>
      <pubDate>Wed, 22 May 2024 02:37:41 +0000</pubDate>
      <link>https://dev.to/femtowork/how-to-improve-team-development-efficiency-with-effective-use-of-pull-requests-and-code-comments-f2p</link>
      <guid>https://dev.to/femtowork/how-to-improve-team-development-efficiency-with-effective-use-of-pull-requests-and-code-comments-f2p</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In programming, while it is ideal to convey information solely through source code, there are limitations. This is especially true in team development, where pull requests (PRs) and source code comments become essential. This article explains the appropriate use and differentiation of these tools.&lt;/p&gt;

&lt;h2&gt;
  
  
  Importance of Pull Requests
&lt;/h2&gt;

&lt;p&gt;PRs are a means to show code changes to the team and receive reviews. The main goal is to improve code quality.&lt;/p&gt;

&lt;h3&gt;
  
  
  Readers of Pull Requests
&lt;/h3&gt;

&lt;p&gt;There are primarily two types of readers for PRs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Code Reviewers&lt;/strong&gt;: Those who review the PR&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Code Modifiers&lt;/strong&gt;: Those who investigate the PR to understand the history of code changes&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Information to Include in a Pull Request
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Purpose of the Change&lt;/strong&gt;: Why the change was made&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Main Changes&lt;/strong&gt;: Overview of the modifications&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scope&lt;/strong&gt;: Range of the modifications&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Testing&lt;/strong&gt;: Items tested and verification points&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Design/Implementation Considerations&lt;/strong&gt;: Background of technical decisions&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Related Issues&lt;/strong&gt;: Information on related tickets&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Basically, include explanations that span multiple files or modifications, rather than what can be explained in code. If code explanations are necessary, it is preferable to write source code comments as mentioned later. However, if not suitable, supplement with inline review comments on the PR for easier understanding.&lt;/p&gt;

&lt;h2&gt;
  
  
  Importance of Source Code Comments
&lt;/h2&gt;

&lt;p&gt;Source code comments are written to explain the behavior and intent of the code. The goal is to enable the reader to efficiently use and modify the code.&lt;/p&gt;

&lt;h3&gt;
  
  
  Readers of Source Code
&lt;/h3&gt;

&lt;p&gt;There are also two types of readers for source code:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Code Users&lt;/strong&gt;: Those who want to know how to correctly use the code&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Code Modifiers&lt;/strong&gt;: Those who modify the code to avoid bugs&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Information to Include in Source Code Comments
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Purpose of Functions and Classes&lt;/strong&gt;: What the function or class is for&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Usage of Functions and Classes&lt;/strong&gt;: Typical usage examples of classes or functions&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Explanation of Complex Processes&lt;/strong&gt;: Explanation of difficult-to-understand logic or algorithms&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Notes and TODOs&lt;/strong&gt;: Points to improve or be aware of in the future&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;External Reference Resources&lt;/strong&gt;: URLs of referenced pages, etc.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Source code comments should pertain to specific files. Again, there is no need to rewrite what can be expressed in the code.&lt;/p&gt;

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

&lt;p&gt;PRs and source code comments play an important role in team development. By understanding and appropriately using each, we can achieve improved code quality and efficient communication.&lt;/p&gt;

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