Skip to content

Commit 1f0813c

Browse files
committed
Address PR comments
1 parent 3ee176f commit 1f0813c

File tree

3 files changed

+45
-45
lines changed

3 files changed

+45
-45
lines changed

docs/getting-started/README.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,35 @@ Follow the steps in this documentation to discover how Harper can simplify your
77
For more advanced concepts in Harper, see our [blog](https://www.harpersystems.dev/blog).
88

99
## Harper Basics
10-
<table data-column-title-hidden data-view="cards"><thead><tr><th></th><th></th><th data-hidden></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><a href="getting-started/install-harper.md"><strong>Install Harper</strong></a></td><td>Pick the installation method that best suits your environment</td><td></td><td><a href="getting-started/install-harper.md">install-harper</a></td></tr><tr><td><a href="getting-started/what-is-harper.md"><strong>What is Harper</strong></a></td><td>Learn about Harper, how it works, and some of its usecases</td><td></td><td><a href="getting-started/what-is-harper.md">what-is-harper</a></td></tr><tr><td><a href="getting-started/harper-concepts.md"><strong>Harper Concepts</strong></a></td><td>Learn about Harper's fundamental concepts and how they interact</td><td></td><td><a href="getting-started/harper-concepts.md">harper-concepts</a></td></tr></tbody></table>
10+
<table data-column-title-hidden data-view="cards">
11+
<thead>
12+
<tr>
13+
<th></th>
14+
<th></th>
15+
<th data-hidden></th>
16+
<th data-hidden data-card-target data-type="content-ref"></th>
17+
</tr>
18+
</thead>
19+
<tbody>
20+
<tr>
21+
<td>
22+
<a href="getting-started/install-harper.md"><strong>Install Harper</strong></a>
23+
</td>
24+
<td>Pick the installation method that best suits your environment</td>
25+
<td></td>
26+
<td><a href="getting-started/install-harper.md">install-harper</a></td>
27+
</tr>
28+
<tr>
29+
<td><a href="getting-started/what-is-harper.md"><strong>What is Harper</strong></a></td>
30+
<td>Learn about Harper, how it works, and some of its usecases</td>
31+
<td></td>
32+
<td><a href="getting-started/what-is-harper.md">what-is-harper</a></td>
33+
</tr>
34+
<tr>
35+
<td><a href="getting-started/harper-concepts.md"><strong>Harper Concepts</strong></a></td>
36+
<td>Learn about Harper's fundamental concepts and how they interact</td>
37+
<td></td>
38+
<td><a href="getting-started/harper-concepts.md">harper-concepts</a></td>
39+
</tr>
40+
</tbody>
41+
</table>

docs/getting-started/first-harper-app.md

Lines changed: 12 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -30,39 +30,28 @@ The schema above does several important things:
3030
- Requires `title` and `author` fields (marked with `!`)
3131
- Adds optional `publishedYear` and `genre` fields
3232

33-
When you start your application, Harper will automatically create this table structure.
33+
When you start your application, Harper will automatically create this table resource.
3434

3535
## Extend the Resource Class
3636
Now let's create the business logic for our Book API by implementing a custom resource class. Update your `resources.js` file:
3737

3838
```js
3939
export class Books extends Resource {
4040
// Get a book by ID or list all books
41-
async get() {
41+
get() {
4242
const id = this.getId();
4343

4444
if (id) {
4545
// Return a single book
46-
return await this.table.get(id);
46+
return this.table.get(id);
4747
} else {
48-
// Return all books with optional genre filter
49-
const genre = this.getQueryParam("genre");
50-
const searchOptions = genre ? { genre } : {};
51-
return await this.table.search(searchOptions);
48+
// Return all books
49+
return this.table.get();
5250
}
5351
}
5452

5553
// Create a new book
56-
async post(data) {
57-
// Parse string data if needed
58-
if (typeof data === "string") {
59-
try {
60-
data = JSON.parse(data);
61-
} catch (err) {
62-
return { error: "Invalid JSON" };
63-
}
64-
}
65-
54+
post(data) {
6655
// Validate required fields
6756
if (!data.title || !data.author) {
6857
return { error: "Title and author are required" };
@@ -72,8 +61,7 @@ export class Books extends Resource {
7261
if (data.id) delete data.id;
7362

7463
try {
75-
const result = await this.table.post(data);
76-
return result;
64+
return this.table.post(data);
7765
} catch (error) {
7866
return { error: "Error creating book", details: error.message };
7967
}
@@ -91,17 +79,13 @@ This line creates a custom `Books` class that extends Harper's built-in `Resourc
9179
9280
### GET Method
9381
```js
94-
async get() {
82+
get() {
9583
const id = this.getId();
9684

9785
if (id) {
98-
// Return a single book
99-
return await this.table.get(id);
86+
return this.table.get(id);
10087
} else {
101-
// Return all books with optional genre filter
102-
const genre = this.getQueryParam("genre");
103-
const searchOptions = genre ? { genre } : {};
104-
return await this.table.search(searchOptions);
88+
return this.table.get();
10589
}
10690
}
10791
```
@@ -115,17 +99,7 @@ The `get()` method handles HTTP GET requests to our Book endpoint. It:
11599
116100
### POST Method
117101
```js
118-
async post(data) {
119-
120-
// Parse string data if needed
121-
if (typeof data === "string") {
122-
try {
123-
data = JSON.parse(data);
124-
} catch (err) {
125-
return { error: "Invalid JSON" };
126-
}
127-
}
128-
102+
post(data) {
129103
// Validate required fields
130104
if (!data.title || !data.author) {
131105
return { error: "Title and author are required" };
@@ -134,12 +108,7 @@ async post(data) {
134108
// Prevent primary key overriding
135109
if (data.id) delete data.id;
136110

137-
try {
138-
const result = await this.table.post(data);
139-
return result;
140-
} catch (error) {
141-
return { error: "Error creating book", details: error.message };
142-
}
111+
return this.table.post(data);
143112
}
144113
```
145114

docs/getting-started/install-harper.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
There are three ways to install a Harper instance: using a package manager like NPM, deploying it as a Docker container, and offline installation. Below is a step-by-step tutorial for each method.
44

55
## Installing via NPM
6-
Before you begin, ensure you have [Node.js](https://nodejs.org/) installed (v22 or newer is recommended). Node.js comes with npm, which will be used to install Harper.
6+
Before you begin, ensure you have [Node.js](https://nodejs.org/) LTS version or newer. Node.js comes with npm, which will be used to install Harper.
77

88
Open your terminal or command prompt and install Harper globally by executing the command below. Installing globally allows the `harperdb` command to be accessible from anywhere on your machine, making it easier to manage multiple projects.
99

0 commit comments

Comments
 (0)