<?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 Ferhat Demir on Medium]]></title>
        <description><![CDATA[Stories by Ferhat Demir on Medium]]></description>
        <link>https://medium.com/@edemirferhat?source=rss-fb69815842ee------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*EWcvqd2TBfGj6NzZJWdWfw.jpeg</url>
            <title>Stories by Ferhat Demir on Medium</title>
            <link>https://medium.com/@edemirferhat?source=rss-fb69815842ee------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 02:43:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@edemirferhat/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[Stripe Subscription Payments With Nest.js and Prisma]]></title>
            <link>https://medium.com/@edemirferhat/stripe-subscription-payments-with-nest-js-and-prisma-part-1-b425ac8c7a04?source=rss-fb69815842ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/b425ac8c7a04</guid>
            <category><![CDATA[stripe]]></category>
            <category><![CDATA[nestjs]]></category>
            <category><![CDATA[prisma]]></category>
            <category><![CDATA[payments]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Ferhat Demir]]></dc:creator>
            <pubDate>Tue, 16 Jul 2024 17:53:05 GMT</pubDate>
            <atom:updated>2025-01-25T09:09:42.888Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, I want to share how you can implement a Stripe subscription using Nest.js and Prisma.</p><p>First of all, I want to describe the Nest.js and Prisma;</p><p>Nest.js is a powerful Node.js framework for building efficient, scalable server-side applications. It supports TypeScript, has a modular architecture, and a dependency injection system for easy maintenance.</p><p>Prisma is a modern ORM with a type-safe, auto-generated query builder for interacting with databases. It includes tools like Prisma Client for type-safe database queries and Prisma Migrate for managing schema changes, making it a popular choice for JavaScript and TypeScript projects.</p><p>We need a Stripe account for this implementation. Let’s create a new one <a href="https://dashboard.stripe.com/register">from here</a>. After creating the account, we will be redirected to the Stripe dashboard. Make sure the Test mode is on. Also, we can skip the setup steps for now.</p><p>Then, let’s create Basic and Pro plans and their prices.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jA8950Q8o2QVXj9QL30w5Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kfjwDRSUD_q_giN-wA21wA.png" /></figure><p>We have two products, the Basic and the Pro, and two pricing options for each plan: Monthly and Yearly.</p><p>Let’s create a new Nest.js application.</p><pre>npm i -g @nestjs/cli<br>nest new project-name</pre><p>After creating a Nest.js application, create a docker-compose.yml file in the main folder of your project:</p><pre>touch docker-compose.yml</pre><p>This docker-compose.yml file is a configuration file containing the specifications for running a docker container with PostgreSQL setup inside. Create the following configuration inside the file:</p><pre><br>version: &#39;3.8&#39;<br>services:<br><br>  postgres:<br>    image: postgres:13.5<br>    restart: always<br>    environment:<br>      - POSTGRES_USER=myuser<br>      - POSTGRES_PASSWORD=mypassword<br>    volumes:<br>      - postgres:/var/lib/postgresql/data<br>    ports:<br>      - &#39;5432:5432&#39;<br><br>volumes:<br>  postgres:</pre><p>To start the postgres container, open a new terminal window, and run the following command in the main folder of your project:</p><pre>docker-compose up</pre><p>Now that the database is ready, it’s time to set up Prisma!</p><pre>npm install -D prisma<br>npx prisma init</pre><p>This will create a new prisma directory with a schema.prisma file. After that, you should see DATABASE_URL the .env file in the prisma directory. Please update the connection string.</p><p>Now, it’s time to define the data models for our application.</p><pre>#prisma/schema.prisma<br><br>model users {<br>  userId               String   @id @default(uuid())<br>  firstName            String?<br>  lastName             String?<br>  email                String?  @unique<br>  subscriptionId       String?<br>  subscription         subscriptions?<br>  customer             customers?<br>}<br><br>model customers {<br>  id         String   @id @default(uuid())<br>  customerId String<br>  userId     String   @unique<br>  user       users    @relation(fields: [userId], references: [userId])<br>}<br><br>model products {<br>  id          String   @id @default(uuid())<br>  productId   String   @unique<br>  active      Boolean  @default(true)<br>  name        String<br>  description String?<br>  prices      prices[]<br>}<br><br>model prices {<br>  id                  String              @id @default(uuid())<br>  priceId             String              @unique<br>  productId           String<br>  product             products            @relation(fields: [productId], references: [id])<br>  description         String?<br>  unitAmount          Int                 <br>  currency            String              <br>  pricingType         PricingType         // one_time, recurring<br>  pricingPlanInterval PricingPlanInterval // day, week, month, year<br>  intervalCount       Int                 <br>  subscription        subscriptions[]<br>  type                PlanType            // basic, pro<br>}</pre><p>I want to describe some values;</p><ul><li><strong>unitAmount: </strong>The unit amount as a positive integer in the smallest currency unit.</li><li><strong>currency</strong>: Three-letter ISO currency code, in lowercase.</li><li><strong>pricingType</strong>: One of `one_time` or `recurring` depending on whether the price is for a one-time purchase or a recurring (subscription) purchase</li><li><strong>pricingPlanInterval</strong>: The frequency at which a subscription is billed. One of day , week , month , or year .</li><li><strong>intervalCount</strong>: The number of intervals between subscription billings. For example, pricingPlanInterval=3 , and intervalCount=3 bills every three months.</li></ul><p>Let&#39;s create the final model and describe some of its values.</p><pre>#prisma/schema.prisma<br><br>model subscriptions {<br>  subscriptionId         String              @id @default(uuid())<br>  providerSubscriptionId String?<br>  userId                 String              @unique<br>  planType               PlanType            <br>  user                   users               @relation(fields: [userId], references: [userId])<br>  status                 SubscriptionStatus? // trialing, active, canceled, incomplete, incomplete_expired, past_due, unpaid, paused<br>  quantity               Int?<br>  priceId                String?<br>  price                  prices?             @relation(fields: [priceId], references: [id])<br>  cancelAtPeriodEnd      Boolean             @default(false)<br>  currentPeriodStart     DateTime?<br>  currentPeriodEnd       DateTime?<br>  endedAt                DateTime?<br>  cancelAt               DateTime?<br>  canceledAt             DateTime?<br>}</pre><ul><li><strong>cancelAtPeriodEnd</strong>: If true, the subscription has been canceled by the user and will be deleted at the end of the billing period.</li><li><strong>currentPeriodStart</strong>: Start of the current period for which the subscription has been invoiced.</li><li><strong>currentPeriodEnd</strong>: At the end of the current period, the subscription has been invoiced. At the end of this period, a new invoice will be created.</li><li><strong>endedAt</strong>: If the subscription has ended, the timestamp is the date the subscription ended.</li><li><strong>cancelAt</strong>: A date at which the subscription will automatically get canceled.</li><li><strong>canceledAt</strong>: If the subscription has been canceled, the date of that cancellation. If the subscription was canceled with cancelAtPeriodEnd, canceledAt will still reflect the date of the initial cancellation request, not the end of the subscription period when the subscription is automatically moved to a canceled state.</li></ul><p>We defined the schema. To generate and execute the migration, run the following command in the terminal:</p><pre>npx prisma migrate dev --name &quot;init&quot;</pre><p>We created the tables and their fields, but they are currently empty. Let’s create a seed file and populate the users , products and prices tables.</p><pre>#prisma/seed.ts<br><br>import { PrismaClient } from &#39;@prisma/client&#39;;<br><br>const prisma = new PrismaClient();<br><br>async function main() {<br>  await prisma.users.create({<br>    data: {<br>      firstName: &#39;Ferhat&#39;,<br>      lastName: &#39;Demir&#39;,<br>      email: &#39;...@gmail.com&#39;,<br>    },<br>  });<br>  <br>  await prisma.products.createMany({<br>    data: [<br>      {<br>        productId: &#39;prod_QSkslDcBhj8y2Z&#39;,<br>        name: &#39;Basic Plan&#39;,<br>      },<br>      {<br>        productId: &#39;prod_QSktVsKo34GHYN&#39;,<br>        name: &#39;Pro Plan&#39;,<br>      },<br>    ],<br>  });<br><br>  // fetch the created products to get their IDs<br>  const products = await prisma.products.findMany({<br>    where: {<br>      productId: { in: [&#39;prod_QSkslDcBhj8y2Z&#39;, &#39;prod_QSktVsKo34GHYN&#39;] },<br>    },<br>  });<br><br>  const productIdMap = products.reduce((map, product) =&gt; {<br>    map[product.productId] = product.id;<br>    return map;<br>  }, {});<br><br>  // create prices next<br>  await prisma.prices.createMany({<br>    data: [<br>      {<br>        priceId: &#39;price_1PbpgJKWfbR45IR7mYwUUMT9&#39;,<br>        unitAmount: 10,<br>        currency: &#39;usd&#39;,<br>        productId: productIdMap[&#39;prod_QSkslDcBhj8y2Z&#39;],<br>        intervalCount: 1,<br>        pricingPlanInterval: &#39;month&#39;,<br>        pricingType: &#39;recurring&#39;,<br>        type: &#39;basic&#39;,<br>      },<br>      {<br>        priceId: &#39;price_1PbprLKWfbR45IR7HCZf44op&#39;,<br>        unitAmount: 100,<br>        currency: &#39;usd&#39;,<br>        productId: productIdMap[&#39;prod_QSktVsKo34GHYN&#39;],<br>        intervalCount: 1,<br>        pricingPlanInterval: &#39;year&#39;,<br>        pricingType: &#39;recurring&#39;,<br>        type: &#39;basic&#39;,<br>      },<br>      {<br>        priceId: &#39;price_1PbPqgKWfbR45IR7L4V0Y7RL&#39;,<br>        unitAmount: 20,<br>        currency: &#39;usd&#39;,<br>        productId: productIdMap[&#39;prod_QSktvsKo34GHYN&#39;],<br>        intervalCount: 1,<br>        pricingPlanInterval: &#39;month&#39;,<br>        pricingType: &#39;recurring&#39;,<br>        type: &#39;pro&#39;,<br>      },<br>      {<br>        priceId: &#39;price_1PbpQVlWfbR45IR7TBywWkkO&#39;,<br>        unitAmount: 200,<br>        currency: &#39;usd&#39;,<br>        productId: productIdMap[&#39;prod_QSktVsKo34GHYN&#39;],<br>        intervalCount: 1,<br>        pricingPlanInterval: &#39;year&#39;,<br>        pricingType: &#39;recurring&#39;,<br>        type: &#39;pro&#39;,<br>      },<br>    ],<br>  });<br>}<br><br>// execute the main function<br>main()<br>  .catch((e) =&gt; {<br>    console.error(e);<br>    process.exit(1);<br>  })<br>  .finally(async () =&gt; {<br>    // close Prisma Client at the end<br>    await prisma.$disconnect();<br>  });</pre><p>To execute the seed file, we should define the command on package.json the file.</p><pre>#package.json<br><br>&quot;scripts&quot;: {<br>  // ...<br>},<br>&quot;dependencies&quot;: {<br>  // ...<br>},<br>&quot;devDependencies&quot;: {<br>  // ...<br>},<br>&quot;prisma&quot;: {<br>  &quot;seed&quot;: &quot;ts-node prisma/seed.ts&quot;<br>}</pre><p>Execute seeding with the following command:</p><pre>npx prisma db seed</pre><p>We need to create the necessary modules: Stripe and Prisma. We must also create an endpoint to listen to Stripe payment events.</p><pre>import { Controller, Post, Req } from &#39;@nestjs/common&#39;;<br>import { StripeService } from &#39;./stripe.service&#39;;<br><br>@Controller(&#39;stripe&#39;)<br>export class StripeController {<br>  constructor(private readonly stripeService: StripeService) {}<br><br>  @Post(&#39;events&#39;)<br>  async handleEvents(@Req() request) {<br>    console.log(&#39;Received a new event&#39;, request.body.type);<br>  }<br>}</pre><p>To efficiently develop and debug in the local environment, we need to install Stripe CLI.</p><pre>brew install stripe/stripe-cli/stripe<br>stripe login</pre><p>Forward events to our endpoint. Then, trigger an event to verify that it is working correctly.</p><pre>stripe listen --forward-to localhost:3000/stripe/events<br>stripe trigger payment_intent.succeeded</pre><p>Now, we should see the logs on the console.</p><p>Let&#39;s start implementing the business logic and updating our data models.</p><h4>1. Handling Stripe Webhooks</h4><p>Webhooks allow Stripe to communicate events (like payment success or failure) to your application. Here’s how to set up and handle webhooks.</p><p>Create a Webhook Endpoint in Next.js</p><p>Using the Nest.js API routes, we can set up a webhook as follows:</p><pre>import { Controller, Post, Req, Res } from &#39;@nestjs/common&#39;;<br>import { Request, Response } from &#39;express&#39;;<br>import Stripe from &#39;stripe&#39;;<br>import { manageSubscriptionStatusChange } from &#39;./stripe.service&#39;;<br><br>const relevantEvents = new Set([<br>  &#39;checkout.session.completed&#39;,<br>  &#39;customer.subscription.created&#39;,<br>  &#39;customer.subscription.updated&#39;,<br>  &#39;customer.subscription.deleted&#39;,<br>]);<br><br>@Controller(&#39;webhook&#39;)<br>export class WebhookController {<br>  private stripe = new Stripe(process.env.STRIPE_SECRET_KEY);<br><br>  @Post()<br>  async handleWebhook(@Req() req: Request, @Res() res: Response) {<br>    const sig = req.headers[&#39;stripe-signature&#39;];<br>    const webhookSecret = process.env.STRIPE_WEBHOOK_SECRET;<br>    let event;<br><br>    try {<br>      if (!sig || !webhookSecret) {<br>        return res.status(400).send(&#39;Webhook secret not found.&#39;);<br>      }<br><br>      event = this.stripe.webhooks.constructEvent(req.body, sig, webhookSecret);<br>      console.log(`Webhook received: ${event.type}`);<br>    } catch (err) {<br>      console.error(`Webhook Error: ${err.message}`);<br>      return res.status(400).send(`Webhook Error: ${err.message}`);<br>    }<br><br>    if (relevantEvents.has(event.type)) {<br>      try {<br>        switch (event.type) {<br>          case &#39;customer.subscription.created&#39;:<br>          case &#39;customer.subscription.updated&#39;:<br>          case &#39;customer.subscription.deleted&#39;:<br>            const subscription = event.data.object as Stripe.Subscription;<br>            await manageSubscriptionStatusChange(subscription.id, subscription.customer as string, event.type === &#39;customer.subscription.created&#39;);<br>            break;<br>          case &#39;checkout.session.completed&#39;:<br>            const session = event.data.object as Stripe.Checkout.Session;<br>            if (session.mode === &#39;subscription&#39;) {<br>              const subscriptionId = session.subscription as string;<br>              await manageSubscriptionStatusChange(subscriptionId, session.customer as string, true);<br>            }<br>            break;<br>          default:<br>            console.warn(`Unhandled event type: ${event.type}`);<br>        }<br>      } catch (error) {<br>        console.error(`Webhook handler error: ${error.message}`);<br>        return res.status(400).send(&#39;Webhook handler failed.&#39;);<br>      }<br>    } else {<br>      console.warn(`Ignored event type: ${event.type}`);<br>    }<br><br>    res.status(200).json({ received: true });<br>  }<br>}</pre><p>Ensure that process.env.NEXT_PUBLIC_STRIPE_SECRET_KEY and process.env.NEXT_PUBLIC_STRIPE_WEBHOOK_SECRET are properly set in your environment variables.</p><h4>2. Adding a Checkout Endpoint</h4><p>We will create a checkout endpoint to initiate the subscription process.</p><pre>import { Controller, Post, Body } from &#39;@nestjs/common&#39;;<br>import Stripe from &#39;stripe&#39;;<br>import { PrismaClient } from &#39;@prisma/client&#39;;<br><br>const prisma = new PrismaClient();<br><br>@Controller(&#39;checkout&#39;)<br>export class CheckoutController {<br>  private stripe = new Stripe(process.env.STRIPE_SECRET_KEY, {<br>    apiVersion: &#39;2022-11-15&#39;,<br>  });<br><br>  @Post()<br>  async createCheckoutSession(@Req() req: Request, @Body() { priceId }: { priceId: string }) {<br>    const userId = req.user.id; // Assuming `req.user` is populated by auth middleware<br><br>    const user = await prisma.users.findUnique({<br>      where: { id: userId },<br>      select: { email: true },<br>    });<br><br>    if (!user) {<br>      throw new Error(&#39;User not found.&#39;);<br>    }<br><br>    let customer = await prisma.customers.findUnique({ where: { userId } });<br><br>    if (!customer) {<br>      const stripeCustomer = await this.stripe.customers.create({<br>        email: user.email,<br>      });<br>      customer = await prisma.customers.create({<br>        data: {<br>          userId,<br>          customerId: stripeCustomer.id,<br>        },<br>      });<br>    }<br><br>    const session = await this.stripe.checkout.sessions.create({<br>      customer: customer.customerId,<br>      customer_update: { address: &#39;auto&#39; },<br>      line_items: [<br>        {<br>          price: priceId,<br>          quantity: 1,<br>        },<br>      ],<br>      mode: &#39;subscription&#39;,<br>      cancel_url: `${process.env.BASE_URL}/dashboard/subscriptions`,<br>      success_url: `${process.env.BASE_URL}/dashboard/subscriptions?checkout=success`,<br>    });<br><br>    return { sessionId: session.id };<br>  }<br>}</pre><h4>3. Managing Subscription Status with Prisma</h4><p>We will replace the Supabase-based logic with Prisma to handle subscription updates.</p><p>Implementing manageSubscriptionStatusChange</p><pre>import { PrismaClient } from &#39;@prisma/client&#39;;<br>import Stripe from &#39;stripe&#39;;<br>import { v4 as uuidv4 } from &#39;uuid&#39;;<br><br>const prisma = new PrismaClient();<br><br>export const manageSubscriptionStatusChange = async (<br>  subscriptionId: string,<br>  customerId: string,<br>  createAction = false<br>) =&gt; {<br>  const customer = await prisma.customers.findUnique({<br>    where: { customerId },<br>    select: { userId: true },<br>  });<br><br>  if (!customer) {<br>    throw new Error(`Customer lookup failed: Customer with ID ${customerId} not found.`);<br>  }<br><br>  const { userId } = customer;<br><br>  const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);<br><br>  const subscription = await stripe.subscriptions.retrieve(subscriptionId, {<br>    expand: [&#39;default_payment_method&#39;],<br>  });<br><br>  const priceData = subscription.items.data[0].price;<br><br>  const price = await prisma.prices.findUnique({<br>    where: { priceId: priceData.id },<br>    select: { id: true, type: true },<br>  });<br><br>  if (!price) {<br>    throw new Error(`Price lookup failed: Price with ID ${priceData.id} not found.`);<br>  }<br><br>  const existingSubscription = await prisma.subscriptions.findFirst({<br>    where: { userId },<br>  });<br><br>  const subscriptionData = {<br>    subscriptionId: existingSubscription ? existingSubscription.subscriptionId : uuidv4(),<br>    providerSubscriptionId: subscription.id,<br>    userId,<br>    status: subscription.status,<br>    priceId: price.id,<br>    quantity: subscription.quantity,<br>    planType: price.type,<br>    cancelAtPeriodEnd: subscription.cancel_at_period_end,<br>    cancelAt: subscription.cancel_at ? new Date(subscription.cancel_at * 1000).toISOString() : null,<br>    canceledAt: subscription.canceled_at ? new Date(subscription.canceled_at * 1000).toISOString() : null,<br>    currentPeriodStart: new Date(subscription.current_period_start * 1000).toISOString(),<br>    currentPeriodEnd: new Date(subscription.current_period_end * 1000).toISOString(),<br>    createdAt: new Date(subscription.created * 1000).toISOString(),<br>    updatedAt: new Date().toISOString(),<br>    endedAt: subscription.ended_at ? new Date(subscription.ended_at * 1000).toISOString() : null,<br>  };<br><br>  await prisma.subscriptions.upsert({<br>    where: { subscriptionId: subscriptionData.subscriptionId },<br>    update: subscriptionData,<br>    create: subscriptionData,<br>  });<br>};</pre><p>This implementation uses Prisma to query and update the database for managing subscription status.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b425ac8c7a04" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Let’s deploy the Web Application]]></title>
            <link>https://medium.com/@edemirferhat/lets-deploy-the-web-application-94859ebcc28b?source=rss-fb69815842ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/94859ebcc28b</guid>
            <category><![CDATA[nestjs]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[ngnix]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Ferhat Demir]]></dc:creator>
            <pubDate>Sat, 26 Aug 2023 12:45:00 GMT</pubDate>
            <atom:updated>2023-08-30T13:25:16.516Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lm9idZx0axf9Uls89sXRHg.jpeg" /></figure><p>Hello, everyone. I want to share how we can deploy our Frontend and Backend applications in this article. I used React.js on the Frontend and Nest.js on the Backend side.</p><p>First of all, I want to explain these terms;</p><p><strong>Web Hosting: </strong>Web hosting is an online service that makes your website’s content accessible online. When you purchase a hosting plan, you rent space on a physical server to store all the website’s files and data. I will use Hostinger in this article, but you can use other web hosting services like DigitalOcean, Contabo, etc.</p><p><strong>Nginx: </strong>Ngnix is open-source web server software designed to handle many connections simultaneously. It is a web server but is commonly used as a reverse proxy. It can be scaled efficiently as a web server and a reverse proxy. Ngnix also helps establish a secure connection between your data centers and the outside network. It works well as an HTTP load balancer that allows you to use multiple load-sharing mechanisms.</p><p><strong>PM2: </strong>PM2 is an advanced process manager for NodeJS applications that allows you to start, control, or stop your node processes quickly. It runs as a daemon on the server and will ensure your app is available 24/7. Therefore, I will run our backend on the server using the PM2 command.</p><h4>Installing Nginx</h4><p>First, I connect my remote Ubuntu server with SSH and run these commands.</p><pre>sudo apt update<br>sudo apt install nginx</pre><p>After these commands, Ubuntu starts Nginx. The server should already be up and running. Open your browser and navigate to your server’s IP address to access the default Nginx landing page to confirm that the software is running correctly.</p><h4>Configuring Nginx</h4><p>Before the Nginx configuration, let’s clone our application to the /var/www/your_domain folder. You can initialize and set up the app in this directory, or you can clone the app from GitHub. I cloned it because my app already exists in my GitHub.</p><p>Nginx on Ubuntu has one server block enabled by default that is configured to serve documents out of a directory at /var/www/</p><p>Then, let’s update the Backend .env file.</p><pre>APP_PORT=3000<br>APP_URL=http://your_ip_address<br>BE_APP_URL=http://your_ip_address</pre><p>And then, let’s update the Frontend .env file.</p><pre>VITE_PORT=3001<br>VITE_APP_URL=http://your_ip_address<br>VITE_BASE_API_URL=http://your_ip_address/api</pre><p><strong>Note: </strong>I did set a global prefix to my Nest.js app in start.ts using this command: app.setGlobalPrefix(&#39;api&#39;)</p><p>And then, let’s build our Backend and Frontend applications.</p><p>Now, we can continue to configure the Ngnix. Let’s run this command and open the Nginx config file.</p><p>sudo nano /etc/nginx/sites-available</p><p>We can configure it like this;</p><pre>server {<br> listen 80;<br> listen [::]:80;<br><br> root /var/www/your_domain/app/web/dist; #it&#39;s a build folder the frontend app<br> server_name your_domain your_ip_address;<br><br> location / {<br>   try_files $uri /index.html;<br> }<br><br> location /api {<br>     proxy_pass http://your_ip_address:3000;<br>            proxy_http_version 1.1;<br>            proxy_set_header Upgrade $http_upgrade;<br>            proxy_set_header Connection &#39;upgrade&#39;;<br>            proxy_set_header Host $host;<br>            proxy_cache_bypass $http_upgrade;<br>        }<br><br>}</pre><p>Next, let’s enable the file by creating a link from it to the sites-enabled directory, which Nginx reads from during startup:</p><p>ln -s /etc/nginx/sites-available/your_domain /etc/nginx/sites-enabled</p><ul><li>/etc/nginx: The Nginx configuration directory. All of the Nginx configuration files reside here.</li><li>/etc/nginx/sites-available/: The directory where per-site server blocks can be stored. Nginx will not use the configuration files in this directory unless linked to the sites-enabled directory. Typically, all server block configuration is done in this directory and then enabled by linking to the other directory.</li><li>/etc/nginx/sites-enabled/: The directory where enabled per-site server blocks are stored. Typically, these are created by linking to configuration files in the sites-available directory.</li></ul><p>Let’s test to make sure that there are no syntax errors in any of your Nginx files:</p><ul><li>sudo nginx -t</li></ul><p>And restart the nginx to enable our changes.</p><ul><li>sudo systemctl restart nginx</li></ul><p>Nginx should now be serving your Frontend app. You can test this by navigating to <a href="http://your_domain/">http://your_domain</a>, or <a href="http://your_ip_address/">http://your_ip_address</a></p><h4>Let’s serve the Backend</h4><p>I’m installing the PM2 with NPM and starting the backend app. pm2 start app.js</p><ul><li>npm install pm2@latest -g</li><li>pm2 start /var/www/your_domain</li></ul><p>And let’s check the process using the pm2 ps command.</p><blockquote>Some definitions were sourced from this website <a href="https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-20-04">https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-20-04</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94859ebcc28b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My software journey]]></title>
            <link>https://medium.com/@edemirferhat/my-software-journey-5027870d4010?source=rss-fb69815842ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/5027870d4010</guid>
            <dc:creator><![CDATA[Ferhat Demir]]></dc:creator>
            <pubDate>Wed, 25 Jan 2023 16:21:26 GMT</pubDate>
            <atom:updated>2023-08-26T12:50:23.004Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello. I have been working as a Software Engineer for about four years. I want to share the four years I spent and my experiences in this medium article.</p><p>First of all, I graduated from Selcuk University Computer Engineering. I started software with C and C++ programming languages in 1st grade. When I went to the second grade, I was unsatisfied with the education I received at school and went into different searches. Frontend technologies aroused my curiosity, and I started working on HTML, CSS, JavaScript, and making projects.</p><p>At this time, I learned that open source is an essential factor in the software world, and I started to think about how I can contribute to the open-source world.</p><p>I had about one year of experience in consolidating and sharing my knowledge;</p><ul><li>I wrote <a href="https://github.com/demirf/sass-rehberi">an article</a> on SCSS, a CSS preprocessor, and added it to <a href="https://github.com/fatihacet/turkcekaynaklar-com.">https://github.com/fatihacet/turkcekaynaklar-com</a>.</li><li>I made a live broadcast on Twitch for people curious about the software or Frontend technologies but at the very beginning of the road and shared them on <a href="https://www.youtube.com/@ferhatdemir9811">my YouTube channel</a>.</li><li>These topics were on HTML, CSS (SCSS, Flexbox), and Webpack.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CUKsXJu53Q-DwLbNzH9JXg.jpeg" /></figure><h4>Transition to Professional Life</h4><p>I wanted to work on an actual project. With that idea, I can use my knowledge and improve myself more. My paths crossed with Superpeer.</p><p>Although I do not have enough experience yet, my small contributions to the software community, my willingness, and my sincerity played a big role in my first business adventure.</p><h4>Remote Work</h4><p>I was working remotely at Superpeer company. This worried me at first. For a software developer who is just at the beginning of the road, the absence of an office is an obstacle for a person who is a beginner in development. WRONG!</p><ul><li>If you are in a team that cares about communication, you can take quick action on any question or problem.</li><li>With activities such as pair coding or fireside chat, you can cover your deficiencies in both technical and socialization.</li><li>Of course, this order may vary according to the company, and you, but Superpeer and remote work have improved me quickly.</li></ul><h4>The Team and Its Importance</h4><p>If the team is good, the project is good too. I always felt that I was in the right and a good team. So, what is the right team for me?</p><ul><li>First and foremost, If you are in a junior position, you should not hesitate to ask questions.</li><li>It is necessary to feel that you are always in progress.</li><li>Your codes should be reviewed, and feedback should be given to you.</li><li>Everyone on the team should be open to future positive/negative feedback.</li><li>You should be able to talk about different topics, not just technical and business.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BhoA3Rl-ZV38zVmwC6lEYw.jpeg" /></figure><h4>Summary</h4><p>My software adventure, which I started as a Frontend Developer, continues as a Full Stack Engineer. I love learning new things and applying them to projects.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5027870d4010" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>