Rise helps you build serverless apis with 1 javascript file. Underneath the hood, rise will create the following resources when deployed via the cli:
This project helps you accomplish:
You can get started by globally npm installing rise-cli:
npm i -g risecli
This will globally install rise-api allowing you to deploy valid riseapps by running the following command in your terminal:
rise-api deploy
To delete an api, run
rise-api remove
Every Rise Api must have a rise.js file at the root of the project. An example rise.js file looks like this:
module.exports = {
api: {
listNotes: () => {
return {
notes: []
}
},
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'
}
]
},
config: {
name: 'myApp'
}
}
rise.js files can have an api
section for actions that require a valid cognito jwt token, and a public
section for actions that do not require an authenticated jwt token. api
and public
have arrays of actions. Config defines the configuration for your app such as name, region, auth, and so on.
Any custom code can be inserted into arrays of action in the form of an arrow function.
When deploying or removing, you can pass the following flags:
rise-api deploy --stage=prod --region=us-east-2
Locally, you can use your own AWS credentials. Check this video out if this is the first time you are setting up AWS credentials.
Inside a CI Pipeline like Github Actions, you can set credentials up by setting environment variables like so:
AWS_ACCESS_KEY_ID=xxx AWS_SECRET_ACCESS_KEY=xxx rise-api deploy
Usually ci platforms have a way to store secrets in the environment. Never hardcode credentials in a github repository. An example of referencing Github Action secrets is as follows:
AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY }}