Skip to content

Commit e98526b

Browse files
committedOct 21, 2024
init commit
0 parents  commit e98526b

13 files changed

+1321
-0
lines changed
 

‎.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
dist

‎README.md

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# HarperDB Vue SSR Example
2+
3+
This repo is an example of how to implement Vue SSR using HarperDB Resources to efficiently generate a _Blog_ from a database of _Posts_.
4+
5+
It includes complete client side hydration as well, resulting in a fully interactive web app experience.
6+
7+
## Get Started
8+
9+
1. `npm i`
10+
2. `npm build`
11+
3. `harperdb run .`
12+
4. Navigate to [/UncachedBlog/0](http://localhost:9926/UncachedBlog/0) or [/CachedBlog/0](http://localhost:9926/CachedBlog/0)
13+
5. Add or remove comments!
14+
15+
The application is fully interactive and leverages a WebHook on the _Post_ to keep the page synced with the database record.
16+
17+
Regardless of caching, the pages are server side rendered. In the caching example, it will only rerender when the _Post_ has been updated.
18+
19+
Otherwise, clients should always receive a 304 status code!
20+
21+
## Help
22+
23+
- The `resources.js` file will generate a Post record automatically on startup, but won't overwrite an existing one.
24+
25+
- If you want to clear the Post record, use the command: `curl -X DELETE http://localhost:9926/Post/0`
26+
27+
- If you want to clear the comments on the Post, use the command:
28+
29+
```sh
30+
curl -X PATCH http://localhost:9926/Post/0 \
31+
-H "Content-Type: application/json" \
32+
-d '{ "comments": [] }'
33+
```

‎config.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
rest:
2+
lastModified: true
3+
graphqlSchema:
4+
files: schema.graphql
5+
jsResource:
6+
files: resources.js
7+
static:
8+
files: 'dist/'

‎index.html

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>HarperDB Vue SSR Example</title>
7+
<!--app-data-->
8+
<!--app-head-->
9+
</head>
10+
<body>
11+
<div id="root"><!--app-html--></div>
12+
<script type="module" src="/src/entry-client.js"></script>
13+
</body>
14+
</html>

0 commit comments

Comments
 (0)
Please sign in to comment.