-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add pod component and changes to config
- Loading branch information
Showing
7 changed files
with
140 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import type { ServiceDescription } from '../service/IService'; | ||
|
||
export interface IPod { | ||
newServiceLocation: (description: ServiceDescription) => Promise<string>; | ||
} | ||
|
||
export type PodServiceLocation = string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import * as path from 'node:path'; | ||
import * as fs from 'fs-extra'; | ||
import { AppRunner } from '@solid/community-server'; | ||
import { v4 } from 'uuid'; | ||
import { AsyncConstructor } from '../core/AsyncConstructor'; | ||
import type { ServiceDescription } from '../service/IService'; | ||
import type { IPod, PodServiceLocation } from './IPod'; | ||
|
||
export class PodCss extends AsyncConstructor implements IPod { | ||
public podURL = 'http://localhost:3000/aggregator'; | ||
|
||
public constructor() { | ||
super({}); | ||
} | ||
|
||
protected async initialize(): Promise<void> { | ||
// TODO [2024-03-01]: make sure the file for the server is selected => not sure actually | ||
|
||
const loaderProperties = { | ||
mainModulePath: 'node_modules/@solid/community-server/', | ||
dumpErrorState: true, | ||
typeChecking: false, | ||
}; | ||
|
||
const config = path.join(__dirname, './assets/css-config.json'); | ||
|
||
const shorthand: Record<string, unknown> = { | ||
rootFilePath: path.join(__dirname, './assets/podData/'), | ||
}; | ||
if (!(await fs.pathExists(path.join(__dirname, './assets/podData/')))) { | ||
shorthand.seedConfig = path.join(__dirname, './assets/seed.json'); | ||
} | ||
|
||
await (new AppRunner()).run({ | ||
loaderProperties, | ||
config, | ||
shorthand, | ||
}); | ||
// TODO [2024-03-01]: Edit profile card | ||
} | ||
|
||
public async newServiceLocation(description: ServiceDescription): Promise<PodServiceLocation> { | ||
if (!this.initialized) { | ||
await new Promise<void>((resolve): void => { | ||
this.subscribeInitialized((): void => { | ||
resolve(); | ||
}); | ||
}); | ||
} | ||
|
||
// Create service folder with uuid | ||
const location = `${this.podURL}/${v4()}`; | ||
const response = await fetch(`${location}/description`, { | ||
method: 'PUT', | ||
body: description.toString(), | ||
}); | ||
|
||
if (response.ok) { | ||
return location; | ||
} | ||
// TODO [2024-03-01]: redo maybe? | ||
throw new Error(`Can't create location on the Solid Server: ${response.statusText}`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
./podData |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^7.0.0/components/context.jsonld", | ||
"import": [ | ||
"css:config/app/init/default.json", | ||
"css:config/app/main/default.json", | ||
"css:config/app/variables/default.json", | ||
"css:config/http/handler/default.json", | ||
"css:config/http/middleware/default.json", | ||
"css:config/http/notifications/all.json", | ||
"css:config/http/server-factory/http.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/oidc/default.json", | ||
"css:config/identity/ownership/token.json", | ||
"css:config/identity/pod/static.json", | ||
"css:config/ldp/authentication/dpop-bearer.json", | ||
"css:config/ldp/authorization/allow-all.json", | ||
"css:config/ldp/handler/default.json", | ||
"css:config/ldp/metadata-parser/default.json", | ||
"css:config/ldp/metadata-writer/default.json", | ||
"css:config/ldp/modes/default.json", | ||
"css:config/storage/backend/memory.json", | ||
"css:config/storage/key-value/resource-store.json", | ||
"css:config/storage/location/pod.json", | ||
"css:config/storage/middleware/default.json", | ||
"css:config/util/auxiliary/empty.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/file.json", | ||
"css:config/util/variables/default.json" | ||
], | ||
"@graph": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[ | ||
{ | ||
"email": "[email protected]", | ||
"password": "aggregator", | ||
"pods": [ | ||
{ "name": "aggregator" } | ||
] | ||
} | ||
] |