create-harper 0.13.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.svg +3 -3
- package/lib/constants/renameFiles.js +4 -3
- package/package.json +1 -1
- package/template-react/AGENTS.md +8 -7
- package/template-react/README.md +53 -6
- package/template-react/_nvmrc +1 -0
- package/template-react/skills/deploying-to-harper-fabric.md +20 -0
- package/template-react-ts/AGENTS.md +8 -7
- package/template-react-ts/README.md +63 -6
- package/template-react-ts/_nvmrc +1 -0
- package/template-react-ts/skills/deploying-to-harper-fabric.md +20 -0
- package/template-vanilla/AGENTS.md +8 -7
- package/template-vanilla/README.md +53 -6
- package/template-vanilla/_github/workflow/deploy.yaml +33 -0
- package/template-vanilla/_nvmrc +1 -0
- package/template-vanilla/package.json +3 -1
- package/template-vanilla/skills/deploying-to-harper-fabric.md +20 -0
- package/template-vanilla-ts/AGENTS.md +8 -7
- package/template-vanilla-ts/README.md +63 -6
- package/template-vanilla-ts/_github/workflow/deploy.yaml +33 -0
- package/template-vanilla-ts/_nvmrc +1 -0
- package/template-vanilla-ts/package.json +3 -1
- package/template-vanilla-ts/skills/deploying-to-harper-fabric.md +20 -0
package/README.svg
CHANGED
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
class="sans"
|
|
117
117
|
x="0"
|
|
118
118
|
y="62"
|
|
119
|
-
font-size="
|
|
119
|
+
font-size="128"
|
|
120
120
|
font-weight="800"
|
|
121
121
|
letter-spacing="-1.5"
|
|
122
122
|
fill="url(#harperGrad)"
|
|
@@ -145,10 +145,10 @@
|
|
|
145
145
|
font-size="22"
|
|
146
146
|
fill="#e6f7ff"
|
|
147
147
|
opacity="0.96"
|
|
148
|
-
>$ npm create harper</text>
|
|
148
|
+
>$ npm create harper@latest</text>
|
|
149
149
|
|
|
150
150
|
<!-- blinking cursor -->
|
|
151
|
-
<rect x="
|
|
151
|
+
<rect x="440" y="16" width="12" height="24" fill="#e6f7ff" opacity="0.55">
|
|
152
152
|
<animate
|
|
153
153
|
attributeName="opacity"
|
|
154
154
|
values="0.1;0.8;0.1"
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
* @type {Record<string, string>}
|
|
4
4
|
*/
|
|
5
5
|
export const renameFiles = {
|
|
6
|
+
'_env': '.env',
|
|
7
|
+
'_env.example': '.env.example',
|
|
6
8
|
_aiignore: '.aiignore',
|
|
7
|
-
_gitignore: '.gitignore',
|
|
8
9
|
_github: '.github',
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
_gitignore: '.gitignore',
|
|
11
|
+
_nvmrc: '.nvmrc',
|
|
11
12
|
};
|
package/package.json
CHANGED
package/template-react/AGENTS.md
CHANGED
|
@@ -6,16 +6,17 @@ This repository contains "skills" that guide AI agents in developing Harper appl
|
|
|
6
6
|
|
|
7
7
|
- [Adding Tables with Schemas](skills/adding-tables-with-schemas.md): Learn how to define schemas and enable automatic REST APIs for your database tables with schema .graphql files in Harper.
|
|
8
8
|
- [Automatic APIs](skills/automatic-apis.md): Details on the CRUD endpoints automatically generated for exported tables with REST and WebSockets.
|
|
9
|
-
- [
|
|
10
|
-
- [
|
|
9
|
+
- [Caching](skills/caching.md): How caching is defined and implemented in Harper applications.
|
|
10
|
+
- [Checking Authentication](skills/checking-authentication.md): How to use sessions to verify user identity and roles.
|
|
11
11
|
- [Custom Resources](skills/custom-resources.md): How to define custom REST endpoints using JavaScript or TypeScript (Note: Paths are case-sensitive).
|
|
12
|
-
- [Extending Table Resources](skills/extending-tables.md): Adding custom logic to automatically generated table resources.
|
|
13
12
|
- [Defining Relationships](skills/defining-relationships.md): Using the `@relationship` directive to link tables.
|
|
14
|
-
- [
|
|
15
|
-
- [
|
|
13
|
+
- [Deploying to Harper Fabric](skills/deploying-to-harper-fabric.md): Globally scaling your Harper application with our generous Free tier and beyond.
|
|
14
|
+
- [Extending Table Resources](skills/extending-tables.md): Adding custom logic to automatically generated table resources.
|
|
16
15
|
- [Handling Binary Data](skills/handling-binary-data.md): How to store and serve binary data like images or MP3s.
|
|
16
|
+
- [Programmatic Table Requests](skills/programmatic-table-requests.md): How to use filters, operators, sorting, and pagination in programmatic table requests.
|
|
17
|
+
- [Querying REST APIs](skills/querying-rest-apis.md): How to use filters, operators, sorting, and pagination in REST requests.
|
|
18
|
+
- [Real-time Applications](skills/real-time-apps.md): Implementing WebSockets and Pub/Sub for live data updates.
|
|
17
19
|
- [Serving Web Content](skills/serving-web-content): Two ways to serve web content from a Harper application.
|
|
18
|
-
- [
|
|
19
|
-
- [Caching](skills/caching.md): How caching is defined and implemented in Harper applications.
|
|
20
|
+
- [TypeScript Type Stripping](skills/typescript-type-stripping.md): Using TypeScript directly without build tools via Node.js Type Stripping.
|
|
20
21
|
- [Using Blobs](skills/using-blob-datatype.md): How to store and retrieve large data in HarperDB.
|
|
21
22
|
- [Vector Indexing](skills/vector-indexing.md): How to define and use vector indexes for efficient similarity search.
|
package/template-react/README.md
CHANGED
|
@@ -22,15 +22,62 @@ npm run dev
|
|
|
22
22
|
|
|
23
23
|
### Define Your Schema
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
1. Create a new yourTableName.graphql file in the [schemas](./schemas) directory.
|
|
26
|
+
2. Craft your schema by hand.
|
|
27
|
+
3. Save your changes.
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
These schemas are the heart of a great Harper app. This is the main starting point for defining your database schema, specifying which tables you want and what attributes/fields they should have. REST endpoints will get stood up for any table that you `@export`.
|
|
29
|
+
These schemas are the heart of a great Harper app, specifying which tables you want and what attributes/fields they should have. Any table you `@export` stands up [REST endpoints automatically](./skills/automatic-rest-apis.md).
|
|
30
30
|
|
|
31
31
|
### Add Custom Endpoints
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
1. Create a new greeting.js file in the [resources](./resources) directory.
|
|
34
|
+
|
|
35
|
+
2. Customize your resource:
|
|
36
|
+
|
|
37
|
+
```javascript
|
|
38
|
+
export class Greeting extends Resource {
|
|
39
|
+
static loadAsInstance = false;
|
|
40
|
+
|
|
41
|
+
async post(
|
|
42
|
+
target,
|
|
43
|
+
newRecord,
|
|
44
|
+
) {
|
|
45
|
+
// By default, only super users can access these endpoints.
|
|
46
|
+
return { greeting: 'Greetings, post!' };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async get(target) {
|
|
50
|
+
// But if we want anyone to be able to access it, we can turn off the permission checks!
|
|
51
|
+
target.checkPermission = false;
|
|
52
|
+
return { greeting: 'Greetings, get! ' + process.version };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async put(
|
|
56
|
+
target,
|
|
57
|
+
record,
|
|
58
|
+
) {
|
|
59
|
+
target.checkPermission = false;
|
|
60
|
+
if (this.getCurrentUser()?.name?.includes('Coffee')) {
|
|
61
|
+
// You can add your own authorization guards, of course.
|
|
62
|
+
return new Response('Coffee? COFFEE?!', { status: 418 });
|
|
63
|
+
}
|
|
64
|
+
return { greeting: 'Sssssssssssssss!' };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async patch(
|
|
68
|
+
target,
|
|
69
|
+
record,
|
|
70
|
+
) {
|
|
71
|
+
return { greeting: 'We can make this work!' };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async delete(target) {
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
3. Save your changes.
|
|
34
81
|
|
|
35
82
|
### View Your Website
|
|
36
83
|
|
|
@@ -58,7 +105,7 @@ Take a look at the [default configuration](./config.yaml), which specifies how f
|
|
|
58
105
|
|
|
59
106
|
When you are ready, head to [https://fabric.harper.fast/](https://fabric.harper.fast/), log in to your account, and create a cluster.
|
|
60
107
|
|
|
61
|
-
|
|
108
|
+
Come back here and configure your [.env](./.env) file with your secure cluster credentials. Don't commit this file to source control!
|
|
62
109
|
|
|
63
110
|
Then you can deploy your app to your cluster:
|
|
64
111
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
24.13.1
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Deploying to Harper Fabric
|
|
2
|
+
|
|
3
|
+
To deploy your application to Harper Fabric, follow these steps:
|
|
4
|
+
|
|
5
|
+
1. **Sign up**: Create an account at [https://fabric.harper.fast](https://fabric.harper.fast) and create a cluster.
|
|
6
|
+
|
|
7
|
+
2. **Configure Environment**: Add your credentials and cluster URL to your `.env` file:
|
|
8
|
+
```bash
|
|
9
|
+
# Deployments
|
|
10
|
+
CLI_TARGET_USERNAME='YOUR_CLUSTER_USERNAME'
|
|
11
|
+
CLI_TARGET_PASSWORD='YOUR_CLUSTER_PASSWORD'
|
|
12
|
+
CLI_TARGET='YOUR_FABRIC.HARPER.FAST_CLUSTER_URL_HERE'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
3. **Deploy Locally**: Run the following command to deploy from your local environment:
|
|
16
|
+
```bash
|
|
17
|
+
npm run deploy
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
4. **Set up CI/CD**: Customize the included `.github/workflow/deploy.yaml` file and define your secrets in your GitHub repository's action settings to enable continuous deployment.
|
|
@@ -6,16 +6,17 @@ This repository contains "skills" that guide AI agents in developing Harper appl
|
|
|
6
6
|
|
|
7
7
|
- [Adding Tables with Schemas](skills/adding-tables-with-schemas.md): Learn how to define schemas and enable automatic REST APIs for your database tables with schema .graphql files in Harper.
|
|
8
8
|
- [Automatic APIs](skills/automatic-apis.md): Details on the CRUD endpoints automatically generated for exported tables with REST and WebSockets.
|
|
9
|
-
- [
|
|
10
|
-
- [
|
|
9
|
+
- [Caching](skills/caching.md): How caching is defined and implemented in Harper applications.
|
|
10
|
+
- [Checking Authentication](skills/checking-authentication.md): How to use sessions to verify user identity and roles.
|
|
11
11
|
- [Custom Resources](skills/custom-resources.md): How to define custom REST endpoints using JavaScript or TypeScript (Note: Paths are case-sensitive).
|
|
12
|
-
- [Extending Table Resources](skills/extending-tables.md): Adding custom logic to automatically generated table resources.
|
|
13
12
|
- [Defining Relationships](skills/defining-relationships.md): Using the `@relationship` directive to link tables.
|
|
14
|
-
- [
|
|
15
|
-
- [
|
|
13
|
+
- [Deploying to Harper Fabric](skills/deploying-to-harper-fabric.md): Globally scaling your Harper application with our generous Free tier and beyond.
|
|
14
|
+
- [Extending Table Resources](skills/extending-tables.md): Adding custom logic to automatically generated table resources.
|
|
16
15
|
- [Handling Binary Data](skills/handling-binary-data.md): How to store and serve binary data like images or MP3s.
|
|
16
|
+
- [Programmatic Table Requests](skills/programmatic-table-requests.md): How to use filters, operators, sorting, and pagination in programmatic table requests.
|
|
17
|
+
- [Querying REST APIs](skills/querying-rest-apis.md): How to use filters, operators, sorting, and pagination in REST requests.
|
|
18
|
+
- [Real-time Applications](skills/real-time-apps.md): Implementing WebSockets and Pub/Sub for live data updates.
|
|
17
19
|
- [Serving Web Content](skills/serving-web-content): Two ways to serve web content from a Harper application.
|
|
18
|
-
- [
|
|
19
|
-
- [Caching](skills/caching.md): How caching is defined and implemented in Harper applications.
|
|
20
|
+
- [TypeScript Type Stripping](skills/typescript-type-stripping.md): Using TypeScript directly without build tools via Node.js Type Stripping.
|
|
20
21
|
- [Using Blobs](skills/using-blob-datatype.md): How to store and retrieve large data in HarperDB.
|
|
21
22
|
- [Vector Indexing](skills/vector-indexing.md): How to define and use vector indexes for efficient similarity search.
|
|
@@ -24,15 +24,72 @@ TypeScript is supported at runtime in Node.js through [type stripping](https://n
|
|
|
24
24
|
|
|
25
25
|
### Define Your Schema
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
1. Create a new yourTableName.graphql file in the [schemas](./schemas) directory.
|
|
28
|
+
2. Craft your schema by hand.
|
|
29
|
+
3. Save your changes.
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
These schemas are the heart of a great Harper app. This is the main starting point for defining your database schema, specifying which tables you want and what attributes/fields they should have. REST endpoints will get stood up for any table that you `@export`.
|
|
31
|
+
These schemas are the heart of a great Harper app, specifying which tables you want and what attributes/fields they should have. Any table you `@export` stands up [REST endpoints automatically](./skills/automatic-rest-apis.md).
|
|
32
32
|
|
|
33
33
|
### Add Custom Endpoints
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
1. Create a new greeting.ts file in the [resources](./resources) directory.
|
|
36
|
+
|
|
37
|
+
2. Customize your resource:
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import {
|
|
41
|
+
type RecordObject,
|
|
42
|
+
type RequestTargetOrId,
|
|
43
|
+
Resource,
|
|
44
|
+
} from 'harperdb';
|
|
45
|
+
|
|
46
|
+
interface GreetingRecord {
|
|
47
|
+
greeting: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export class Greeting extends Resource<GreetingRecord> {
|
|
51
|
+
static loadAsInstance = false;
|
|
52
|
+
|
|
53
|
+
async post(
|
|
54
|
+
target: RequestTargetOrId,
|
|
55
|
+
newRecord: Partial<GreetingRecord & RecordObject>,
|
|
56
|
+
): Promise<GreetingRecord> {
|
|
57
|
+
// By default, only super users can access these endpoints.
|
|
58
|
+
return { greeting: 'Greetings, post!' };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async get(target?: RequestTargetOrId): Promise<GreetingRecord> {
|
|
62
|
+
// But if we want anyone to be able to access it, we can turn off the permission checks!
|
|
63
|
+
target.checkPermission = false;
|
|
64
|
+
return { greeting: 'Greetings, get! ' + process.version };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async put(
|
|
68
|
+
target: RequestTargetOrId,
|
|
69
|
+
record: GreetingRecord & RecordObject,
|
|
70
|
+
): Promise<GreetingRecord> {
|
|
71
|
+
target.checkPermission = false;
|
|
72
|
+
if (this.getCurrentUser()?.name?.includes('Coffee')) {
|
|
73
|
+
// You can add your own authorization guards, of course.
|
|
74
|
+
return new Response('Coffee? COFFEE?!', { status: 418 });
|
|
75
|
+
}
|
|
76
|
+
return { greeting: 'Sssssssssssssss!' };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async patch(
|
|
80
|
+
target: RequestTargetOrId,
|
|
81
|
+
record: Partial<GreetingRecord & RecordObject>,
|
|
82
|
+
): Promise<GreetingRecord> {
|
|
83
|
+
return { greeting: 'We can make this work!' };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async delete(target: RequestTargetOrId): Promise<boolean> {
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
3. Save your changes.
|
|
36
93
|
|
|
37
94
|
### View Your Website
|
|
38
95
|
|
|
@@ -60,7 +117,7 @@ Take a look at the [default configuration](./config.yaml), which specifies how f
|
|
|
60
117
|
|
|
61
118
|
When you are ready, head to [https://fabric.harper.fast/](https://fabric.harper.fast/), log in to your account, and create a cluster.
|
|
62
119
|
|
|
63
|
-
|
|
120
|
+
Come back here and configure your [.env](./.env) file with your secure cluster credentials. Don't commit this file to source control!
|
|
64
121
|
|
|
65
122
|
Then you can deploy your app to your cluster:
|
|
66
123
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
24.13.1
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Deploying to Harper Fabric
|
|
2
|
+
|
|
3
|
+
To deploy your application to Harper Fabric, follow these steps:
|
|
4
|
+
|
|
5
|
+
1. **Sign up**: Create an account at [https://fabric.harper.fast](https://fabric.harper.fast) and create a cluster.
|
|
6
|
+
|
|
7
|
+
2. **Configure Environment**: Add your credentials and cluster URL to your `.env` file:
|
|
8
|
+
```bash
|
|
9
|
+
# Deployments
|
|
10
|
+
CLI_TARGET_USERNAME='YOUR_CLUSTER_USERNAME'
|
|
11
|
+
CLI_TARGET_PASSWORD='YOUR_CLUSTER_PASSWORD'
|
|
12
|
+
CLI_TARGET='YOUR_FABRIC.HARPER.FAST_CLUSTER_URL_HERE'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
3. **Deploy Locally**: Run the following command to deploy from your local environment:
|
|
16
|
+
```bash
|
|
17
|
+
npm run deploy
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
4. **Set up CI/CD**: Customize the included `.github/workflow/deploy.yaml` file and define your secrets in your GitHub repository's action settings to enable continuous deployment.
|
|
@@ -6,16 +6,17 @@ This repository contains "skills" that guide AI agents in developing Harper appl
|
|
|
6
6
|
|
|
7
7
|
- [Adding Tables with Schemas](skills/adding-tables-with-schemas.md): Learn how to define schemas and enable automatic REST APIs for your database tables with schema .graphql files in Harper.
|
|
8
8
|
- [Automatic APIs](skills/automatic-apis.md): Details on the CRUD endpoints automatically generated for exported tables with REST and WebSockets.
|
|
9
|
-
- [
|
|
10
|
-
- [
|
|
9
|
+
- [Caching](skills/caching.md): How caching is defined and implemented in Harper applications.
|
|
10
|
+
- [Checking Authentication](skills/checking-authentication.md): How to use sessions to verify user identity and roles.
|
|
11
11
|
- [Custom Resources](skills/custom-resources.md): How to define custom REST endpoints using JavaScript or TypeScript (Note: Paths are case-sensitive).
|
|
12
|
-
- [Extending Table Resources](skills/extending-tables.md): Adding custom logic to automatically generated table resources.
|
|
13
12
|
- [Defining Relationships](skills/defining-relationships.md): Using the `@relationship` directive to link tables.
|
|
14
|
-
- [
|
|
15
|
-
- [
|
|
13
|
+
- [Deploying to Harper Fabric](skills/deploying-to-harper-fabric.md): Globally scaling your Harper application with our generous Free tier and beyond.
|
|
14
|
+
- [Extending Table Resources](skills/extending-tables.md): Adding custom logic to automatically generated table resources.
|
|
16
15
|
- [Handling Binary Data](skills/handling-binary-data.md): How to store and serve binary data like images or MP3s.
|
|
16
|
+
- [Programmatic Table Requests](skills/programmatic-table-requests.md): How to use filters, operators, sorting, and pagination in programmatic table requests.
|
|
17
|
+
- [Querying REST APIs](skills/querying-rest-apis.md): How to use filters, operators, sorting, and pagination in REST requests.
|
|
18
|
+
- [Real-time Applications](skills/real-time-apps.md): Implementing WebSockets and Pub/Sub for live data updates.
|
|
17
19
|
- [Serving Web Content](skills/serving-web-content): Two ways to serve web content from a Harper application.
|
|
18
|
-
- [
|
|
19
|
-
- [Caching](skills/caching.md): How caching is defined and implemented in Harper applications.
|
|
20
|
+
- [TypeScript Type Stripping](skills/typescript-type-stripping.md): Using TypeScript directly without build tools via Node.js Type Stripping.
|
|
20
21
|
- [Using Blobs](skills/using-blob-datatype.md): How to store and retrieve large data in HarperDB.
|
|
21
22
|
- [Vector Indexing](skills/vector-indexing.md): How to define and use vector indexes for efficient similarity search.
|
|
@@ -22,15 +22,62 @@ npm run dev
|
|
|
22
22
|
|
|
23
23
|
### Define Your Schema
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
1. Create a new yourTableName.graphql file in the [schemas](./schemas) directory.
|
|
26
|
+
2. Craft your schema by hand.
|
|
27
|
+
3. Save your changes.
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
These schemas are the heart of a great Harper app. This is the main starting point for defining your database schema, specifying which tables you want and what attributes/fields they should have. REST endpoints will get stood up for any table that you `@export`.
|
|
29
|
+
These schemas are the heart of a great Harper app, specifying which tables you want and what attributes/fields they should have. Any table you `@export` stands up [REST endpoints automatically](./skills/automatic-rest-apis.md).
|
|
30
30
|
|
|
31
31
|
### Add Custom Endpoints
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
1. Create a new greeting.js file in the [resources](./resources) directory.
|
|
34
|
+
|
|
35
|
+
2. Customize your resource:
|
|
36
|
+
|
|
37
|
+
```javascript
|
|
38
|
+
export class Greeting extends Resource {
|
|
39
|
+
static loadAsInstance = false;
|
|
40
|
+
|
|
41
|
+
async post(
|
|
42
|
+
target,
|
|
43
|
+
newRecord,
|
|
44
|
+
) {
|
|
45
|
+
// By default, only super users can access these endpoints.
|
|
46
|
+
return { greeting: 'Greetings, post!' };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async get(target) {
|
|
50
|
+
// But if we want anyone to be able to access it, we can turn off the permission checks!
|
|
51
|
+
target.checkPermission = false;
|
|
52
|
+
return { greeting: 'Greetings, get! ' + process.version };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async put(
|
|
56
|
+
target,
|
|
57
|
+
record,
|
|
58
|
+
) {
|
|
59
|
+
target.checkPermission = false;
|
|
60
|
+
if (this.getCurrentUser()?.name?.includes('Coffee')) {
|
|
61
|
+
// You can add your own authorization guards, of course.
|
|
62
|
+
return new Response('Coffee? COFFEE?!', { status: 418 });
|
|
63
|
+
}
|
|
64
|
+
return { greeting: 'Sssssssssssssss!' };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async patch(
|
|
68
|
+
target,
|
|
69
|
+
record,
|
|
70
|
+
) {
|
|
71
|
+
return { greeting: 'We can make this work!' };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async delete(target) {
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
3. Save your changes.
|
|
34
81
|
|
|
35
82
|
### View Your Website
|
|
36
83
|
|
|
@@ -58,7 +105,7 @@ Take a look at the [default configuration](./config.yaml), which specifies how f
|
|
|
58
105
|
|
|
59
106
|
When you are ready, head to [https://fabric.harper.fast/](https://fabric.harper.fast/), log in to your account, and create a cluster.
|
|
60
107
|
|
|
61
|
-
|
|
108
|
+
Come back here and configure your [.env](./.env) file with your secure cluster credentials. Don't commit this file to source control!
|
|
62
109
|
|
|
63
110
|
Then you can deploy your app to your cluster:
|
|
64
111
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
name: Deploy to Harper Fabric
|
|
2
|
+
on:
|
|
3
|
+
workflow_dispatch:
|
|
4
|
+
# push:
|
|
5
|
+
# branches:
|
|
6
|
+
# - main
|
|
7
|
+
|
|
8
|
+
concurrency:
|
|
9
|
+
group: main
|
|
10
|
+
cancel-in-progress: false
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
deploy:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- name: Checkout code
|
|
17
|
+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
|
18
|
+
with:
|
|
19
|
+
fetch-depth: 0
|
|
20
|
+
fetch-tags: true
|
|
21
|
+
- name: Set up Node.js
|
|
22
|
+
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
|
|
23
|
+
with:
|
|
24
|
+
cache: 'npm'
|
|
25
|
+
node-version-file: '.nvmrc'
|
|
26
|
+
- name: Install dependencies
|
|
27
|
+
run: npm ci
|
|
28
|
+
- name: Run unit tests
|
|
29
|
+
run: npm test
|
|
30
|
+
- name: Run lint
|
|
31
|
+
run: npm run lint
|
|
32
|
+
- name: Deploy
|
|
33
|
+
run: npm run deploy
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
24.13.1
|
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
"start": "harperdb run .",
|
|
8
8
|
"dev": "harperdb dev .",
|
|
9
9
|
"deploy": "dotenv -- npm run deploy:component",
|
|
10
|
-
"deploy:component": "harperdb deploy_component . restart=rolling replicated=true"
|
|
10
|
+
"deploy:component": "harperdb deploy_component . restart=rolling replicated=true",
|
|
11
|
+
"test": "echo 'No tests implemented yet'",
|
|
12
|
+
"lint": "echo 'No lint implemented yet'"
|
|
11
13
|
},
|
|
12
14
|
"devDependencies": {
|
|
13
15
|
"dotenv-cli": "^11.0.0",
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Deploying to Harper Fabric
|
|
2
|
+
|
|
3
|
+
To deploy your application to Harper Fabric, follow these steps:
|
|
4
|
+
|
|
5
|
+
1. **Sign up**: Create an account at [https://fabric.harper.fast](https://fabric.harper.fast) and create a cluster.
|
|
6
|
+
|
|
7
|
+
2. **Configure Environment**: Add your credentials and cluster URL to your `.env` file:
|
|
8
|
+
```bash
|
|
9
|
+
# Deployments
|
|
10
|
+
CLI_TARGET_USERNAME='YOUR_CLUSTER_USERNAME'
|
|
11
|
+
CLI_TARGET_PASSWORD='YOUR_CLUSTER_PASSWORD'
|
|
12
|
+
CLI_TARGET='YOUR_FABRIC.HARPER.FAST_CLUSTER_URL_HERE'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
3. **Deploy Locally**: Run the following command to deploy from your local environment:
|
|
16
|
+
```bash
|
|
17
|
+
npm run deploy
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
4. **Set up CI/CD**: Customize the included `.github/workflow/deploy.yaml` file and define your secrets in your GitHub repository's action settings to enable continuous deployment.
|
|
@@ -6,16 +6,17 @@ This repository contains "skills" that guide AI agents in developing Harper appl
|
|
|
6
6
|
|
|
7
7
|
- [Adding Tables with Schemas](skills/adding-tables-with-schemas.md): Learn how to define schemas and enable automatic REST APIs for your database tables with schema .graphql files in Harper.
|
|
8
8
|
- [Automatic APIs](skills/automatic-apis.md): Details on the CRUD endpoints automatically generated for exported tables with REST and WebSockets.
|
|
9
|
-
- [
|
|
10
|
-
- [
|
|
9
|
+
- [Caching](skills/caching.md): How caching is defined and implemented in Harper applications.
|
|
10
|
+
- [Checking Authentication](skills/checking-authentication.md): How to use sessions to verify user identity and roles.
|
|
11
11
|
- [Custom Resources](skills/custom-resources.md): How to define custom REST endpoints using JavaScript or TypeScript (Note: Paths are case-sensitive).
|
|
12
|
-
- [Extending Table Resources](skills/extending-tables.md): Adding custom logic to automatically generated table resources.
|
|
13
12
|
- [Defining Relationships](skills/defining-relationships.md): Using the `@relationship` directive to link tables.
|
|
14
|
-
- [
|
|
15
|
-
- [
|
|
13
|
+
- [Deploying to Harper Fabric](skills/deploying-to-harper-fabric.md): Globally scaling your Harper application with our generous Free tier and beyond.
|
|
14
|
+
- [Extending Table Resources](skills/extending-tables.md): Adding custom logic to automatically generated table resources.
|
|
16
15
|
- [Handling Binary Data](skills/handling-binary-data.md): How to store and serve binary data like images or MP3s.
|
|
16
|
+
- [Programmatic Table Requests](skills/programmatic-table-requests.md): How to use filters, operators, sorting, and pagination in programmatic table requests.
|
|
17
|
+
- [Querying REST APIs](skills/querying-rest-apis.md): How to use filters, operators, sorting, and pagination in REST requests.
|
|
18
|
+
- [Real-time Applications](skills/real-time-apps.md): Implementing WebSockets and Pub/Sub for live data updates.
|
|
17
19
|
- [Serving Web Content](skills/serving-web-content): Two ways to serve web content from a Harper application.
|
|
18
|
-
- [
|
|
19
|
-
- [Caching](skills/caching.md): How caching is defined and implemented in Harper applications.
|
|
20
|
+
- [TypeScript Type Stripping](skills/typescript-type-stripping.md): Using TypeScript directly without build tools via Node.js Type Stripping.
|
|
20
21
|
- [Using Blobs](skills/using-blob-datatype.md): How to store and retrieve large data in HarperDB.
|
|
21
22
|
- [Vector Indexing](skills/vector-indexing.md): How to define and use vector indexes for efficient similarity search.
|
|
@@ -24,15 +24,72 @@ TypeScript is supported at runtime in Node.js through [type stripping](https://n
|
|
|
24
24
|
|
|
25
25
|
### Define Your Schema
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
1. Create a new yourTableName.graphql file in the [schemas](./schemas) directory.
|
|
28
|
+
2. Craft your schema by hand.
|
|
29
|
+
3. Save your changes.
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
These schemas are the heart of a great Harper app. This is the main starting point for defining your database schema, specifying which tables you want and what attributes/fields they should have. REST endpoints will get stood up for any table that you `@export`.
|
|
31
|
+
These schemas are the heart of a great Harper app, specifying which tables you want and what attributes/fields they should have. Any table you `@export` stands up [REST endpoints automatically](./skills/automatic-rest-apis.md).
|
|
32
32
|
|
|
33
33
|
### Add Custom Endpoints
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
1. Create a new greeting.ts file in the [resources](./resources) directory.
|
|
36
|
+
|
|
37
|
+
2. Customize your resource:
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import {
|
|
41
|
+
type RecordObject,
|
|
42
|
+
type RequestTargetOrId,
|
|
43
|
+
Resource,
|
|
44
|
+
} from 'harperdb';
|
|
45
|
+
|
|
46
|
+
interface GreetingRecord {
|
|
47
|
+
greeting: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export class Greeting extends Resource<GreetingRecord> {
|
|
51
|
+
static loadAsInstance = false;
|
|
52
|
+
|
|
53
|
+
async post(
|
|
54
|
+
target: RequestTargetOrId,
|
|
55
|
+
newRecord: Partial<GreetingRecord & RecordObject>,
|
|
56
|
+
): Promise<GreetingRecord> {
|
|
57
|
+
// By default, only super users can access these endpoints.
|
|
58
|
+
return { greeting: 'Greetings, post!' };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async get(target?: RequestTargetOrId): Promise<GreetingRecord> {
|
|
62
|
+
// But if we want anyone to be able to access it, we can turn off the permission checks!
|
|
63
|
+
target.checkPermission = false;
|
|
64
|
+
return { greeting: 'Greetings, get! ' + process.version };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async put(
|
|
68
|
+
target: RequestTargetOrId,
|
|
69
|
+
record: GreetingRecord & RecordObject,
|
|
70
|
+
): Promise<GreetingRecord> {
|
|
71
|
+
target.checkPermission = false;
|
|
72
|
+
if (this.getCurrentUser()?.name?.includes('Coffee')) {
|
|
73
|
+
// You can add your own authorization guards, of course.
|
|
74
|
+
return new Response('Coffee? COFFEE?!', { status: 418 });
|
|
75
|
+
}
|
|
76
|
+
return { greeting: 'Sssssssssssssss!' };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async patch(
|
|
80
|
+
target: RequestTargetOrId,
|
|
81
|
+
record: Partial<GreetingRecord & RecordObject>,
|
|
82
|
+
): Promise<GreetingRecord> {
|
|
83
|
+
return { greeting: 'We can make this work!' };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async delete(target: RequestTargetOrId): Promise<boolean> {
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
3. Save your changes.
|
|
36
93
|
|
|
37
94
|
### View Your Website
|
|
38
95
|
|
|
@@ -60,7 +117,7 @@ Take a look at the [default configuration](./config.yaml), which specifies how f
|
|
|
60
117
|
|
|
61
118
|
When you are ready, head to [https://fabric.harper.fast/](https://fabric.harper.fast/), log in to your account, and create a cluster.
|
|
62
119
|
|
|
63
|
-
|
|
120
|
+
Come back here and configure your [.env](./.env) file with your secure cluster credentials. Don't commit this file to source control!
|
|
64
121
|
|
|
65
122
|
Then you can deploy your app to your cluster:
|
|
66
123
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
name: Deploy to Harper Fabric
|
|
2
|
+
on:
|
|
3
|
+
workflow_dispatch:
|
|
4
|
+
# push:
|
|
5
|
+
# branches:
|
|
6
|
+
# - main
|
|
7
|
+
|
|
8
|
+
concurrency:
|
|
9
|
+
group: main
|
|
10
|
+
cancel-in-progress: false
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
deploy:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- name: Checkout code
|
|
17
|
+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
|
18
|
+
with:
|
|
19
|
+
fetch-depth: 0
|
|
20
|
+
fetch-tags: true
|
|
21
|
+
- name: Set up Node.js
|
|
22
|
+
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
|
|
23
|
+
with:
|
|
24
|
+
cache: 'npm'
|
|
25
|
+
node-version-file: '.nvmrc'
|
|
26
|
+
- name: Install dependencies
|
|
27
|
+
run: npm ci
|
|
28
|
+
- name: Run unit tests
|
|
29
|
+
run: npm test
|
|
30
|
+
- name: Run lint
|
|
31
|
+
run: npm run lint
|
|
32
|
+
- name: Deploy
|
|
33
|
+
run: npm run deploy
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
24.13.1
|
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
"start": "harperdb run .",
|
|
8
8
|
"dev": "harperdb dev .",
|
|
9
9
|
"deploy": "dotenv -- npm run deploy:component",
|
|
10
|
-
"deploy:component": "harperdb deploy_component . restart=rolling replicated=true"
|
|
10
|
+
"deploy:component": "harperdb deploy_component . restart=rolling replicated=true",
|
|
11
|
+
"test": "echo 'No tests implemented yet'",
|
|
12
|
+
"lint": "echo 'No lint implemented yet'"
|
|
11
13
|
},
|
|
12
14
|
"devDependencies": {
|
|
13
15
|
"dotenv-cli": "^11.0.0",
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Deploying to Harper Fabric
|
|
2
|
+
|
|
3
|
+
To deploy your application to Harper Fabric, follow these steps:
|
|
4
|
+
|
|
5
|
+
1. **Sign up**: Create an account at [https://fabric.harper.fast](https://fabric.harper.fast) and create a cluster.
|
|
6
|
+
|
|
7
|
+
2. **Configure Environment**: Add your credentials and cluster URL to your `.env` file:
|
|
8
|
+
```bash
|
|
9
|
+
# Deployments
|
|
10
|
+
CLI_TARGET_USERNAME='YOUR_CLUSTER_USERNAME'
|
|
11
|
+
CLI_TARGET_PASSWORD='YOUR_CLUSTER_PASSWORD'
|
|
12
|
+
CLI_TARGET='YOUR_FABRIC.HARPER.FAST_CLUSTER_URL_HERE'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
3. **Deploy Locally**: Run the following command to deploy from your local environment:
|
|
16
|
+
```bash
|
|
17
|
+
npm run deploy
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
4. **Set up CI/CD**: Customize the included `.github/workflow/deploy.yaml` file and define your secrets in your GitHub repository's action settings to enable continuous deployment.
|