mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
feat: Move runtime config into dedicated component, Closes #67
* Move runtime config into dedicated component, Closes #67 * Migrate FileResourceStore to RuntimeConfig
This commit is contained in:
@@ -11,6 +11,7 @@ import {
|
||||
QuadToTurtleConverter,
|
||||
Representation,
|
||||
RepresentationConvertingStore,
|
||||
RuntimeConfig,
|
||||
Setup,
|
||||
SimpleAclAuthorizer,
|
||||
SimpleBodyParser,
|
||||
@@ -36,15 +37,13 @@ import {
|
||||
const { argv } = yargs
|
||||
.usage('node ./bin/server.js [args]')
|
||||
.options({
|
||||
port: { type: 'number', alias: 'p', default: 3000 },
|
||||
port: { type: 'number', alias: 'p' },
|
||||
})
|
||||
.help();
|
||||
|
||||
const { port } = argv;
|
||||
|
||||
const base = `http://localhost:${port}/`;
|
||||
|
||||
// This is instead of the dependency injection that still needs to be added
|
||||
const runtimeConfig = new RuntimeConfig();
|
||||
|
||||
const bodyParser = new CompositeAsyncHandler<HttpRequest, Representation | undefined>([
|
||||
new SimpleSparqlUpdateBodyParser(),
|
||||
new SimpleBodyParser(),
|
||||
@@ -62,7 +61,7 @@ const permissionsExtractor = new CompositeAsyncHandler([
|
||||
]);
|
||||
|
||||
// Will have to see how to best handle this
|
||||
const store = new SimpleResourceStore(base);
|
||||
const store = new SimpleResourceStore(runtimeConfig);
|
||||
const converter = new CompositeAsyncHandler([
|
||||
new TurtleToQuadConverter(),
|
||||
new QuadToTurtleConverter(),
|
||||
@@ -73,7 +72,7 @@ const patcher = new SimpleSparqlUpdatePatchHandler(convertingStore, locker);
|
||||
const patchingStore = new PatchingStore(convertingStore, patcher);
|
||||
|
||||
const aclManager = new SimpleExtensionAclManager();
|
||||
const containerManager = new UrlContainerManager(base);
|
||||
const containerManager = new UrlContainerManager(runtimeConfig);
|
||||
const authorizer = new SimpleAclAuthorizer(aclManager, containerManager, patchingStore);
|
||||
|
||||
const operationHandler = new CompositeAsyncHandler([
|
||||
@@ -97,9 +96,11 @@ const httpHandler = new AuthenticatedLdpHandler({
|
||||
|
||||
const httpServer = new ExpressHttpServer(httpHandler);
|
||||
|
||||
const setup = new Setup(httpServer, store, aclManager);
|
||||
setup.setup(port, base).then((): void => {
|
||||
process.stdout.write(`Running at ${base}\n`);
|
||||
const setup = new Setup(httpServer, store, aclManager, runtimeConfig);
|
||||
|
||||
runtimeConfig.reset({ port: argv.port });
|
||||
setup.setup().then((): void => {
|
||||
process.stdout.write(`Running at ${runtimeConfig.base}\n`);
|
||||
}).catch((error): void => {
|
||||
process.stderr.write(`${error}\n`);
|
||||
process.exit(1);
|
||||
|
||||
Reference in New Issue
Block a user