<?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 Steven Jung on Medium]]></title>
        <description><![CDATA[Stories by Steven Jung on Medium]]></description>
        <link>https://medium.com/@jungs1?source=rss-3f06b11e7013------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ybBJXB1NJlXOBnQK8g-Nvw.png</url>
            <title>Stories by Steven Jung on Medium</title>
            <link>https://medium.com/@jungs1?source=rss-3f06b11e7013------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 11:46:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jungs1/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[Which API Architecture to choose? — RPC, GraphQL, REST]]></title>
            <link>https://medium.com/@jungs1/which-api-architecture-to-choose-rpc-graphql-rest-7c2a3ea89ff?source=rss-3f06b11e7013------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c2a3ea89ff</guid>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[api-architecture]]></category>
            <category><![CDATA[rest]]></category>
            <category><![CDATA[rpc]]></category>
            <dc:creator><![CDATA[Steven Jung]]></dc:creator>
            <pubDate>Sun, 11 Jun 2023 15:05:14 GMT</pubDate>
            <atom:updated>2023-06-11T15:05:14.195Z</atom:updated>
            <content:encoded><![CDATA[<h3>Which API Architecture to choose? — RPC, GraphQL, REST</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q8uFtm-HH3lGpqu2_Do4qg.png" /></figure><p>In the realm of designing request-response APIs, several paradigms each with distinct advantages and considerations have emerged. This article focuses on three principal paradigms: REST, RPC (Remote Procedure Call), and GraphQL, aiming to provide an in-depth comparison and guidance on their respective use cases.</p><h3>REST API: The Resource-Centric Paradigm</h3><p>REST (Representational State Transfer) APIs are resource-centric, giving precedence to entities or ‘nouns’ over actions. This is exemplified in the way URLs are constructed to represent collections and individual entities in a structured format.</p><p>- Collection of users: `/api/v1/users` <br>- Individual user: `/api/v1/users/{userId}`<br>- Orders associated with a specific user: `/api/v1/users/{userId}/orders`</p><p>REST APIs conventionally utilize CRUD (Create, Read, Update, Delete) operations, facilitated through HTTP methods such as POST, GET, PUT, PATCH, and DELETE. REST APIs are known for their standardization, leveraging HTTP features effectively, and are generally easy to maintain and understand. However, there are times where actions or operations do not neatly fit into the RESTful paradigm. <br>Let’s consider a social media platform that allows users to follow other users. In a RESTful API design, the following operations are typically associated with resources:</p><p>- Creating a user: `POST /users`<br>- Retrieving a user: `GET /users/{id}`<br>- Updating a user: `PUT /users/{id}`<br>- Deleting a user: `DELETE /users/{id}`</p><p>However, when it comes to the operation of “following” another user, it doesn’t fit neatly into the CRUD (Create, Read, Update, Delete) paradigm. The action of “following” doesn’t directly map to a specific resource or entity. It’s a relationship between two users, but it doesn’t make sense to have a dedicated resource for “follows” or “followers”. One way to handle this in a RESTful API is by introducing a non-resourceful action. For example:</p><p>- Creating a follow relationship: `POST /users/{followerId}/follows/{followedId}`<br>- Removing a follow relationship: `DELETE /users/{followerId}/follows/{followedId}`</p><p>In this approach, the follow relationship is treated as a sub-resource under the user resource. However, it’s important to note that this doesn’t strictly adhere to the RESTful principles since it goes beyond the basic CRUD operations. Another alternative is to consider a different architectural style, such as using a custom RPC (Remote Procedure Call) API or implementing specific endpoints for the non-resourceful actions. For example:</p><p>- Following a user: `POST /follow`<br>- Unfollowing a user: `POST /unfollow`</p><p>In this approach, the API endpoints are designed specifically for the “following” and “unfollowing” actions, without trying to fit them into a resource-centric model.</p><p><em>Advantages of REST API:<br></em>- Consistency in method names, arguments, and status codes.<br>- Effective utilization of HTTP features.<br>- Ease of maintenance due to its standardized approach.</p><p><em>Limitations of REST API:</em><br>- Potential for large payloads owing to multiple round trips.<br>- Requirement of multiple HTTP requests for fetching related resources.</p><p>REST APIs are particularly beneficial for systems that need to expose CRUD-like operations. For example, a user management system that requires frequent creation, retrieval, updating, and deletion of user records can benefit from a REST API’s resource-centric approach.</p><h3>GraphQL: The Contract-Oriented Paradigm</h3><p>GraphQL, unlike REST and RPC is not just an architectural style. GraphQL is also a query language that serves as a contract between the backend and frontend. This paradigm significantly reduces the number of round trips between server and client. GraphQL solves the problems of over-fetching and under-fetching by allowing clients to specify exactly what data they need in a single query. This feature reduces payload size and eliminates the need for versioning that’s often necessary in REST APIs. However, GraphQL also introduces additional complexity, and optimizing performance can pose challenges. For simple APIs, GraphQL may be unnecessarily complex. Here’s an example using GraphQL for the social media platform’s “follow” functionality:<br>With GraphQL, you can define a specific mutation operation for creating a follow relationship between users. Here’s an example schema for the social media platform:</p><pre>type User {<br> id: ID!<br> name: String!<br> followers: [User!]!<br> following: [User!]!<br>}<br><br>type Mutation {<br> followUser(followerId: ID!, followedId: ID!): User!<br>}</pre><p>In this schema, we have a `User` type representing a user in the social media platform. The `User` type has fields like `id`, `name`, `followers`, and `following`, which represent the relationships between users.</p><p>The `followUser` mutation allows clients to create a follow relationship between two users. The `followerId` parameter represents the ID of the user who is following, and the `followedId` parameter represents the ID of the user being followed. The mutation returns the updated user object for the follower.</p><p>To create a follow relationship using GraphQL, a client can send a mutation request like this:</p><pre>mutation {<br> followUser(followerId: &quot;123&quot;, followedId: &quot;456&quot;) {<br> id<br> name<br> followers {<br>   id<br>   name<br>  }<br>  following {<br>   id<br>   name<br>  }<br>}</pre><p>In this example, the client is requesting to follow the user with ID “456” from the user with ID “123”. The response from the server will include the updated user object for the follower, including their ID, name, and the updated lists of followers and following.</p><p>Using GraphQL allows you to define specific operations that align with your application’s requirements, including actions like “follow” that may not fit neatly into the traditional RESTful CRUD model. With its flexible and expressive schema definition, GraphQL provides a powerful way to handle diverse data relationships and operations in a more tailored manner.</p><p>Here is a different example that illustrates how GraphQL can reduce the payload size. <br>Let’s consider an example where a social media platform needs to retrieve a user’s profile information along with their recent posts.</p><p>Using REST API:</p><p>To achieve this with REST API, you might need to make two separate requests:</p><p>1. Retrieve user profile: `GET /users/{id}`<br> <br>2. Retrieve recent posts: `GET /users/{id}/posts?limit=5`</p><p>Each request would return different data, with the first request providing the user’s profile information and the second request returning the user’s recent posts.</p><p>Using GraphQL:</p><p>With GraphQL, you can fetch both the user’s profile information and their recent posts in a single request, minimizing the number of API calls required, and payload size by specifying exactly what fields you what in the response.</p><pre>query {<br> user(id: &quot;{id}&quot;) {<br>   name<br>   age<br>   email<br>   posts(limit: 5) {<br>     title<br>     content<br>     createdAt<br>   }<br> }<br>}</pre><p><em>Advantages of GraphQL:<br></em>- Reduces multiple round trips, improving communication efficiency.<br>- Eliminates versioning issues, simplifying API updates and maintenance.<br>- Smaller payload size, leading to faster data transfer.</p><p><em>Limitationsof GraphQL:<br></em>- Increased complexity in implementation and maintenance compared to REST and RPC.<br>- Performance optimization can be challenging, requiring specialized knowledge and strategies.<br>- May be overly complicated for simple APIs that do not require complex data retrieval.</p><p>GraphQL becomes particularly beneficial when there’s a requirement for client-side data filtering and flexibility in data retrieval. An example use case could be a content aggregation platform where the client needs to fetch varied data types, like articles, images, and user comments, from different sources in a single request.</p><h3>RPC: The Action-Oriented Paradigm</h3><p>Unlike REST, RPC or Remote Procedure Call focuses on actions rather than resources. This paradigm generally offers lightweight payloads and the function names are often descriptive, providing clear hints about their functionality. RPC libraries can enhance client-server interactions with features such as type safety. Despite the lack of standardization at par with REST, RPC can be a more efficient option in certain scenarios. It is often implemented within a monorepo, which promotes better code sharing.</p><p><em>Advantages of RPC:</em><br>- Ease of comprehension due to its focus on actions.<br>- Lightweight payloads promoting efficient data transfer.<br>- High performance due to fewer data requirements.</p><p><em>Limitations of RPC:</em><br>- Discovery of available actions can be challenging due to lack of standardization.<br>- Limited standardization compared to REST.</p><p>RPC serves as an effective choice when an API needs to expose a variety of actions. For instance, in a complex banking system where diverse actions like ‘TransferMoney’, ‘CheckBalance’, or ‘IssueStatement’ are required, an RPC architecture can prove beneficial due to its action-centric nature.</p><h3>Conclusion: Choosing the Right API Architecture</h3><p>While all these paradigms have their unique strengths and limitations, the decision of which to use should be largely influenced by the specific requirements and trade-offs of your application. REST APIs offer a reliable and standardized approach, RPC provides an action-oriented perspective with lightweight payloads, and GraphQL offers a contract-oriented approach with greater flexibility in data retrieval.</p><p>As the technology landscape continues to evolve, understanding these paradigms will empower you to make informed decisions that align with your project’s needs and objectives. The right API architecture is the one that most effectively caters to your application’s requirements while balancing performance, complexity, and maintainability.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c2a3ea89ff" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up Strapi using Google App Engine with Google Cloud Storage]]></title>
            <link>https://medium.com/@jungs1/setting-up-strapi-using-google-app-engine-with-google-cloud-storage-8e08d07117ef?source=rss-3f06b11e7013------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e08d07117ef</guid>
            <category><![CDATA[software-testing]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[quality-assurance-testing]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Steven Jung]]></dc:creator>
            <pubDate>Fri, 17 Feb 2023 02:14:36 GMT</pubDate>
            <atom:updated>2023-03-30T06:43:11.217Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Complete Guide to setup Strapi with Google App Engine and Google Cloud Storage</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XF9DkyC8oXn1c-VHlQjPaQ.jpeg" /><figcaption>Strapi + Google App Engine + Google Cloud Storage</figcaption></figure><h3>Introduction</h3><p>In this tutorial, we will be setting up a Strapi project and deploying it to Google App Engine. In addition, we will also configure Strapi to use Google Cloud Storage as its storage solution.</p><h3>Prerequisites</h3><p>Before proceeding with this tutorial, you should have the following components installed:</p><ul><li>@strapi/strapi: 4.6.1</li><li>@strapi-community/strapi-provider-upload-google-cloud-storage: 4.6.1</li><li>pg: 8.9.0</li></ul><h3>Creating a new Strapi project</h3><p>First, create a new Strapi project by executing the following command:</p><pre>npx create-strapi-app@latest my-project --quickstart</pre><p>Once the project has been created, install the required pg package by executing the following command:</p><pre>npm i pg@4.6.1</pre><h3>Creating an App Engine project</h3><p>Create a new <a href="https://console.cloud.google.com/projectselector2/appengine?supportedpurview=project">App Engine</a> project with the following configuration:</p><ul><li>Language: Node.js</li><li>Environment: Standard (or Flexible)</li></ul><p>Once the project has been created, take note of the instance identifier, which has the following format:</p><pre>&lt;instance_id&gt;:&lt;region&gt;:&lt;instance_name&gt;<br><br>ex) myapi-123456:europe-west1:myapi</pre><p>Also, take note of the default App Engine default service account, or a custom service account you have set up for the App Engine. We need to add specific roles in order for Strapi to be deployed to App Engine. The service account has the following format:</p><pre>myapi-123456@appspot.gserviceaccount.com</pre><h3>Creating a Cloud SQL database</h3><p>Configure the Cloud SQL database as you like with regard to storage, region, database name, and so on. Take note of the user name (default is postgres) and password. In the ./config/env/production/database.ts file, add the following code to specify the connection details for the database:// path: ./config/env/production/database.ts</p><pre>// path: ./config/env/production/database.ts<br>export default ({ env }) =&gt; ({<br>  connection: {<br>    client: &#39;postgres&#39;,<br>    connection: {<br>      host: `/cloudsql/${env(&#39;INSTANCE_CONNECTION_NAME&#39;)}`,<br>      database: env(&#39;DATABASE_NAME&#39;),<br>      user: env(&#39;DATABASE_USER&#39;),<br>      password: env(&#39;DATABASE_PASSWORD&#39;),<br>    },<br>  },<br>});</pre><h3>Configuring Permissions</h3><p>Go to the IAM &amp; Admin section in your Google Cloud console, click on Grant Access, and configure as follows:</p><ul><li>New principals: my-api-123456@appspot.gserviceaccount.com (App Engine default service account or a custom service account you created above)</li><li>Assign Roles: Cloud SQL Client</li></ul><p>It is important to assign the Cloud SQL Client role to the service account in order for App Engine to connect with the Cloud SQL database. If you do not assign this role, you will encounter the following error when you access your webpage after deployment:</p><pre>[Error: connect ECONNREFUSED /cloudsql/&lt;instance_id&gt;:&lt;region&gt;:&lt;instance_name&gt;:&lt;db_name&gt;/.s.PGSQL.5432](https://console.cloud.google.com/errors/...) .PipeConnectWrap.afterConnect ( node:net:1278 )</pre><h3>Creating an app.yaml file</h3><p>Create an app.yaml file with the following content:</p><pre>runtime: nodejs16<br>instance_class: F2<br>env_variables:<br>  HOST: &#39;0.0.0.0&#39;<br>  NODE_ENV: &#39;production&#39;<br>  DATABASE_NAME: &#39;strapi&#39;<br>  DATABASE_USER: &#39;postgres&#39;<br>  DATABASE_PASSWORD: &#39;password&#39;<br>  INSTANCE_CONNECTION_NAME: &#39;myapi-123456:europe-west1:myapi&#39;<br>beta_settings:<br>  cloud_sql_instances: &#39;myapi-123456:europe-west1:myapi&#39;<br>service_account: &#39;myapi-123456@appspot.gserviceaccount.com&#39;</pre><h3>Create .gcloudignore</h3><pre>.gcloudignore<br>.git<br>.gitignore<br>node_modules/<br>#!include:.gitignore<br>!.env<br>yarn.lock  # If you&#39;re using Yarn</pre><h3>Adding .gitkeep to the database/migrations folder</h3><p>Google App Engine does not give mkdir permissions, and the database/migrations folder is required for deployments. Ensure that git keeps track of the database/migrations folder by adding a .gitkeep file to the folder with the following command:</p><pre>touch database/migrations/.gitkeep<br>```</pre><h3>Deploying the Strapi project</h3><p>Deploy the Strapi project by executing the following command:</p><pre>gcloud app deploy app.yaml --project &lt;project_id&gt;</pre><p>Congratulations, you have successfully completed part 1 of setting up Strapi using Google App Engine. However, what good is your CMS if you do not have storage like Google Storage configured? Next step is to configure Strapi to use Google Cloud Storage using the recommended Strapi plugin called <a href="https://github.com/strapi-community/strapi-provider-upload-google-cloud-storage">strapi-provider-upload-google-cloud-stroage</a></p><h3>Configuring Google Cloud Storage for Strapi</h3><p>Install the strapi-provider-upload-google-cloud-storage plugin by executing the following command:</p><pre>npm i @strapi-community/strapi-provider-upload-google-cloud-storage@4.6.1</pre><p>For people who want to read the official guide click <a href="https://github.com/strapi-community/strapi-provider-upload-google-cloud-storage">here</a></p><h3>Setting up Google authentication for development</h3><ol><li>In the GCP Console, go to the <strong>Create service account key</strong> page.</li><li>From the <strong>Service account</strong> list, select <strong>New service account</strong>.</li><li>In the <strong>Service account name</strong> field, enter a name.</li><li>From the <strong>Role</strong> list, select <strong>Cloud Storage &gt; Storage Admin</strong>.</li><li>Select JSON for <strong>Key Type</strong></li><li>Click <strong>Create</strong>. A JSON file that contains your key downloads to your computer.</li><li>Copy the full content of the downloaded JSON file</li><li>Open the Strapi configuration file</li><li>Paste it into the “Service Account JSON” field (as string or JSON, be careful with indentation)</li></ol><p>Editconfig/env/dev/plugins.ts</p><pre>module.exports = ({ env }) =&gt; ({<br>  upload: {<br>    config: {<br>      provider: &quot;@strapi-community/strapi-provider-upload-google-cloud-storage&quot;,<br>      providerOptions: {<br>        sizeLimit: 5 * 1024 * 1024 * 1024, // 5GB in bytes<br>        bucketName: &quot;my-bucket&quot;,<br>        publicFiles: true,<br>        uniform: true,<br>        serviceAccount: {/**YOUR SERVICE ACCOUNT KEY**/},<br>    },<br>  },<br>});</pre><h3>Setting up Google authentication for production</h3><p>Editconfig/env/production/plugins.ts</p><pre>module.exports = ({ env }) =&gt; ({<br>  upload: {<br>    config: {<br>      provider: &quot;@strapi-community/strapi-provider-upload-google-cloud-storage&quot;,<br>      providerOptions: {<br>        sizeLimit: 5 * 1024 * 1024 * 1024, // 5GB in bytes<br>        bucketName: &quot;my-bucket&quot;,<br>        publicFiles: true,<br>        uniform: true,<br>    },<br>  },<br>});</pre><h3>Setting up strapi::security middlewares to avoid CSP blocked url</h3><p>Edit ./config/middlewares.ts</p><p>In the field img-src and media-src add your own CDN url, by default it&#39;s storage.googleapis.com but you need to add your own CDN url</p><pre>module.exports = [<br>  &#39;strapi::errors&#39;,<br>  {<br>    name: &#39;strapi::security&#39;,<br>    config: {<br>      contentSecurityPolicy: {<br>        useDefaults: true,<br>        directives: {<br>          &#39;connect-src&#39;: [&quot;&#39;self&#39;&quot;, &#39;https:&#39;],<br>          &#39;img-src&#39;: [&quot;&#39;self&#39;&quot;, &#39;data:&#39;, &#39;blob:&#39;, &#39;storage.googleapis.com&#39;],<br>          &#39;media-src&#39;: [&quot;&#39;self&#39;&quot;, &#39;data:&#39;, &#39;blob:&#39;, &#39;storage.googleapis.com&#39;],<br>          upgradeInsecureRequests: null,<br>        },<br>      },<br>    },<br>  },<br>  &#39;strapi::cors&#39;,<br>  &#39;strapi::poweredBy&#39;,<br>  &#39;strapi::logger&#39;,<br>  &#39;strapi::query&#39;,<br>  &#39;strapi::body&#39;,<br>  &#39;strapi::favicon&#39;,<br>  &#39;strapi::public&#39;,<br>];</pre><h3>Bucket Settings and Permissions</h3><p>Unfortunately, at the time of this writing, it is best to make your bucket public because images cannot be read by the Strapi frontend.</p><p>Also it is important to set up the appropriate bucket permissions. Make sure you add allUsers and allAuthenticatedUsers access with the following roles:</p><ul><li>allUsers: Storage Object Viewer</li><li>allAuthenticatedUsers: Storage Admin, Storage Object Admin</li></ul><p>By following these steps, you should be able to successfully set up Strapi using Google App Engine with Google Cloud Storage.</p><h3>CORS Settings</h3><p>Lastly, you will need to update CORS to view the thubmnails stored in your Google Cloud Storage from your CMS.</p><p>If you want to learn more, you can refer to the official guide <a href="https://cloud.google.com/storage/docs/using-cors">here</a>.</p><p>First create a JSON file with the following settings:</p><pre>[<br>  {<br>    &quot;origin&quot;: [<br>      &quot;https://xxxx.com&quot; #CMS URL <br>    ],<br>    &quot;method&quot;: [&quot;GET&quot;, &quot;POST&quot;, &quot;PUT&quot;, &quot;DELETE&quot;, &quot;PATCH&quot;]<br>  }<br>]</pre><p>After you have created the above json, update the CORS settings using gcloud cli</p><pre>gcloud storage buckets describe gs://BUCKET_NAME --format=&quot;default(cors)&quot;</pre><p>You are finally done :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e08d07117ef" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>