Skip to content

Commit bab44d5

Browse files
tasks module readme
1 parent bef6e2c commit bab44d5

2 files changed

Lines changed: 41 additions & 1 deletion

File tree

tasks/README.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,43 @@
11
## Tasks Data Module
22

3-
(under construction)
3+
To use this Solid Data Module you need an authenticated fetch function. In Node.JS, when working against a CSS or Pivot server such as solidcommnunity.net, you can use [css-authn](https://www.npmjs.com/package/css-authn#usage) for this. In the browser, you can use [Inrupt Solid Client](https://docs.inrupt.com/developer-tools/javascript/client-libraries/authentication/).
4+
5+
6+
### Usage
7+
Set up a typescript project, install [solid-data-module-tasks](https://www.npmjs.com/package/solid-data-module-tasks) from NPM, and create a `.env` file like this:
8+
```env
9+
SOLID_SERVER=https://solidcommunity.net
10+
SOLID_EMAIL=michielbdejong@users.css.pod
11+
SOLID_PASSWORD=...
12+
```
13+
14+
Make sure there is a Solid OS issue tracker at `trackerUrl`. You can create this through the web interface of Pivot.
15+
16+
Then save, build and run the following TypeScript file:
17+
```ts
18+
import 'dotenv/config';
19+
import { v7 } from 'css-authn';
20+
import { fetchTracker, Interpretation, addIssue, addComment } from 'solid-data-module-tasks';
21+
22+
const authenticatedFetch = await v7.getAuthenticatedFetch({
23+
email: process.env.SOLID_EMAIL,
24+
password: process.env.SOLID_PASSWORD,
25+
provider: process.env.SOLID_SERVER,
26+
});
27+
const trackerUrl = 'https://michielbdejong.solidcommunity.net/tasks/index.ttl#this';
28+
const localState: Interpretation = await fetchTracker(trackerUrl, authenticatedFetch);
29+
const issueUri = await addIssue(localState, {
30+
title: 'Use the Solid Data Module for Tasks',
31+
description: 'Solid app devs should not be rolling their own task tracker access code.',
32+
}, authenticatedFetch);
33+
const newComment = {
34+
issueUri,
35+
author: 'https://michielbdejong.solidcommunity.net/profile/card#me',
36+
text: `I totally agree at ${new Date().toUTCString()}`,
37+
};
38+
const commentUri = await addComment(localState, newComment, authenticatedFetch);
39+
console.log(commentUri);
40+
```
41+
42+
This will result in an issue and a comment being created in that tracker:
43+
![screenshot](https://github.com/user-attachments/assets/8d0a1aef-94c8-4c41-848d-d21edfe5f116)

tasks/vanilla/src/fetcher.ts

Whitespace-only changes.

0 commit comments

Comments
 (0)