Skip to content

Instantly share code, notes, and snippets.

@mstefaniuk
Last active December 17, 2015 20:59
Show Gist options
  • Save mstefaniuk/5671321 to your computer and use it in GitHub Desktop.
Save mstefaniuk/5671321 to your computer and use it in GitHub Desktop.
== Singup workflow definition ==
var wf = {
name: "Simple signup process",
type: "$process",
document: "signup",
start: {
required: ["email","password"],
to: "pending"
},
states: {
pending: {
type: "task",
assign: "public",
notification: {
type: "email",
to: ["{{document.email}}"],
subject: 'Please confirm your signup',
body: "Confirm link is {{$processing.state.link}}."
},
timeout: {
transition: "timeout",
duration: "3D12H"
},
transitions: {
confirm: "confirmed",
decline: "end",
timeout: "end"
}
},
confirmed: {
type: "store",
db: "_users",
document: {
_id: "org.couchdb.user:{{email}}",
name: "{{email}}"
type: "user",
roles: ["{{hash(email)}}","defaultrole"]
password: "{{password}}"
},
to: "end"
}
},
end: {
document: "delete"
}
};
== Simple review workflow ==
var wf = {
name: "Simple review process",
type: "$process",
document: "review",
start: {
to: "review"
},
states:{
review: {
type: "task",
assign: {
to: "role",
roles: ["reviewer"]
},
transitions: {
accept: {
to: "publish"
},
reject: {
to: "rejected"
}
}
},
publish: {
type: "replicate",
db: "published/documents",
to: "end"
},
rejected: {
type: "task",
assing: "initiator",
transitions: {
givup: "end",
retry: "review"
}
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment