Skip to content

Commit

Permalink
Inherit default handlers to root.
Browse files Browse the repository at this point in the history
  • Loading branch information
RubenVerborgh committed Dec 10, 2018
1 parent 0ad5386 commit de580f6
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/index.js
@@ -1,18 +1,19 @@
import { PathFactory, StringToLDflexHandler } from 'ldflex';
import { PathFactory } from 'ldflex';
import context from './context.json';
import UserPathHandler from './UserPathHandler';
import SubjectPathResolver from './SubjectPathResolver';
import CreateActivityHandler from './CreateActivityHandler';

const { as } = context['@context'];
const { defaultHandlers } = PathFactory;

let rootPath;

// Creates data paths that start from a given subject
const subjectPathFactory = new PathFactory({
context,
handlers: {
...PathFactory.defaultHandlers,
...defaultHandlers,
// Activities on paths
like: new CreateActivityHandler({ type: `${as}Like` }),
dislike: new CreateActivityHandler({ type: `${as}Dislike` }),
Expand All @@ -26,12 +27,9 @@ const subjectPathFactory = new PathFactory({
export default rootPath = new PathFactory({
// Handlers of specific named properties
handlers: {
// Don't get mistaken for an ES6 module by loaders
__esModule: () => undefined,
...defaultHandlers,
// The `user` property starts a path with the current user as subject
user: new UserPathHandler(subjectPathFactory),
// The `resolve` method interprets a string expression as an LDflex path
resolve: new StringToLDflexHandler(),
},
// Handlers of all remaining properties
resolvers: [
Expand Down

0 comments on commit de580f6

Please sign in to comment.