Skip to content

Commit

Permalink
feat: 🎸 Add cache handling for If-None-Match/Etag (#4)
Browse files Browse the repository at this point in the history
* feat: 🎸 Add cache handling for If-None-Match/Etag
  • Loading branch information
dkolba authored Jun 14, 2023
1 parent 7fcd1d8 commit c8b8595
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 98 deletions.
27 changes: 15 additions & 12 deletions __snapshots__/luhmann_test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,20 @@ Some test text",

snapshot[`simpleSnippet with bare data isSnapshotMatch 1`] = `
'<section>
<h2><a href="/missing name">missing title</a></h2>
<time datetime="Mon, 22 May 2023 19:57:18 GMT"></time>
<span>missing teaser</span>
\\t\\t </section>'
<h2><a href="/missing name">missing title</a></h2>
<time datetime="Mon, 22 May 2023 19:57:18 GMT"></time>
<span>missing teaser</span>
<span> - </span><time datetime="Mon, 22 May 2023 19:57:18 GMT">2023/4/1</time>
\\t</section>'
`;

snapshot[`simpleSnippet with full data isSnapshotMatch 1`] = `
'<section>
<h2><a href="/testslug">Test title</a></h2>
<time datetime="Mon, 22 May 2023 19:57:18 GMT"></time>
<span>Test teaser</span>
\\t\\t </section>'
<h2><a href="/testslug">Test title</a></h2>
<time datetime="Mon, 22 May 2023 19:57:18 GMT"></time>
<span>Test teaser</span>
<span> - </span><time datetime="Mon, 22 May 2023 19:57:18 GMT">2023/4/1</time>
\\t</section>'
`;

snapshot[`generateDocument isSnapshotMatch 1`] = `
Expand Down Expand Up @@ -139,9 +141,10 @@ Some test text",
snapshot[`teaserifyDocs & markupify isSnapshotMatch 2`] = `
[
'<section>
<h2><a href="/test">A first test title</a></h2>
<time datetime="Fri, 21 May 2032 00:00:00 GMT">21.5.2032</time>
<span>Best test teaser in the industry</span>
\\t\\t </section>',
<h2><a href="/test">A first test title</a></h2>
<time datetime="Fri, 21 May 2032 00:00:00 GMT">21.5.2032</time>
<span>Best test teaser in the industry</span>
<span> - </span><time datetime="Fri, 21 May 2032 00:00:00 GMT">2032/4/5</time>
\\t</section>',
]
`;
36 changes: 20 additions & 16 deletions __snapshots__/luhmann_test_e2e.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ snapshot[`e2e isSnapshotMatch 1`] = `
<body>
<main data-color-mode="light" data-light-theme="light" data-dark-theme="dark" class="markdown-body">
<section>
<h2><a href="/test_zettel_1">A first test title</a></h2>
<time datetime="Fri, 21 May 2032 00:00:00 GMT">21.5.2032</time>
<span>Best test teaser in the industry</span>
\\t\\t </section><section>
<h2><a href="/test_zettel_2">A second test title</a></h2>
<time datetime="Sat, 22 May 2032 00:00:00 GMT">22.5.2032</time>
<span>Second best test teaser in the industry</span>
\\t\\t </section>
<h2><a href="/test_zettel_1">A first test title</a></h2>
<time datetime="Fri, 21 May 2032 00:00:00 GMT">21.5.2032</time>
<span>Best test teaser in the industry</span>
<span> - </span><time datetime="Fri, 21 May 2032 00:00:00 GMT">2032/4/5</time>
\\t</section><section>
<h2><a href="/test_zettel_2">A second test title</a></h2>
<time datetime="Mon, 24 Dec 2001 00:00:00 GMT">24.12.2001</time>
<span>Second best test teaser in the industry</span>
<span> - </span><time datetime="Mon, 24 Dec 2001 00:00:00 GMT">2001/11/1</time>
\\t</section>
</main>
</body>
</html>
Expand All @@ -50,10 +52,11 @@ snapshot[`e2e isSnapshotMatch 2`] = `
<body>
<main data-color-mode="light" data-light-theme="light" data-dark-theme="dark" class="markdown-body">
<section>
<h2><a href="/test_zettel_1">A first test title</a></h2>
<time datetime="Fri, 21 May 2032 00:00:00 GMT">21.5.2032</time>
<span>Best test teaser in the industry</span>
\\t\\t </section><h2 id="test-headline-1"><a class="anchor" aria-hidden="true" tabindex="-1" href="#test-headline-1"><svg class="octicon octicon-link" viewbox="0 0 16 16" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Test Headline 1</h2><p>An unordered test list</p>
<h2><a href="/test_zettel_1">A first test title</a></h2>
<time datetime="Fri, 21 May 2032 00:00:00 GMT">21.5.2032</time>
<span>Best test teaser in the industry</span>
<span> - </span><time datetime="Fri, 21 May 2032 00:00:00 GMT">2032/4/5</time>
\\t</section><h2 id="test-headline-1"><a class="anchor" aria-hidden="true" tabindex="-1" href="#test-headline-1"><svg class="octicon octicon-link" viewbox="0 0 16 16" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Test Headline 1</h2><p>An unordered test list</p>
<ul>
<li>Test list item 1</li>
<li>Test list item 2</li>
Expand Down Expand Up @@ -91,10 +94,11 @@ snapshot[`e2e isSnapshotMatch 3`] = `
<body>
<main data-color-mode="light" data-light-theme="light" data-dark-theme="dark" class="markdown-body">
<section>
<h2><a href="/test_zettel_2">A second test title</a></h2>
<time datetime="Sat, 22 May 2032 00:00:00 GMT">22.5.2032</time>
<span>Second best test teaser in the industry</span>
\\t\\t </section><h2 id="test-headline-2"><a class="anchor" aria-hidden="true" tabindex="-1" href="#test-headline-2"><svg class="octicon octicon-link" viewbox="0 0 16 16" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Test Headline 2</h2><p>An unordered test list</p>
<h2><a href="/test_zettel_2">A second test title</a></h2>
<time datetime="Mon, 24 Dec 2001 00:00:00 GMT">24.12.2001</time>
<span>Second best test teaser in the industry</span>
<span> - </span><time datetime="Mon, 24 Dec 2001 00:00:00 GMT">2001/11/1</time>
\\t</section><h2 id="test-headline-2"><a class="anchor" aria-hidden="true" tabindex="-1" href="#test-headline-2"><svg class="octicon octicon-link" viewbox="0 0 16 16" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Test Headline 2</h2><p>An unordered test list</p>
<ul>
<li>Test list item 1</li>
<li>Test list item 2</li>
Expand Down
1 change: 1 addition & 0 deletions deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export {
test,
} from "https://deno.land/[email protected]/front_matter/yaml.ts";
export * as log from "https://deno.land/[email protected]/log/mod.ts";
export { calculate } from "https://deno.land/[email protected]/http/etag.ts";
2 changes: 1 addition & 1 deletion example/deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"tasks": {
"dev": "deno run --allow-env --allow-net --allow-read --watch server.ts",
"format": "deno fmt ../luhmann.ts ../luhmann_test.ts",
"format": "deno fmt ../mod.ts ../luhmann_test.ts",
"file_server": "deno run --allow-read --allow-net https://deno.land/[email protected]/http/file_server.ts static",
"update_snapshots": "deno test --allow-all ../luhmann_test.ts -- --update",
"update_snapshots_e2e": "deno test --allow-all ../luhmann_test_e2e.ts -- --update",
Expand Down
Loading

0 comments on commit c8b8595

Please sign in to comment.