Skip to content

Commit

Permalink
feat(message): modify message: content -> contents
Browse files Browse the repository at this point in the history
  • Loading branch information
mefellows committed May 8, 2018
1 parent 0add369 commit 38e57a8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/dsl/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface Message {
providerStates?: [{ name: string }];
description?: string;
metadata?: Metadata;
content: any;
contents: any;
}

// Consumer message handler
Expand Down
8 changes: 4 additions & 4 deletions src/messageConsumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class MessageConsumer {
if (isEmpty(content)) {
throw new Error("You must provide a valid JSON document or primitive for the Message.");
}
this.state.content = content;
this.state.contents = content;

return this;
}
Expand Down Expand Up @@ -143,7 +143,7 @@ export class MessageConsumer {
}

const isMessage = (x: Message | any): x is Message => {
return (x as Message).content !== undefined;
return (x as Message).contents !== undefined;
};

// TODO: create basic adapters for API handlers, e.g.
Expand All @@ -152,7 +152,7 @@ const isMessage = (x: Message | any): x is Message => {
// a wrapped function that accepts a Message and returns a Promise
export function synchronousBodyHandler(handler: (body: any) => any): MessageHandler {
return (m: Message): Promise<any> => {
const body = m.content;
const body = m.contents;

return new Promise((resolve, reject) => {
try {
Expand All @@ -169,5 +169,5 @@ export function synchronousBodyHandler(handler: (body: any) => any): MessageHand
// a wrapped function that accepts a Message and returns a Promise
// TODO: move this into its own package and re-export?
export function asynchronousBodyHandler(handler: (body: any) => Promise<any>): MessageHandler {
return (m: Message) => handler(m.content);
return (m: Message) => handler(m.contents);
}
2 changes: 1 addition & 1 deletion src/messageProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class MessageProvider {
.setupStates(message)
.then(() => this.findHandler(message))
.then((handler) => handler(message))
.then((o) => res.json({ content: o }))
.then((o) => res.json({ contents: o }))
.catch((e) => res.status(500).send(e));
};
}
Expand Down

0 comments on commit 38e57a8

Please sign in to comment.