-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
144 lines (138 loc) · 4.72 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
const CSS = require("@solid/community-server");
const fs = require("fs/promises");
const basicConfig = {
"@context": [
"https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^5.0.0/components/context.jsonld",
"https://linkedsoftwaredependencies.org/bundles/npm/ldes-solid-server/^0.0.0/components/context.jsonld",
],
"import": [
"css:config/app/main/default.json",
"css:config/app/init/initialize-root.json",
"css:config/app/setup/disabled.json",
"css:config/app/variables/default.json",
"css:config/http/handler/default.json",
"css:config/http/middleware/websockets.json",
"css:config/http/server-factory/websockets.json",
"css:config/http/static/default.json",
"css:config/identity/access/public.json",
"css:config/identity/email/default.json",
"css:config/identity/handler/default.json",
"css:config/identity/ownership/token.json",
"css:config/identity/pod/static.json",
"css:config/identity/registration/enabled.json",
"css:config/ldp/authentication/dpop-bearer.json",
"css:config/ldp/authorization/allow-all.json",
"lss:config/ldp/handler/default.json",
"css:config/ldp/metadata-parser/default.json",
"lss:config/ldp/metadata-writer/default.json",
"css:config/ldp/modes/default.json",
"css:config/storage/backend/data-accessors/memory.json",
"css:config/storage/key-value/memory.json",
"css:config/storage/middleware/default.json",
"css:config/util/auxiliary/no-acl.json",
"css:config/util/identifiers/suffix.json",
"css:config/util/index/default.json",
"css:config/util/logging/winston.json",
"css:config/util/representation-conversion/default.json",
"css:config/util/resource-locker/memory.json",
"css:config/util/variables/default.json",
],
"@graph": [
{
"@id": "urn:solid-server:default:ResourceStore_Backend",
"comment":
"A more complex example with 3 different stores being routed to.",
"@type": "RepresentationConvertingStore",
"source": {
"@type": "LDESStore",
"id": "http://mine.org/testing",
"base": { "@id": "urn:solid-server:default:variable:baseUrl" },
"relativePath": {
"@id": "urn:solid-server:default:relative-path",
},
"views": [
{
"@type": "PrefixView",
"prefix": "default",
"view": {
"@type": "MongoSDSView",
"descriptionId":
"http://localhost:3000/ldes/#timestampFragmentation",
"streamId": "https://w3id.org/sds#Stream",
"db": {
"@id": "urn:solid-server:default:DBConfig",
},
"freshDuration": 240,
},
},
],
},
"options_outConverter": {
"@id": "urn:solid-server:default:RepresentationConverter",
},
},
{
"@id": "urn:solid-server:default:MemoryResourceStore",
"@type": "DataAccessorBasedStore",
"identifierStrategy": {
"@id": "urn:solid-server:default:IdentifierStrategy",
},
"auxiliaryStrategy": {
"@id": "urn:solid-server:default:AuxiliaryStrategy",
},
"accessor": {
"@id": "urn:solid-server:default:MemoryDataAccessor",
},
"metadataStrategy": {
"@id": "urn:solid-server:default:MetadataStrategy",
},
},
{
"@id": "urn:solid-server:default:relative-path",
"valueRaw": "/ldes/",
},
],
};
async function start(dbConfig, views) {
console.log("DB config", dbConfig);
console.log("views", views);
const dbJson = {
"@id": "urn:solid-server:default:DBConfig",
"@type": "DBConfig",
metaCollection: dbConfig.metadata,
indexCollection: dbConfig.index,
membersCollection: dbConfig.data,
dbUrl: dbConfig.url,
};
basicConfig["@graph"].push(dbJson);
const viewsJson = views.map((view) => ({
"@type": "PrefixView",
prefix: view.prefix,
view: {
"@type": "MongoSDSView",
"descriptionId": view.description,
"streamId": view.stream,
"db": {
"@id": "urn:solid-server:default:DBConfig",
},
"freshDuration": 240,
},
}));
basicConfig["@graph"][0].source.views = viewsJson;
const path = "/tmp/config.json";
await fs.writeFile(path, JSON.stringify(basicConfig), { flag: "w" });
return async () => {
const runner = new CSS.AppRunner();
const config = {
// This makes little sense, but I'll allow it
mainModulePath: "/tmp/node_modules/@solid/community-server/",
logLevel: "info",
typeChecking: false,
};
console.log(config, path);
await runner.run(config, [path], {
"urn:solid-server:default:variable:baseUrl": "http://localhost:3000/",
});
};
}
exports.start = start;