Here is an example rise file:
module.exports = {
public: {
isStoreOpen: () => {
return {
open: true
}
},
isSpecificStoreOpen: [
{
type: 'input',
storeId: 'string'
},
(input) => {
return {
open: input.storeId === '100'
}
}
],
listNotes: [
{
type: 'db',
action: 'list',
input: {
pk: 'notes',
sk: 'note_'
}
},
{
type: 'output',
id: 'string',
content: 'string'
}
]
},
api: {
listNotes: [
{
type: 'db',
action: 'list',
input: {
pk: 'notes',
sk: 'note_'
}
},
{
type: 'output',
id: 'string',
content: 'string'
}
],
makeNote: [
{
type: 'input',
content: 'string'
},
(input) => {
// some custom logic
return input
},
{
type: 'db',
action: 'set',
input: {
pk: 'notes',
sk: '@id',
content: '$content'
}
},
{
type: 'output',
id: 'string',
content: 'string'
}
]
},
events: {
handleUserAdded: [
{
type: 'event-source',
source: 'userService',
event: 'userAdded'
},
(input) => {
// logic for handling it...
}
]
}
config: {
name: 'myApp'
}
}
Here we see 4 top level properties:
Each rise project when deployed will have 1 endpoint that receives post requests. This is inspired by GraphQL, and instead relies on concepts like Queries and Mutations rather than http verbs such as GET, POST, PUT, DELETE.
Every property in the public
or api
object can be posted to from a frontend client, here is an example:
const data = {
action: 'makeNote',
input: {
content: 'my note'
}
}
const result = await document.fetch(URL, {
method: 'POST',
body: JSON.stringify(data)
})
Some actions will be get or list calls, some will involve changing data. Rise doesnt distinguish between the 2, all you need to do is specify which action you want to make in the body of your POST call against the deployed url.
Anyone can hit your rise api endpoint with a public action. Api represnts actions that require a valid jwt token set to the authorization
header
Events are the same as public
and api
in that it also contains actions. The main difference is that it is triggered from an event bridge event from within your AWS accountrather than an http call, and nothing is waiting for the return value of these actions. The other main difference is that these actions must have an event-source
step in order to define what event this action is listening for.
The root rise.js file requires a config to be defined.
module.exports = {
public: ...,
api: ...,
events: ...,
config: {
name: 'blue-app', // required
}
}