Skip to content

Commit

Permalink
🔀 Merge pull request #161 from hemedani/main
Browse files Browse the repository at this point in the history
    - ⬆️ increase dependencies version
    - 🍱 improve declaration creation
    - 📖 generate new doc
  • Loading branch information
hemedani authored May 25, 2024
2 parents e9fc37c + 2512cc8 commit 1ee489a
Show file tree
Hide file tree
Showing 55 changed files with 1,886 additions and 1,385 deletions.
422 changes: 421 additions & 1 deletion deno.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/CSR_SSR_or_SSG_content.html
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,10 @@ <h1 class="menu-title">Lesan</h1>
<h1 id="csr-ssr-or-ssg-content"><a class="header" href="#csr-ssr-or-ssg-content">CSR, SSR or SSG content</a></h1>
<p>Content on the internet is usually divided into three parts: <code>CSR</code> or Client-Side Rendering, <code>SSR</code> or Server-Side Rendering and <code>SSG</code> or Static Site Generation. <code>CSR</code> content is usually created by JavaScript frameworks on the client side, which is why search engines cannot easily understand them. <code>SSR</code> content is processed on the server side and is easily understandable by search engines. However, to create this content, the server must be involved in processing them each time. The best contents for publishing on the web are <code>SSG</code> contents because they are completely understandable by search engines and the server will not be involved in processing their data. Static contents can be placed on <code>CDNs</code> (Content Delivery Networks) and requests for this content can be returned from the stored location on the network before it reaches the <code>server</code>. To understand the popularity of <code>SSG</code> content, you can refer to popular JavaScript frameworks such as <code>Gastby</code> and <code>NextJS</code>.</p>
<p>One of the biggest problems with creating <code>SSG</code> content is the complexity of the data model. As the <code>number</code> of requests for data from the <code>database</code> increases, the amount of content that can be converted to <code>SSG</code> decreases. Because to create <code>SSG</code> content, the number of requests to the <code>database</code> must reach <code>zero</code> in order to produce static content.</p>
<p><code>Lesan’s</code> framework has simplified the conditions for creating <code>SSG</code> content by reducing the <code>number</code> of requests to the <code>database</code>. </p>
<p>In addition, <code>Lesan</code> only updates <code>SSG</code> content when a data has changed. Unlike the process that is usually used in <code>NextJS</code> or <code>Gastby</code>, which uses time periods to create and update <code>SSG</code> content due to lack of <code>awareness</code> of data changes. In this way, a specific time is determined in advance (for example, one day) to generate <code>SSG</code> content, and when that time ends, they send a request to the server to receive the content again and convert it to <code>SSG</code> and repeat this process. This cycle has two major problems: </p>
<p><code>Lesan’s</code> framework has simplified the conditions for creating <code>SSG</code> content by reducing the <code>number</code> of requests to the <code>database</code>.</p>
<p>In addition, <code>Lesan</code> only updates <code>SSG</code> content when a data has changed. Unlike the process that is usually used in <code>NextJS</code> or <code>Gastby</code>, which uses time periods to create and update <code>SSG</code> content due to lack of <code>awareness</code> of data changes. In this way, a specific time is determined in advance (for example, one day) to generate <code>SSG</code> content, and when that time ends, they send a request to the server to receive the content again and convert it to <code>SSG</code> and repeat this process. This cycle has two major problems:</p>
<ul>
<li>First, it is possible that the data has <code>not changed</code> and an unnecessary processing task is imposed on the server which can cause problems if the <code>number</code> of these requests on the server increases. </li>
<li>First, it is possible that the data has <code>not changed</code> and an unnecessary processing task is imposed on the server which can cause problems if the <code>number</code> of these requests on the server increases.</li>
<li>And the second problem is that it is possible for the content on the server to change and it may be <code>necessary</code> to quickly update that content everywhere, including places where <code>SSG</code> content is stored. But in current processes, we have to <code>wait</code> until the time we have set in advance ends and send <code>another</code> request to the server to update the <code>SSG</code> content.</li>
</ul>
<p>Returning to the example of a news agency, if this website intends to convert its news to <code>SSG</code> content, it will face both of the above problems. On the one hand, the process of generating <code>SSG</code> content may be performed for many news items that have <code>not changed</code>, which creates an unnecessary processing load for the server. On the other hand, it is possible that a news item has been mistakenly converted to <code>SSG</code> content and the news agency wants to remove it quickly, but we have to wait until the end of the specified time for that content to disappear. Also, someone has to request this news after the end of this time. For these two simple reasons, many websites prefer to process their content in <code>SSR</code> form. But how can we create <code>SSG</code> content only when data changes in the main <code>database</code>? This can be easily done with <code>Lesan</code>.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,20 +233,20 @@ <h2 id="proposed-method"><a class="header" href="#proposed-method">Proposed Meth
<pre><code class="language-ts">const cityRelations = {
country: {
optional: false,
schemaName: &quot;country&quot;,
type: &quot;single&quot; as RelationDataType,
schemaName: "country",
type: "single" as RelationDataType,
},
province: {
optional: false,
schemaName: &quot;province&quot;,
type: &quot;single&quot; as RelationDataType,
schemaName: "province",
type: "single" as RelationDataType,
},
};
const provinceRelations = {
country: {
optional: false,
schemaName: &quot;country&quot;,
type: &quot;single&quot; as RelationDataType,
schemaName: "country",
type: "single" as RelationDataType,
},
};

Expand All @@ -257,30 +257,30 @@ <h2 id="proposed-method"><a class="header" href="#proposed-method">Proposed Meth
<pre><code class="language-typescript">const cityRelations = {
country: {
optional: false,
schemaName: &quot;country&quot;,
type: &quot;single&quot; as RelationDataType,
schemaName: "country",
type: "single" as RelationDataType,
relatedRelations: {
cities: {
type: &quot;multiple&quot; as RelationDataType,
type: "multiple" as RelationDataType,
limit: 50,
sort: {
field: &quot;_id&quot;,
order: &quot;desc&quot; as RelationSortOrderType,
field: "_id",
order: "desc" as RelationSortOrderType,
},
},
}
},
province: {
optional: false,
schemaName: &quot;province&quot;,
type: &quot;single&quot; as RelationDataType,
schemaName: "province",
type: "single" as RelationDataType,
relatedRelations: {
cities: {
type: &quot;multiple&quot; as RelationDataType,
type: "multiple" as RelationDataType,
limit: 50,
sort: {
field: &quot;_id&quot;,
order: &quot;desc&quot; as RelationSortOrderType,
field: "_id",
order: "desc" as RelationSortOrderType,
},
},
}
Expand All @@ -289,15 +289,15 @@ <h2 id="proposed-method"><a class="header" href="#proposed-method">Proposed Meth
const provinceRelations = {
country: {
optional: false,
schemaName: &quot;country&quot;,
type: &quot;single&quot; as RelationDataType,
schemaName: "country",
type: "single" as RelationDataType,
relatedRelations: {
provinces: {
type: &quot;multiple&quot; as RelationDataType,
type: "multiple" as RelationDataType,
limit: 50,
sort: {
field: &quot;_id&quot;,
order: &quot;desc&quot; as RelationSortOrderType,
field: "_id",
order: "desc" as RelationSortOrderType,
},
},
}
Expand All @@ -311,15 +311,15 @@ <h2 id="proposed-method"><a class="header" href="#proposed-method">Proposed Meth
So we can add a new <code>relatedRelation</code> in the definition of city relationships where we have linked the country to the city:</p>
<pre><code class="language-ts">relatedRelations: {
cities: {
type: &quot;multiple&quot; as RelationDataType,
type: "multiple" as RelationDataType,
limit: 50,
sort: {
field: &quot;_id&quot;,
order: &quot;desc&quot; as RelationSortOrderType,
field: "_id",
order: "desc" as RelationSortOrderType,
},
},
capital: {
type: &quot;single&quot;,
type: "single",
},
}
</code></pre>
Expand All @@ -329,37 +329,37 @@ <h2 id="proposed-method"><a class="header" href="#proposed-method">Proposed Meth
const cityRelations = {
country: {
optional: false,
schemaName: &quot;country&quot;,
type: &quot;single&quot; as RelationDataType,
schemaName: "country",
type: "single" as RelationDataType,
relatedRelations: {
cities: {
type: &quot;multiple&quot; as RelationDataType,
type: "multiple" as RelationDataType,
limit: 50,
sort: {
field: &quot;_id&quot;,
order: &quot;desc&quot; as RelationSortOrderType,
field: "_id",
order: "desc" as RelationSortOrderType,
},
},
capital: {
type: &quot;single&quot;,
type: "single",
},
}
},
province: {
optional: false,
schemaName: &quot;province&quot;,
type: &quot;single&quot; as RelationDataType,
schemaName: "province",
type: "single" as RelationDataType,
relatedRelations: {
cities: {
type: &quot;multiple&quot; as RelationDataType,
type: "multiple" as RelationDataType,
limit: 50,
sort: {
field: &quot;_id&quot;,
order: &quot;desc&quot; as RelationSortOrderType,
field: "_id",
order: "desc" as RelationSortOrderType,
},
},
center: {
type: &quot;single&quot;,
type: "single",
},
}
},
Expand All @@ -369,15 +369,15 @@ <h2 id="proposed-method"><a class="header" href="#proposed-method">Proposed Meth
const provinceRelations = {
country: {
optional: false,
schemaName: &quot;country&quot;,
type: &quot;single&quot; as RelationDataType,
schemaName: "country",
type: "single" as RelationDataType,
relatedRelations: {
provinces: {
type: &quot;multiple&quot; as RelationDataType,
type: "multiple" as RelationDataType,
limit: 50,
sort: {
field: &quot;_id&quot;,
order: &quot;desc&quot; as RelationSortOrderType,
field: "_id",
order: "desc" as RelationSortOrderType,
},
},
}
Expand Down Expand Up @@ -405,47 +405,47 @@ <h2 id="proposed-method"><a class="header" href="#proposed-method">Proposed Meth
</code></pre>
<p>The amount of pure fields is known. And the value of the fields that are of the relation type of schemas will be in the form of <code>objects</code> or <code>array of objects</code> of the pure type of that relation. That is, for example, for the country:</p>
<pre><code class="language-ts">{
id: &quot;234fwee656&quot;,
name: &quot;iran&quot;,
abb: &quot;ir&quot;,
description: &quot;a big country in asia&quot;,
id: "234fwee656",
name: "iran",
abb: "ir",
description: "a big country in asia",
geoLocation : [ [12,4], [32,45], ... ],
capital : {
id: &quot;234fwee656&quot;,
name: &quot;tehran&quot;,
abb: &quot;th&quot;,
description: &quot;the beautiful city in middle of iran&quot;,
id: "234fwee656",
name: "tehran",
abb: "th",
description: "the beautiful city in middle of iran",
geoLocation : [ [12,4], [32,45], ... ]
},
provinces : [{
id: &quot;234fwee656&quot;,
name: &quot;tehran&quot;,
abb: &quot;th&quot;,
description: &quot;one of the irans provinces&quot;,
id: "234fwee656",
name: "tehran",
abb: "th",
description: "one of the irans provinces",
geoLocation : [ [12,4], [32,45], ... ]
},
{

id: &quot;234fwee656&quot;,
name: &quot;hamedan&quot;,
abb: &quot;hm&quot;,
description: &quot;one of the irans provinces&quot;,
id: "234fwee656",
name: "hamedan",
abb: "hm",
description: "one of the irans provinces",
geoLocation : [ [12,4], [32,45], ... ]
},
... til to end of the provinces
}],
cities : [{
id: &quot;234fwee656&quot;,
name: &quot;tehran&quot;,
abb: &quot;th&quot;,
description: &quot;the beautiful city in middle of iran&quot;,
id: "234fwee656",
name: "tehran",
abb: "th",
description: "the beautiful city in middle of iran",
geoLocation : [ [12,4], [32,45], ... ]
},
{
Id: &quot;234fwee656&quot;,
name: &quot;hamedan&quot;,
abb: &quot;hm&quot;,
description: &quot;one of the irans cities&quot;,
Id: "234fwee656",
name: "hamedan",
abb: "hm",
description: "one of the irans cities",
geoLocation : [ [12,4], [32,45], ... ]
},
... til to end of the number limit for the first paginate
Expand Down
Loading

0 comments on commit 1ee489a

Please sign in to comment.