<?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: NGUYEN THI HONG NHUNG</title>
    <description>The latest articles on DEV Community by NGUYEN THI HONG NHUNG (@nhungnguyen04).</description>
    <link>https://dev.to/nhungnguyen04</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%2F1350494%2Fbbcba2c0-6f60-47a0-85c1-0cf2c99a771e.jpeg</url>
      <title>DEV Community: NGUYEN THI HONG NHUNG</title>
      <link>https://dev.to/nhungnguyen04</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nhungnguyen04"/>
    <language>en</language>
    <item>
      <title>REST CRUD API</title>
      <dc:creator>NGUYEN THI HONG NHUNG</dc:creator>
      <pubDate>Tue, 03 Sep 2024 07:37:26 +0000</pubDate>
      <link>https://dev.to/nhungnguyen04/rest-crud-api-gao</link>
      <guid>https://dev.to/nhungnguyen04/rest-crud-api-gao</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;1. What are REST Services&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;-&amp;gt; A lightweight approach of communication between different apps&lt;br&gt;
-&amp;gt; &lt;em&gt;REST&lt;/em&gt; is language independent&lt;br&gt;
-&amp;gt; &lt;em&gt;REST&lt;/em&gt; works with any data format, but JSON is the most popular&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;2. JSON&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;An object:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
   "name": value
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Names of the object's attributes are always in double quote, value is in double quote if it is a string&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;4 HTTP methods: &lt;strong&gt;Post&lt;/strong&gt;(Create), &lt;strong&gt;GET&lt;/strong&gt;(Read), &lt;strong&gt;PUT&lt;/strong&gt;(Update), &lt;strong&gt;DELETE&lt;/strong&gt;(delete)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;3. Spring Rest Controller&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Development process:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Add Maven dependency for Spring Boot starter web&lt;/li&gt;
&lt;li&gt;Create Spring Rest Service using &lt;code&gt;@RestController&lt;/code&gt; (manually), instead you can use Rest's auto configuration, see in section &lt;em&gt;6&lt;/em&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;4. API Desgin Process&lt;/strong&gt;
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Review API's requirements&lt;/li&gt;
&lt;li&gt;Identify main entity/resource&lt;/li&gt;
&lt;li&gt;Use Http methods to assign action on resource&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;5. Spring JPA&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Automatically give &lt;strong&gt;CRUD&lt;/strong&gt; operations on entities&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Extend &lt;code&gt;JPARepository&lt;/code&gt; interface and plug in your entity and primary key&lt;/li&gt;
&lt;li&gt;Use your repository&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;6. Spring Data Rest&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;You only need to add &lt;code&gt;spring-boot-starter-data-rest&lt;/code&gt; dependency to your &lt;em&gt;pom.xml&lt;/em&gt; file, Spring will give &lt;strong&gt;REST CRUD&lt;/strong&gt; operations&lt;/p&gt;

</description>
      <category>java</category>
      <category>springboot</category>
      <category>mysql</category>
    </item>
  </channel>
</rss>
