Skip to content

Commit 7e3ddb1

Browse files
committed
move createServerLessPod to solid-rest
1 parent 736bf22 commit 7e3ddb1

File tree

7 files changed

+31
-137
lines changed

7 files changed

+31
-137
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,11 @@ The solid-auth-fetcher session and authFetcher objects are available for each cl
136136
137137
## <a name="pod">Creating a serverless pod</a>
138138
139-
Solid Node Client can access the local file system using file:// URLs without using a server. In most respects, it will treat the file system as a pod. To get the full benefit of this, it's best to create some local files such as a profile, a preferences file, and type indexes. You can create them manually or copy them from a remote pod, but the easiest thing to do is use the built-in createLocalPod method.
139+
Solid Node Client can access the local file system using file:// URLs without using a server. In most respects, it will treat the file system as a pod. To get the full benefit of this, it's best to create some local files such as a profile, a preferences file, and type indexes. You can create them manually or copy them from a remote pod, but the easiest thing to do is use the built-in createServerlessPod method.
140140
```javascript
141141
import {SolidNodeClient} from 'solid-node-client';
142142
const client = new SolidNodeClient();
143-
client.createLocalPod('file:///home/jeff/myPod/');
143+
client.createServerlessPod('file:///home/jeff/myPod/');
144144
```
145145
The code above will create a profile, preferences and other key pod resources in the named folder. Your profile will be located at '/home/jeff/myPod/profile/card' and your preferences file will be located at '/home/jeff/myPod/settings/prefs.ttl'. You can now use a file:// URL to refer to your local webId: <file:///home/jeff/myPod/profile/card#me>. As with a server-based pod, this webId is the starting point for any app that wants to follow its nose through your local file system.
146146

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "solid-node-client",
3-
"version": "1.2.3",
3+
"version": "1.2.4",
44
"description": "a client for nodejs access to Solid",
55
"main": "./src/index.js",
66
"scripts": {
@@ -12,7 +12,7 @@
1212
"license": "MIT",
1313
"dependencies": {
1414
"solid-auth-fetcher": "^1.3.5",
15-
"solid-rest": "^1.2.7"
15+
"solid-rest": "^1.2.8"
1616
},
1717
"devDependencies": {
1818
"rdflib": "^2.1.1",

src/createLocalPod.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/createLocalPod.ts

Lines changed: 0 additions & 72 deletions
This file was deleted.

src/index.js

Lines changed: 7 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4141
exports.__esModule = true;
4242
exports.SolidNodeClient = void 0;
4343
var solid_auth_fetcher_1 = require("solid-auth-fetcher");
44-
var createLocalPod_js_1 = require("./createLocalPod.js");
44+
/*
45+
import
46+
{profile_content,prefs_content,private_content,public_content,acl_content}
47+
from './createLocalPod.js';
48+
*/
4549
var node_fetch_1 = __importDefault(require("node-fetch"));
4650
var solid_rest_1 = __importDefault(require("solid-rest"));
4751
var SolidNodeClient = /** @class */ (function () {
@@ -144,52 +148,10 @@ var SolidNodeClient = /** @class */ (function () {
144148
});
145149
});
146150
};
147-
SolidNodeClient.prototype.createLocalPod = function (base) {
151+
SolidNodeClient.prototype.createServerlessPod = function (base) {
148152
return __awaiter(this, void 0, void 0, function () {
149153
return __generator(this, function (_a) {
150-
switch (_a.label) {
151-
case 0:
152-
base = base.replace(/\/$/, '');
153-
return [4 /*yield*/, this.makeResource(base, "/profile/card", createLocalPod_js_1.profile_content)];
154-
case 1:
155-
_a.sent();
156-
return [4 /*yield*/, this.makeResource(base, "/settings/prefs.ttl", createLocalPod_js_1.prefs_content)];
157-
case 2:
158-
_a.sent();
159-
return [4 /*yield*/, this.makeResource(base, "/settings/privateTypeIndex.ttl", createLocalPod_js_1.private_content)];
160-
case 3:
161-
_a.sent();
162-
return [4 /*yield*/, this.makeResource(base, "/settings/publicTypeIndex.ttl", createLocalPod_js_1.public_content)];
163-
case 4:
164-
_a.sent();
165-
return [4 /*yield*/, this.makeResource(base, "/public/.meta", "")];
166-
case 5:
167-
_a.sent();
168-
return [4 /*yield*/, this.makeResource(base, "/inbox/.meta", "")];
169-
case 6:
170-
_a.sent();
171-
return [2 /*return*/];
172-
}
173-
});
174-
});
175-
};
176-
SolidNodeClient.prototype.makeResource = function (base, path, content) {
177-
return __awaiter(this, void 0, void 0, function () {
178-
var url;
179-
return __generator(this, function (_a) {
180-
switch (_a.label) {
181-
case 0:
182-
url = base + path;
183-
console.log("Creating " + url);
184-
return [4 /*yield*/, this.fetch(url, {
185-
method: "PUT",
186-
body: content,
187-
headers: { "content-type": "text/turtle" }
188-
})];
189-
case 1:
190-
_a.sent();
191-
return [2 /*return*/];
192-
}
154+
return [2 /*return*/, this.rest.createServerlessPod(base)];
193155
});
194156
});
195157
};

src/index.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
import { getSession, getNodeSolidServerCookie, getAuthFetcher }
1+
import
2+
{ getSession, getNodeSolidServerCookie, getAuthFetcher }
23
from "solid-auth-fetcher";
3-
import {profile_content,prefs_content,private_content,public_content}
4+
/*
5+
import
6+
{profile_content,prefs_content,private_content,public_content,acl_content}
47
from './createLocalPod.js';
8+
*/
59
import fetch from "node-fetch";
610
import SolidRest from "solid-rest";
711

@@ -64,25 +68,33 @@ export class SolidNodeClient {
6468
async currentSession(){
6569
return ( this.session.loggedIn ) ? this.session : null ;
6670
}
71+
async createServerlessPod( base:string ){
72+
return this.rest.createServerlessPod( base );
73+
}
74+
/*
6775
async createLocalPod( base:string ){
76+
console.log(`Creating pod at <${base}>`);
6877
base = base.replace(/\/$/,'');
78+
await this.makeResource( base,"/.acl", acl_content );
6979
await this.makeResource( base,"/profile/card", profile_content );
7080
await this.makeResource( base,"/settings/prefs.ttl", prefs_content );
7181
await this.makeResource(base,"/settings/privateTypeIndex.ttl",private_content );
7282
await this.makeResource( base,"/settings/publicTypeIndex.ttl", public_content );
83+
await this.makeResource( base,"/private/.meta", "" );
84+
await this.makeResource( base,"/.well-known/.meta", "" );
7385
await this.makeResource( base,"/public/.meta", "" );
7486
await this.makeResource( base,"/inbox/.meta", "" );
7587
}
7688
async makeResource( base:string, path:string, content:string ){
7789
let url = base + path
78-
console.log ( "Creating " + url )
90+
console.log ( " creating " + path )
7991
await this.fetch( url, {
8092
method:"PUT",
8193
body:content,
8294
headers:{"content-type":"text/turtle"}
8395
})
8496
}
85-
97+
*/
8698
}
8799

88100
/** UNAUTHENTICATED SESSION

0 commit comments

Comments
 (0)