A serverless function engine for Node.js, built on top of Express.js and Socket.IO.
BFast Function provides a powerful and flexible way to build and deploy serverless functions. It's designed to be easy to use, with a simple and intuitive API.
- Easy to use: A simple and intuitive API for creating and deploying serverless functions.
- Flexible: Supports both HTTP and Socket.IO functions.
- Scalable: Built on top of Express.js and Socket.IO, which are known for their scalability.
- Extensible: Can be easily extended with custom middleware and plugins.
- Open-source: BFast Function is open-source and available on GitHub.
There are several ways to get started with BFast Function:
1. From npm:
The easiest way to get started is to install BFast Function from npm:
npm install bfast-function
2. From Git:
You can also clone the BFast Function repository from GitHub:
git clone https://github.com/bfast-cloud/bfast-function.git
Then, install the dependencies:
cd bfast-function
npm install
3. From a tarball:
You can also download a tarball of the BFast Function repository from the releases page.
Then, extract the tarball and install the dependencies:
tar -xvf bfast-function-*.tar.gz
cd bfast-function-*
npm install
-
Create a functions folder:
mkdir functions
-
Create a function file (e.g.,
example.js
):const bfast = require('bfast'); exports.myHttpFunction = bfast.functions().onHttpRequest('/hello', (request, response) => { response.status(200).send('Hello, World!'); }); exports.mySocketFunction = bfast.functions().onSocketIO('echo', (request, response) => { response.emit('echo', request.body); });
-
Start the BFast Function engine:
Create an
index.mjs
file in your root workspace and start the Faas server:import {start} from 'bfast-function'; start({ port: '3000', functionsConfig: { functionsDirPath: './functions', } }).catch(console.log);
Then, start the server:
node index.mjs
You can also run the BFast Function engine in a Docker container.
1. Build the Docker image:
docker build -t bfast-function .
2. Run the Docker container:
docker run -p 3000:3000 bfast-function
This will start the BFast Function engine and expose it on port 3000.
You can also mount a local functions folder to the container:
docker run -p 3000:3000 -v $(pwd)/functions:/app/functions bfast-function
This will mount the functions
folder in your current working directory to the /app/functions
folder in the container.
The bfast.json
file is a JSON file that contains configurations for the BFast Function engine.
{
"ignore": ["**/node_modules/**"]
}
Key | Type | Description |
---|---|---|
ignore |
Array |
An array of glob patterns to ignore when loading functions. |
For a full list of available options and APIs, please see the API Reference.
We welcome contributions to BFast Function! If you have an idea for a new feature or have found a bug, please open an issue on our GitHub repository.
BFast Function is licensed under the MIT License.