create-harper 0.0.4 → 0.0.5

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.
Files changed (58) hide show
  1. package/index.js +21 -20
  2. package/lib/constants/defaultEnv.js +3 -0
  3. package/lib/constants/exampleFiles.js +22 -0
  4. package/lib/constants/frameworks.js +1 -13
  5. package/lib/constants/templates.js +2 -2
  6. package/lib/fs/crawlTemplateDir.js +9 -3
  7. package/lib/steps/getEnvVars.js +57 -6
  8. package/lib/steps/getExamples.js +48 -0
  9. package/lib/steps/getTemplate.js +4 -4
  10. package/lib/steps/helpAgents.js +15 -0
  11. package/lib/steps/scaffoldProject.js +3 -2
  12. package/package.json +1 -2
  13. package/template-react/config.yaml +2 -2
  14. package/template-react/resources/exampleSocket.js +34 -0
  15. package/template-react/resources/exampleTable.js +14 -0
  16. package/template-react/resources/greeting.js +10 -0
  17. package/{template-studio/schema.graphql → template-react/schemas/exampleTable.graphql} +1 -1
  18. package/template-react-ts/config.yaml +2 -2
  19. package/template-react-ts/resources/exampleSocket.ts +41 -0
  20. package/template-react-ts/resources/exampleTable.ts +20 -0
  21. package/template-react-ts/{resources.ts → resources/greeting.ts} +0 -23
  22. package/{template-vanilla/schema.graphql → template-react-ts/schemas/exampleTable.graphql} +1 -1
  23. package/template-studio/config.yaml +2 -2
  24. package/template-studio/resources/exampleSocket.js +34 -0
  25. package/template-studio/resources/exampleTable.js +14 -0
  26. package/template-studio/resources/greeting.js +10 -0
  27. package/{template-vanilla-ts/schema.graphql → template-studio/schemas/exampleTable.graphql} +1 -1
  28. package/template-studio-ts/config.yaml +2 -2
  29. package/template-studio-ts/resources/exampleSocket.ts +41 -0
  30. package/template-studio-ts/resources/exampleTable.ts +20 -0
  31. package/{template-vanilla-ts/resources.ts → template-studio-ts/resources/greeting.ts} +0 -23
  32. package/template-studio-ts/{schema.graphql → schemas/exampleTable.graphql} +1 -1
  33. package/template-vanilla/README.md +1 -1
  34. package/template-vanilla/config.yaml +2 -2
  35. package/template-vanilla/resources/exampleSocket.js +34 -0
  36. package/template-vanilla/resources/exampleTable.js +14 -0
  37. package/template-vanilla/resources/greeting.js +10 -0
  38. package/template-vanilla/schemas/exampleTable.graphql +7 -0
  39. package/template-vanilla-ts/README.md +2 -2
  40. package/template-vanilla-ts/config.yaml +2 -2
  41. package/template-vanilla-ts/resources/exampleSocket.ts +41 -0
  42. package/template-vanilla-ts/resources/exampleTable.ts +20 -0
  43. package/{template-studio-ts/resources.ts → template-vanilla-ts/resources/greeting.ts} +0 -23
  44. package/template-vanilla-ts/schemas/exampleTable.graphql +7 -0
  45. package/template-barebones/README.md +0 -7
  46. package/template-barebones/_aiignore +0 -1
  47. package/template-barebones/_env +0 -3
  48. package/template-barebones/_env.example +0 -3
  49. package/template-barebones/_gitignore +0 -147
  50. package/template-barebones/config.yaml +0 -7
  51. package/template-barebones/graphql.config.yml +0 -3
  52. package/template-barebones/package.json +0 -14
  53. package/template-barebones/schema.graphql +0 -1
  54. package/template-react/resources.js +0 -27
  55. package/template-react/schema.graphql +0 -5
  56. package/template-react-ts/schema.graphql +0 -5
  57. package/template-studio/resources.js +0 -27
  58. package/template-vanilla/resources.js +0 -27
