mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
feat: Add placeholders for static assets to configuration.
This commit is contained in:
parent
5a12315554
commit
75d0d4152a
@ -16,6 +16,7 @@
|
||||
"files-scs:config/presets/middleware.json",
|
||||
"files-scs:config/presets/pod-management.json",
|
||||
"files-scs:config/presets/representation-conversion.json",
|
||||
"files-scs:config/presets/static.json",
|
||||
"files-scs:config/presets/storage/backend/storage-memory.json",
|
||||
"files-scs:config/presets/storage-wrapper.json",
|
||||
"files-scs:config/presets/cli-params.json"
|
||||
|
@ -16,6 +16,7 @@
|
||||
"files-scs:config/presets/middleware.json",
|
||||
"files-scs:config/presets/pod-management.json",
|
||||
"files-scs:config/presets/representation-conversion.json",
|
||||
"files-scs:config/presets/static.json",
|
||||
"files-scs:config/presets/storage/backend/storage-filesystem.json",
|
||||
"files-scs:config/presets/storage-wrapper.json",
|
||||
"files-scs:config/presets/cli-params.json"
|
||||
|
@ -16,6 +16,7 @@
|
||||
"files-scs:config/presets/middleware.json",
|
||||
"files-scs:config/presets/pod-management.json",
|
||||
"files-scs:config/presets/representation-conversion.json",
|
||||
"files-scs:config/presets/static.json",
|
||||
"files-scs:config/presets/storage/backend/storage-filesystem.json",
|
||||
"files-scs:config/presets/storage/backend/storage-memory.json",
|
||||
"files-scs:config/presets/storage/backend/storage-sparql-endpoint.json",
|
||||
|
@ -16,6 +16,7 @@
|
||||
"files-scs:config/presets/middleware.json",
|
||||
"files-scs:config/presets/pod-management.json",
|
||||
"files-scs:config/presets/representation-conversion.json",
|
||||
"files-scs:config/presets/static.json",
|
||||
"files-scs:config/presets/storage/backend/storage-filesystem.json",
|
||||
"files-scs:config/presets/storage/backend/storage-sparql-endpoint.json",
|
||||
"files-scs:config/presets/storage/routing/quad-type-routing.json",
|
||||
|
@ -16,6 +16,7 @@
|
||||
"files-scs:config/presets/middleware.json",
|
||||
"files-scs:config/presets/pod-management.json",
|
||||
"files-scs:config/presets/representation-conversion.json",
|
||||
"files-scs:config/presets/static.json",
|
||||
"files-scs:config/presets/storage/backend/storage-sparql-endpoint.json",
|
||||
"files-scs:config/presets/storage-wrapper.json",
|
||||
"files-scs:config/presets/cli-params.json"
|
||||
|
@ -28,6 +28,9 @@
|
||||
{
|
||||
"@type": "WaterfallHandler",
|
||||
"WaterfallHandler:_handlers": [
|
||||
{
|
||||
"@id": "urn:solid-server:default:StaticAssetHandler"
|
||||
},
|
||||
{
|
||||
"@id": "urn:solid-server:default:PodManagerHandler"
|
||||
},
|
||||
|
@ -82,7 +82,11 @@
|
||||
"@type": "WaterfallHandler",
|
||||
"WaterfallHandler:_handlers": [
|
||||
{
|
||||
"@type": "IfNeededConverter"
|
||||
"@id": "urn:solid-server:default:IndexConverter",
|
||||
},
|
||||
{
|
||||
"@type": "IfNeededConverter",
|
||||
"comment": "Only continue converting if the requester cannot accept the available content type",
|
||||
},
|
||||
{
|
||||
"@id": "urn:solid-server:default:ContentTypeReplacer"
|
||||
|
15
config/presets/static.json
Normal file
15
config/presets/static.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^0.0.0/components/context.jsonld",
|
||||
"@graph": [
|
||||
{
|
||||
"@id": "urn:solid-server:default:IndexConverter",
|
||||
"@type": "UnsupportedAsyncHandler",
|
||||
"comment": "This value can be used to set a custom handler for index files"
|
||||
},
|
||||
{
|
||||
"@id": "urn:solid-server:default:StaticAssetHandler",
|
||||
"@type": "UnsupportedAsyncHandler",
|
||||
"comment": "This value can be used to set a custom handler for static assets"
|
||||
}
|
||||
]
|
||||
}
|
@ -2,6 +2,7 @@ import { createReadStream } from 'fs';
|
||||
import * as mime from 'mime-types';
|
||||
import { getLoggerFor } from '../../logging/LogUtil';
|
||||
import { APPLICATION_OCTET_STREAM } from '../../util/ContentTypes';
|
||||
import { NotImplementedHttpError } from '../../util/errors/NotImplementedHttpError';
|
||||
import { pipeSafely } from '../../util/StreamUtil';
|
||||
import type { HttpHandlerInput } from '../HttpHandler';
|
||||
import { HttpHandler } from '../HttpHandler';
|
||||
@ -25,10 +26,10 @@ export class StaticAssetHandler extends HttpHandler {
|
||||
|
||||
public async canHandle({ request }: HttpHandlerInput): Promise<void> {
|
||||
if (request.method !== 'GET' && request.method !== 'HEAD') {
|
||||
throw new Error('Only GET and HEAD requests are supported');
|
||||
throw new NotImplementedHttpError('Only GET and HEAD requests are supported');
|
||||
}
|
||||
if (!(this.getAssetUrl(request) in this.assets)) {
|
||||
throw new Error(`No static resource at ${request.url}`);
|
||||
throw new NotImplementedHttpError(`No static resource at ${request.url}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
"files-scs:config/presets/ldp/response-writer.json",
|
||||
"files-scs:config/presets/ldp/request-parser.json",
|
||||
"files-scs:config/presets/representation-conversion.json",
|
||||
"files-scs:config/presets/static.json",
|
||||
"files-scs:config/presets/storage/backend/storage-memory.json",
|
||||
"files-scs:config/presets/storage/backend/storage-filesystem.json",
|
||||
"files-scs:config/presets/storage/backend/storage-sparql-endpoint.json",
|
||||
|
@ -3,6 +3,7 @@
|
||||
"import": [
|
||||
"files-scs:config/presets/http.json",
|
||||
"files-scs:config/presets/middleware.json",
|
||||
"files-scs:config/presets/static.json",
|
||||
"files-scs:config/presets/cli-params.json"
|
||||
],
|
||||
"@graph": [
|
||||
|
@ -12,6 +12,7 @@
|
||||
"files-scs:config/presets/middleware.json",
|
||||
"files-scs:config/presets/pod-management.json",
|
||||
"files-scs:config/presets/representation-conversion.json",
|
||||
"files-scs:config/presets/static.json",
|
||||
"files-scs:config/presets/storage/backend/storage-memory.json",
|
||||
"files-scs:config/presets/storage-wrapper.json",
|
||||
"files-scs:config/presets/cli-params.json"
|
||||
|
Loading…
x
Reference in New Issue
Block a user