Skip to content

Commit

Permalink
Merge branch 'solid-master' into sparql-resource-store
Browse files Browse the repository at this point in the history
  • Loading branch information
smessie committed Aug 28, 2020
2 parents 3b836cc + 267b3dc commit e013eb7
Show file tree
Hide file tree
Showing 84 changed files with 1,118 additions and 382 deletions.
22 changes: 22 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,22 @@ module.exports = {
},
plugins: [
'eslint-plugin-tsdoc',
'eslint-plugin-import',
'eslint-plugin-unused-imports'
],
extends: [
'es/node',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript'
],
settings: {
'import/resolver': {
'typescript': {
'alwaysTryTypes': true // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/rdf-js`
},
}
},
rules: {
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-unnecessary-condition': 'off', // problems with optional parameters
Expand All @@ -24,5 +36,15 @@ module.exports = {
'padding-line-between-statements': 'off',
'tsdoc/syntax': 'error',
'prefer-named-capture-group': 'off',

// Import
'sort-imports': 'off', // Disabled in favor of eslint-plugin-import
'import/order': ['error', {
alphabetize: {
order: 'asc',
caseInsensitive: true
}
}],
'unused-imports/no-unused-imports-ts': 'error',
},
};
25 changes: 13 additions & 12 deletions bin/server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env node
import { InteractionController } from '../src/util/InteractionController';
import { ResourceStoreController } from '../src/util/ResourceStoreController';
import yargs from 'yargs';
import {
AcceptPreferenceParser,
Expand All @@ -13,6 +11,7 @@ import {
QuadToTurtleConverter,
Representation,
RepresentationConvertingStore,
RuntimeConfig,
Setup,
SimpleAclAuthorizer,
SimpleBodyParser,
Expand All @@ -34,19 +33,19 @@ import {
TurtleToQuadConverter,
UrlContainerManager,
} from '..';
import { InteractionController } from '../src/util/InteractionController';
import { ResourceStoreController } from '../src/util/ResourceStoreController';

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(),
Expand All @@ -64,7 +63,7 @@ const permissionsExtractor = new CompositeAsyncHandler([
]);

// Will have to see how to best handle this
const store = new SimpleResourceStore(new ResourceStoreController(base, new InteractionController()));
const store = new SimpleResourceStore(new ResourceStoreController(runtimeConfig, new InteractionController()));
const converter = new CompositeAsyncHandler([
new TurtleToQuadConverter(),
new QuadToTurtleConverter(),
Expand All @@ -75,7 +74,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([
Expand All @@ -99,9 +98,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);
Expand Down
1 change: 1 addition & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export * from './src/authorization/SimpleAuthorizer';
export * from './src/authorization/SimpleExtensionAclManager';

// Init
export * from './src/init/RuntimeConfig';
export * from './src/init/Setup';

// LDP/HTTP
Expand Down

0 comments on commit e013eb7

Please sign in to comment.