@@ -0,0 +1,14 @@
1
+ import { tables } from 'harperdb';
2
+
3
+ export class ExampleTable extends tables.ExampleTable {
4
+ // we can define our own custom POST handler
5
+ post(content) {
6
+ // do something with the incoming content;
7
+ return super.post(content);
8
+ }
9
+ // or custom GET handler
10
+ get() {
11
+ // we can modify this resource before returning
12
+ return super.get();
13
+ }
14
+ }
@@ -0,0 +1,10 @@
1
+ import { Resource } from 'harperdb';
2
+
3
+ export class Greeting extends Resource {
4
+ // a "Hello, world!" handler
5
+ static loadAsInstance = false; // use the updated/newer Resource API
6
+
7
+ get() {
8
+ return { greeting: 'Hello, world!' };
9
+ }
10
+ }
@@ -1,6 +1,6 @@
1
1
  ## Here we can define any tables in our database. This example shows how we define a type as a table using
2
2
  ## the type name as the table name and specifying it is an "export" available in the REST and other external protocols.
3
- type TableName @table @export {
3
+ type ExampleTable @table @export {
4
4
  id: ID @primaryKey # Here we define primary key (must be one)
5
5
  name: String # we can define any other attributes here
6
6
  tag: String @indexed # we can specify any attributes that should be indexed
@@ -13,11 +13,11 @@ rest: true
13
13
 
14
14
  # These reads GraphQL schemas to define the schema of database/tables/attributes.
15
15
  graphqlSchema:
16
- files: 'schema.graphql'
16
+ files: 'schemas/*.graphql'
17
17
 
18
18
  # Loads JavaScript modules such that their exports are exported as resources
19
19
  jsResource:
20
- files: 'resources.ts'
20
+ files: 'resources/*.ts'
21
21
 
22
22
  # Serve the static files from the web directory as a web application
23
23
  static:
@@ -0,0 +1,41 @@
1
+ import { type IterableEventQueue, RequestTarget, Resource, tables, type User } from 'harperdb';
2
+
3
+ interface ExampleSocketRecord {
4
+ id: string;
5
+ type?: 'get' | 'put';
6
+ name: string;
7
+ tag: string;
8
+ }
9
+
10
+ export class ExampleSocket extends Resource<ExampleSocketRecord> {
11
+ static loadAsInstance = false;
12
+
13
+ // This customizes handling the socket connections; tables can have this method too!
14
+ async *connect(
15
+ target: RequestTarget,
16
+ incomingMessages: IterableEventQueue<ExampleSocketRecord>,
17
+ ): AsyncIterable<ExampleSocketRecord> {
18
+ const subscription = await tables.ExampleTable.subscribe(target);
19
+ if (!incomingMessages) {
20
+ // Server sent events, no incoming messages!
21
+ // Subscribe to changes to the table.
22
+ return subscription;
23
+ }
24
+ for await (let message of incomingMessages) {
25
+ const { type, id, name, tag } = message;
26
+ switch (type) {
27
+ case 'get':
28
+ const loaded = await tables.ExampleTable.get(id);
29
+ yield {
30
+ type: 'get',
31
+ id,
32
+ ...(loaded ? loaded : {}),
33
+ };
34
+ break;
35
+ case 'put':
36
+ await tables.ExampleTable.put(id, { name, tag });
37
+ break;
38
+ }
39
+ }
40
+ }
41
+ }
@@ -0,0 +1,20 @@
1
+ import { type RequestTargetOrId, tables } from 'harperdb';
2
+
3
+ export interface TableNameRecord {
4
+ id: string;
5
+ name: string;
6
+ tag: string;
7
+ }
8
+
9
+ export class ExampleTable extends tables.ExampleTable<TableNameRecord> {
10
+ // we can define our own custom POST handler
11
+ async post(target: RequestTargetOrId, newRecord: Omit<TableNameRecord, 'id'>) {
12
+ // do something with the incoming content;
13
+ return super.post(target, newRecord);
14
+ }
15
+ // or custom GET handler
16
+ async get(target: RequestTargetOrId): Promise<TableNameRecord> {
17
+ // we can modify this resource before returning
18
+ return super.get(target);
19
+ }
20
+ }
@@ -1,28 +1,5 @@
1
1
  import { type RecordObject, type RequestTargetOrId, Resource } from 'harperdb';
2
2
 
3
- /** Here we can define any JavaScript-based resources and extensions to tables
4
- import { tables, type RequestTarget } from 'harperdb';
5
-
6
- interface TableNameRecord {
7
- id: string;
8
- name: string;
9
- tag: string;
10
- }
11
-
12
- export class TableName extends tables.TableName<TableNameRecord> {
13
- // we can define our own custom POST handler
14
- async post(target: RequestTargetOrId, newRecord: Omit<TableNameRecord, 'id'>) {
15
- // do something with the incoming content;
16
- return super.post(target, newRecord);
17
- }
18
- // or custom GET handler
19
- async get(target: RequestTarget): Promise<TableNameRecord> {
20
- // we can modify this resource before returning
21
- return super.get(target);
22
- }
23
- }
24
- */
25
-
26
3
  interface GreetingRecord {
27
4
  greeting: string;
28
5
  }
@@ -1,6 +1,6 @@
1
1
  ## Here we can define any tables in our database. This example shows how we define a type as a table using
2
2
  ## the type name as the table name and specifying it is an "export" available in the REST and other external protocols.
3
- type TableName @table @export {
3
+ type ExampleTable @table @export {
4
4
  id: ID @primaryKey # Here we define primary key (must be one)
5
5
  name: String # we can define any other attributes here
6
6
  tag: String @indexed # we can specify any attributes that should be indexed
@@ -38,7 +38,7 @@ Take a look at the [default configuration](./config.yaml), which specifies how f
38
38
 
39
39
  The [schema.graphql](./schema.graphql) is the table schema definition. This is the main starting point for defining your database schema, specifying which tables you want and what attributes/fields they should have.
40
40
 
41
- The [resources.js](./resources.js) provides a template for defining JavaScript resource classes, for customized application logic in your endpoints.
41
+ The [resources.js](resources/greeting.js) provides a template for defining JavaScript resource classes, for customized application logic in your endpoints.
42
42
 
43
43
  ## Deployment
44
44
 
@@ -13,11 +13,11 @@ rest: true
13
13
 
14
14
  # These reads GraphQL schemas to define the schema of database/tables/attributes.
15
15
  graphqlSchema:
16
- files: 'schema.graphql'
16
+ files: 'schemas/*.graphql'
17
17
 
18
18
  # Loads JavaScript modules such that their exports are exported as resources
19
19
  jsResource:
20
- files: 'resources.js'
20
+ files: 'resources/*.js'
21
21
 
22
22
  # Serve the static files from the web directory as a web application
23
23
  static:
@@ -0,0 +1,34 @@
1
+ import { Resource, tables } from 'harperdb';
2
+
3
+ export class ExampleSocket extends Resource {
4
+ static loadAsInstance = false;
5
+
6
+ // This customizes handling the socket connections; tables can have this method too!
7
+ async *connect(
8
+ target,
9
+ incomingMessages,
10
+ ) {
11
+ const subscription = await tables.ExampleTable.subscribe(target);
12
+ if (!incomingMessages) {
13
+ // Server sent events, no incoming messages!
14
+ // Subscribe to changes to the table.
15
+ return subscription;
16
+ }
17
+ for await (let message of incomingMessages) {
18
+ const { type, id, name, tag } = message;
19
+ switch (type) {
20
+ case 'get':
21
+ const loaded = await tables.ExampleTable.get(id);
22
+ yield {
23
+ type: 'get',
24
+ id,
25
+ ...(loaded ? loaded : {}),
26
+ };
27
+ break;
28
+ case 'put':
29
+ await tables.ExampleTable.put(id, { name, tag });
30
+ break;
31
+ }
32
+ }
33
+ }
34
+ }
@@ -0,0 +1,14 @@
1
+ import { tables } from 'harperdb';
2
+
3
+ export class ExampleTable extends tables.ExampleTable {
4
+ // we can define our own custom POST handler
5
+ post(content) {
6
+ // do something with the incoming content;
7
+ return super.post(content);
8
+ }
9
+ // or custom GET handler
10
+ get() {
11
+ // we can modify this resource before returning
12
+ return super.get();
13
+ }
14
+ }
@@ -0,0 +1,10 @@
1
+ import { Resource } from 'harperdb';
2
+
3
+ export class Greeting extends Resource {
4
+ // a "Hello, world!" handler
5
+ static loadAsInstance = false; // use the updated/newer Resource API
6
+
7
+ get() {
8
+ return { greeting: 'Hello, world!' };
9
+ }
10
+ }
@@ -0,0 +1,7 @@
1
+ ## Here we can define any tables in our database. This example shows how we define a type as a table using
2
+ ## the type name as the table name and specifying it is an "export" available in the REST and other external protocols.
3
+ type ExampleTable @table @export {
4
+ id: ID @primaryKey # Here we define primary key (must be one)
5
+ name: String # we can define any other attributes here
6
+ tag: String @indexed # we can specify any attributes that should be indexed
7
+ }
@@ -36,9 +36,9 @@ For more information on Harper Components, see the [Components documentation](ht
36
36
 
37
37
  Take a look at the [default configuration](./config.yaml), which specifies how files are handled in your application.
38
38
 
39
- The [schema.graphql](./schema.graphql) is the table schema definition. This is the main starting point for defining your database schema, specifying which tables you want and what attributes/fields they should have.
39
+ The [schema.graphql](schemas/exampleTable.graphql) is the table schema definition. This is the main starting point for defining your database schema, specifying which tables you want and what attributes/fields they should have.
40
40
 
41
- The [resources.js](resources.ts) provides a template for defining JavaScript resource classes, for customized application logic in your endpoints.
41
+ The [resources.js](resources/greeting.ts) provides a template for defining JavaScript resource classes, for customized application logic in your endpoints.
42
42
 
43
43
  ## Deployment
44
44
 
@@ -13,11 +13,11 @@ rest: true
13
13
 
14
14
  # These reads GraphQL schemas to define the schema of database/tables/attributes.
15
15
  graphqlSchema:
16
- files: 'schema.graphql'
16
+ files: 'schemas/*.graphql'
17
17
 
18
18
  # Loads JavaScript modules such that their exports are exported as resources
19
19
  jsResource:
20
- files: 'resources.ts'
20
+ files: 'resources/*.ts'
21
21
 
22
22
  # Serve the static files from the web directory as a web application
23
23
  static:
@@ -0,0 +1,41 @@
1
+ import { type IterableEventQueue, RequestTarget, Resource, tables, type User } from 'harperdb';
2
+
3
+ interface ExampleSocketRecord {
4
+ id: string;
5
+ type?: 'get' | 'put';
6
+ name: string;
7
+ tag: string;
8
+ }
9
+
10
+ export class ExampleSocket extends Resource<ExampleSocketRecord> {
11
+ static loadAsInstance = false;
12
+
13
+ // This customizes handling the socket connections; tables can have this method too!
14
+ async *connect(
15
+ target: RequestTarget,
16
+ incomingMessages: IterableEventQueue<ExampleSocketRecord>,
17
+ ): AsyncIterable<ExampleSocketRecord> {
18
+ const subscription = await tables.ExampleTable.subscribe(target);
19
+ if (!incomingMessages) {
20
+ // Server sent events, no incoming messages!
21
+ // Subscribe to changes to the table.
22
+ return subscription;
23
+ }
24
+ for await (let message of incomingMessages) {
25
+ const { type, id, name, tag } = message;
26
+ switch (type) {
27
+ case 'get':
28
+ const loaded = await tables.ExampleTable.get(id);
29
+ yield {
30
+ type: 'get',
31
+ id,
32
+ ...(loaded ? loaded : {}),
33
+ };
34
+ break;
35
+ case 'put':
36
+ await tables.ExampleTable.put(id, { name, tag });
37
+ break;
38
+ }
39
+ }
40
+ }
41
+ }
@@ -0,0 +1,20 @@
1
+ import { type RequestTargetOrId, tables } from 'harperdb';
2
+
3
+ export interface TableNameRecord {
4
+ id: string;
5
+ name: string;
6
+ tag: string;
7
+ }
8
+
9
+ export class ExampleTable extends tables.ExampleTable<TableNameRecord> {
10
+ // we can define our own custom POST handler
11
+ async post(target: RequestTargetOrId, newRecord: Omit<TableNameRecord, 'id'>) {
12
+ // do something with the incoming content;
13
+ return super.post(target, newRecord);
14
+ }
15
+ // or custom GET handler
16
+ async get(target: RequestTargetOrId): Promise<TableNameRecord> {
17
+ // we can modify this resource before returning
18
+ return super.get(target);
19
+ }
20
+ }
@@ -1,28 +1,5 @@
1
1
  import { type RecordObject, type RequestTargetOrId, Resource } from 'harperdb';
2
2
 
3
- /** Here we can define any JavaScript-based resources and extensions to tables
4
- import { tables, type RequestTarget } from 'harperdb';
5
-
6
- interface TableNameRecord {
7
- id: string;
8
- name: string;
9
- tag: string;
10
- }
11
-
12
- export class TableName extends tables.TableName<TableNameRecord> {
13
- // we can define our own custom POST handler
14
- async post(target: RequestTargetOrId, newRecord: Omit<TableNameRecord, 'id'>) {
15
- // do something with the incoming content;
16
- return super.post(target, newRecord);
17
- }
18
- // or custom GET handler
19
- async get(target: RequestTarget): Promise<TableNameRecord> {
20
- // we can modify this resource before returning
21
- return super.get(target);
22
- }
23
- }
24
- */
25
-
26
3
  interface GreetingRecord {
27
4
  greeting: string;
28
5
  }
@@ -0,0 +1,7 @@
1
+ ## Here we can define any tables in our database. This example shows how we define a type as a table using
2
+ ## the type name as the table name and specifying it is an "export" available in the REST and other external protocols.
3
+ type ExampleTable @table @export {
4
+ id: ID @primaryKey # Here we define primary key (must be one)
5
+ name: String # we can define any other attributes here
6
+ tag: String @indexed # we can specify any attributes that should be indexed
7
+ }
@@ -1,7 +0,0 @@
1
- # your-project-name-here
2
-
3
- This repository is intended for use alongside the Harper Learn ["Getting Started > Create Your First Application"](https://docs.harperdb.io/learn/getting-started/create-your-first-application) guide.
4
-
5
- The `main` branch is the starting point for the guide.
6
-
7
- The `completed` branch is the completed code example if you need to check your work.
@@ -1 +0,0 @@
1
- .env
@@ -1,3 +0,0 @@
1
- CLI_TARGET_USERNAME='your-cluster-username-here'
2
- CLI_TARGET_PASSWORD='your-cluster-password-here'
3
- CLI_TARGET='your-fabric.harper.fast-cluster-url-here'
@@ -1,3 +0,0 @@
1
- CLI_TARGET_USERNAME='YOUR_CLUSTER_USERNAME'
2
- CLI_TARGET_PASSWORD='YOUR_CLUSTER_PASSWORD'
3
- CLI_TARGET='YOUR_FABRIC.HARPER.FAST_CLUSTER_URL_HERE'
@@ -1,147 +0,0 @@
1
- .DS_Store
2
-
3
- #
4
- # https://raw.githubusercontent.com/github/gitignore/refs/heads/main/Node.gitignore
5
- #
6
-
7
- # Logs
8
- logs
9
- *.log
10
- npm-debug.log*
11
- yarn-debug.log*
12
- yarn-error.log*
13
- lerna-debug.log*
14
-
15
- # Diagnostic reports (https://nodejs.org/api/report.html)
16
- report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
17
-
18
- # Runtime data
19
- pids
20
- *.pid
21
- *.seed
22
- *.pid.lock
23
-
24
- # Directory for instrumented libs generated by jscoverage/JSCover
25
- lib-cov
26
-
27
- # Coverage directory used by tools like istanbul
28
- coverage
29
- *.lcov
30
-
31
- # nyc test coverage
32
- .nyc_output
33
-
34
- # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
35
- .grunt
36
-
37
- # Bower dependency directory (https://bower.io/)
38
- bower_components
39
-
40
- # node-waf configuration
41
- .lock-wscript
42
-
43
- # Compiled binary addons (https://nodejs.org/api/addons.html)
44
- build/Release
45
-
46
- # Dependency directories
47
- node_modules/
48
- jspm_packages/
49
-
50
- # Snowpack dependency directory (https://snowpack.dev/)
51
- web_modules/
52
-
53
- # TypeScript cache
54
- *.tsbuildinfo
55
-
56
- # Optional npm cache directory
57
- .npm
58
-
59
- # Optional eslint cache
60
- .eslintcache
61
-
62
- # Optional stylelint cache
63
- .stylelintcache
64
-
65
- # Optional REPL history
66
- .node_repl_history
67
-
68
- # Output of 'npm pack'
69
- *.tgz
70
-
71
- # Yarn Integrity file
72
- .yarn-integrity
73
-
74
- # dotenv environment variable files
75
- .env
76
- .env.*
77
- !.env.example
78
-
79
- # parcel-bundler cache (https://parceljs.org/)
80
- .cache
81
- .parcel-cache
82
-
83
- # Next.js build output
84
- .next
85
- out
86
-
87
- # Nuxt.js build / generate output
88
- .nuxt
89
- dist
90
- .output
91
-
92
- # Gatsby files
93
- .cache/
94
- # Comment in the public line in if your project uses Gatsby and not Next.js
95
- # https://nextjs.org/blog/next-9-1#public-directory-support
96
- # public
97
-
98
- # vuepress build output
99
- .vuepress/dist
100
-
101
- # vuepress v2.x temp and cache directory
102
- .temp
103
- .cache
104
-
105
- # Sveltekit cache directory
106
- .svelte-kit/
107
-
108
- # vitepress build output
109
- **/.vitepress/dist
110
-
111
- # vitepress cache directory
112
- **/.vitepress/cache
113
-
114
- # Docusaurus cache and generated files
115
- .docusaurus
116
-
117
- # Serverless directories
118
- .serverless/
119
-
120
- # FuseBox cache
121
- .fusebox/
122
-
123
- # DynamoDB Local files
124
- .dynamodb/
125
-
126
- # Firebase cache directory
127
- .firebase/
128
-
129
- # TernJS port file
130
- .tern-port
131
-
132
- # Stores VSCode versions used for testing VSCode extensions
133
- .vscode-test
134
-
135
- # yarn v3
136
- .pnp.*
137
- .yarn/*
138
- !.yarn/patches
139
- !.yarn/plugins
140
- !.yarn/releases
141
- !.yarn/sdks
142
- !.yarn/versions
143
-
144
- # Vite files
145
- vite.config.js.timestamp-*
146
- vite.config.ts.timestamp-*
147
- .vite/
@@ -1,7 +0,0 @@
1
- # yaml-language-server: $schema=./node_modules/harperdb/config-app.schema.json
2
-
3
- # This is the configuration file for the application.
4
- # It specifies built-in Harper components that will load the specified feature and files.
5
- # For more information, see https://docs.harperdb.io/docs/reference/components/built-in-extensions
6
-
7
- # Follow along with https://github.com/HarperFast/create-your-first-application to learn more!
@@ -1,3 +0,0 @@
1
- schema: schema.graphql
2
- include: node_modules/harperdb/schema.graphql
3
- documents: '**/*.graphql'
@@ -1,14 +0,0 @@
1
- {
2
- "name": "your-package-name-here",
3
- "version": "1.0.0",
4
- "description": "Your new Harper app",
5
- "type": "module",
6
- "scripts": {
7
- "start": "harperdb run .",
8
- "dev": "harperdb dev .",
9
- "deploy": "npx -y dotenv-cli -- harperdb deploy . restart=rolling replicated=true"
10
- },
11
- "devDependencies": {
12
- "harperdb": "^4.7.15"
13
- }
14
- }
@@ -1 +0,0 @@
1
- ## Table Schemas
@@ -1,27 +0,0 @@
1
- import { Resource } from 'harperdb';
2
-
3
- /** Here we can define any JavaScript-based resources and extensions to tables
4
- import {tables} from 'harperdb';
5
-
6
- export class MyCustomResource extends tables.TableName {
7
- // we can define our own custom POST handler
8
- post(content) {
9
- // do something with the incoming content;
10
- return super.post(content);
11
- }
12
- // or custom GET handler
13
- get() {
14
- // we can modify this resource before returning
15
- return super.get();
16
- }
17
- }
18
- */
19
- // we can also define a custom resource without a specific table
20
- export class Greeting extends Resource {
21
- // a "Hello, world!" handler
22
- static loadAsInstance = false; // use the updated/newer Resource API
23
-
24
- get() {
25
- return { greeting: 'Hello, world!' };
26
- }
27
- }
@@ -1,5 +0,0 @@
1
- type ToDoList @table @export {
2
- id: ID @primaryKey
3
- status: String @index
4
- description: String
5
- }
@@ -1,5 +0,0 @@
1
- type ToDoList @table @export {
2
- id: ID @primaryKey
3
- status: String @index
4
- description: String
5
- }
@@ -1,27 +0,0 @@
1
- import { Resource } from 'harperdb';
2
-
3
- /** Here we can define any JavaScript-based resources and extensions to tables
4
- import {tables} from 'harperdb';
5
-
6
- export class MyCustomResource extends tables.TableName {
7
- // we can define our own custom POST handler
8
- post(content) {
9
- // do something with the incoming content;
10
- return super.post(content);
11
- }
12
- // or custom GET handler
13
- get() {
14
- // we can modify this resource before returning
15
- return super.get();
16
- }
17
- }
18
- */
19
- // we can also define a custom resource without a specific table
20
- export class Greeting extends Resource {
21
- // a "Hello, world!" handler
22
- static loadAsInstance = false; // use the updated/newer Resource API
23
-
24
- get() {
25
- return { greeting: 'Hello, world!' };
26
- }
27
- }