async-fire
v0.0.0-rc3
Published
Tiny framework bringing async ES6 functions to Firebase
Downloads
4
Readme
async-fire
Tiny framework bringing async ES6 functions to Firebase
Features
- Agile designed for development and production usage
- Lightweight the entire codebase is under 100 LOC
- ES6 support with zero additional configuration (use
async/await
in your functions) - Testable easily test your functions with existing HTTP testing frameworks
- Fast the added overhead by transpiling async functions is minimal
Usage
First, initialize a Firebase project and select functions
:
$ firebase init
Then install the framework in the created ./functions
directory:
$ cd functions
$ npm install --save async-fire
Next, add a start
script to the generated package.json
:
{
"main": "index.js",
"scripts": {
"start": "async-fire"
}
}
Now create replace the index.js
file Firebase created with your server bootstraping code:
const createServer = require('async-fire')
module.exports = createServer({
// pass any custom options you may need
root: __dirname
})
Finally, create your functions. By default, async-fire
looks in ./routes
for your functions, but you may put them anywhere.
$ mkdir routes
$ touch routes/helloWorld.js
Your helloWorld
function could look something like:
module.exports = async (req, res) => {
const color = await getFavoriteColor()
res.send(`Your favorite color is ${color}`)
}
Once you've created your routes, start the server with:
$ npm start
Inspiration
This project was inspired heavily by Zeit's micro
framework. Many thanks to them for the concept & ideas.
License
MIT