Skip to content

Commit

Permalink
chats: example to create a new chat
Browse files Browse the repository at this point in the history
  • Loading branch information
angelo-v committed Aug 12, 2024
1 parent d31e0a0 commit b9a5902
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
4 changes: 4 additions & 0 deletions chats/rdflib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ const updater = new UpdateManager(store);
const module: ChatsModule = new ChatsModuleRdfLib({store, fetcher, updater});

// 3️⃣ use the module to interact with chats
const uri = await module.createChat({
containerUri: "http://localhost:3000/alice/public/chats/",
name: "My new chat",
});

```

Expand Down
10 changes: 0 additions & 10 deletions chats/rdflib/examples/create-chat.js

This file was deleted.

19 changes: 19 additions & 0 deletions chats/rdflib/examples/create-chat.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import ChatsModule from "../dist/index.js";
import { Fetcher, graph, UpdateManager } from "rdflib";

import { faker } from "@faker-js/faker";

const store = graph();
const fetcher = new Fetcher(store);
const updater = new UpdateManager(store);

const module = new ChatsModule({store, fetcher, updater});

const name = `Chat about ${faker.word.sample()}`;

const uri = await module.createChat({
containerUri: "http://localhost:3000/alice/public/chats/",
name,
});

console.log("new chat created:", name, uri);

0 comments on commit b9a5902

Please sign in to comment.