Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
1,439 additions
and
101 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import yargs from 'yargs'; | ||
import { | ||
AcceptPreferenceParser, | ||
AuthenticatedLdpHandler, | ||
CompositeAsyncHandler, | ||
ExpressHttpServer, | ||
Operation, | ||
ResponseDescription, | ||
SimpleAuthorizer, | ||
SimpleBodyParser, | ||
SimpleCredentialsExtractor, | ||
SimpleDeleteOperationHandler, | ||
SimpleGetOperationHandler, | ||
SimplePermissionsExtractor, | ||
SimplePostOperationHandler, | ||
SimpleRequestParser, | ||
SimpleResourceStore, | ||
SimpleResponseWriter, | ||
SimpleTargetExtractor, | ||
} from '..'; | ||
|
||
const { argv } = yargs | ||
.usage('node ./bin/server.js [args]') | ||
.options({ | ||
port: { type: 'number', alias: 'p', default: 3000 }, | ||
}) | ||
.help(); | ||
|
||
const { port } = argv; | ||
|
||
// This is instead of the dependency injection that still needs to be added | ||
const requestParser = new SimpleRequestParser({ | ||
targetExtractor: new SimpleTargetExtractor(), | ||
preferenceParser: new AcceptPreferenceParser(), | ||
bodyParser: new SimpleBodyParser(), | ||
}); | ||
|
||
const credentialsExtractor = new SimpleCredentialsExtractor(); | ||
const permissionsExtractor = new SimplePermissionsExtractor(); | ||
const authorizer = new SimpleAuthorizer(); | ||
|
||
// Will have to see how to best handle this | ||
const store = new SimpleResourceStore(`http://localhost:${port}/`); | ||
const operationHandler = new CompositeAsyncHandler<Operation, ResponseDescription>([ | ||
new SimpleGetOperationHandler(store), | ||
new SimplePostOperationHandler(store), | ||
new SimpleDeleteOperationHandler(store), | ||
]); | ||
|
||
const responseWriter = new SimpleResponseWriter(); | ||
|
||
const httpHandler = new AuthenticatedLdpHandler({ | ||
requestParser, | ||
credentialsExtractor, | ||
permissionsExtractor, | ||
authorizer, | ||
operationHandler, | ||
responseWriter, | ||
}); | ||
|
||
const httpServer = new ExpressHttpServer(httpHandler); | ||
|
||
httpServer.listen(port); | ||
|
||
process.stdout.write(`Running at http://localhost:${port}/\n`); |
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,76 @@ | ||
// Authentication | ||
export * from './src/authentication/Credentials'; | ||
export * from './src/authentication/CredentialsExtractor'; | ||
export * from './src/authentication/SimpleCredentialsExtractor'; | ||
|
||
// Authorization | ||
export * from './src/authorization/Authorizer'; | ||
export * from './src/authorization/SimpleAuthorizer'; | ||
|
||
// LDP/HTTP | ||
export * from './src/ldp/http/AcceptPreferenceParser'; | ||
export * from './src/ldp/http/BodyParser'; | ||
export * from './src/ldp/http/Patch'; | ||
export * from './src/ldp/http/PreferenceParser'; | ||
export * from './src/ldp/http/RequestParser'; | ||
export * from './src/ldp/http/ResponseWriter'; | ||
export * from './src/ldp/http/SimpleBodyParser'; | ||
export * from './src/ldp/http/SimpleRequestParser'; | ||
export * from './src/ldp/http/SimpleResponseWriter'; | ||
export * from './src/ldp/http/SimpleTargetExtractor'; | ||
export * from './src/ldp/http/TargetExtractor'; | ||
|
||
// LDP/Operations | ||
export * from './src/ldp/operations/Operation'; | ||
export * from './src/ldp/operations/OperationHandler'; | ||
export * from './src/ldp/operations/ResponseDescription'; | ||
export * from './src/ldp/operations/SimpleDeleteOperationHandler'; | ||
export * from './src/ldp/operations/SimpleGetOperationHandler'; | ||
export * from './src/ldp/operations/SimplePostOperationHandler'; | ||
|
||
// LDP/Permissions | ||
export * from './src/ldp/permissions/PermissionSet'; | ||
export * from './src/ldp/permissions/PermissionsExtractor'; | ||
export * from './src/ldp/permissions/SimplePermissionsExtractor'; | ||
|
||
// LDP/Representation | ||
export * from './src/ldp/representation/BinaryRepresentation'; | ||
export * from './src/ldp/representation/NamedRepresentation'; | ||
export * from './src/ldp/representation/QuadRepresentation'; | ||
export * from './src/ldp/representation/Representation'; | ||
export * from './src/ldp/representation/RepresentationMetadata'; | ||
export * from './src/ldp/representation/RepresentationPreference'; | ||
export * from './src/ldp/representation/RepresentationPreferences'; | ||
export * from './src/ldp/representation/ResourceIdentifier'; | ||
|
||
// LDP | ||
export * from './src/ldp/AuthenticatedLdpHandler'; | ||
|
||
// Server | ||
export * from './src/server/ExpressHttpServer'; | ||
export * from './src/server/HttpHandler'; | ||
export * from './src/server/HttpRequest'; | ||
export * from './src/server/HttpResponse'; | ||
|
||
// Storage | ||
export * from './src/storage/AtomicResourceStore'; | ||
export * from './src/storage/Conditions'; | ||
export * from './src/storage/Lock'; | ||
export * from './src/storage/RepresentationConverter'; | ||
export * from './src/storage/ResourceLocker'; | ||
export * from './src/storage/ResourceMapper'; | ||
export * from './src/storage/ResourceStore'; | ||
export * from './src/storage/SimpleResourceStore'; | ||
|
||
// Util/Errors | ||
export * from './src/util/errors/HttpError'; | ||
export * from './src/util/errors/NotFoundHttpError'; | ||
export * from './src/util/errors/UnsupportedHttpError'; | ||
export * from './src/util/errors/UnsupportedMediaTypeHttpError'; | ||
|
||
// Util | ||
export * from './src/util/AcceptParser'; | ||
export * from './src/util/AsyncHandler'; | ||
export * from './src/util/CompositeAsyncHandler'; | ||
export * from './src/util/TypedReadable'; | ||
export * from './src/util/Util'; |
Oops, something went wrong.