atomable runtime
This is the runtime for the atomable serverless microservices framework. Our goal is to make your serverless life easier!
The best way to use this runtime is by using our insanely powerful atomable cli.
If using command line tools is not your thing, well we still got your covered! Check out the code examples below to get started!
Documentation
Source code | fork | pull request | issues
https://github.com/atomable/runtime
Installation
npm
npm install atomable-runtime
yarn
yarn add atomable-runtime
Importing
const runtime = require('atomable-runtime');
import { register, handle } from 'atomable-runtime';
Usage
To use the runtime you need to create an AWS lambda that will be the main entry point of your project. Once this is done, you never have to think about configuring more lambdas.
handler.js
const runtime = require('atomable-runtime');
/**
* () registers the function and the
* callback to handle the aws event
*/
(() => {
const protonHandler = require('./proton/proton.js').proton;
const protonConf = { name: 'proton', https: { path: 'proton', method: 'get', parameters: [{ in: 'query', name: 'firstName' }, { in: 'query', name: 'lastName', required: false }] }};
runtime.register(protonHandler, protonConf);
const electronHandler = require('./electron/electron.js').electron;
const electronConf = { name: 'electron', https: { path: 'electron', method: 'post', parameters: [{ in: 'body', name: '*' }, { in: 'headers', name: 'authorization' }] }};
runtime.register(electronHandler, electronConf);
})();
/**
* handler() handles aws lambda events
*/
export const handler = runtime.handle;
proton.js
// firstName is guaranteed not to be null since it is required by default
// since we configured lastName to not be required, it may be undefined here
module.exports.proton = (firstName, lastName) {
// you can also return a promise, we will handle the result correctly.
return { statusCode : 200, body: `Hello ${firstName} ${lastName}` };
};
Tests
To run the tests, simply checkout the code and run npm test
.
Contributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request!
If you find issues with the runtime, log them here in our issues.
If you feel like contributing, one thing you have to know is we hate classes, the keyword new
and we like to use our Monad library, lift.js, as often as possible :)
Roadmap
Here is a list of things we want to do in this project, feel free to help us out!
- Add parameter validators (stringNotEmpty, stringLength, intBetween, etc. That sort of thing...)
- Better error messages when things are not configured as they should.
- Support multiple cloud providers
Links
License
MIT