https://github.com/fahamutech/bfast-functions
Cloud function node run-time for BFast::Cloud platform
https://github.com/fahamutech/bfast-functions
bfastfaas cloudfunction faas function serveless
Last synced: 5 months ago
JSON representation
Cloud function node run-time for BFast::Cloud platform
- Host: GitHub
- URL: https://github.com/fahamutech/bfast-functions
- Owner: fahamutech
- License: mit
- Created: 2019-08-12T07:10:20.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-06-20T09:17:37.000Z (almost 3 years ago)
- Last Synced: 2025-01-14T07:34:28.286Z (over 1 year ago)
- Topics: bfastfaas, cloudfunction, faas, function, serveless
- Language: JavaScript
- Homepage:
- Size: 979 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# BFast Function
[](https://badge.fury.io/js/bfast-function)
[](https://travis-ci.org/bfast-cloud/bfast-function)
[](https://opensource.org/licenses/MIT)
[](https://www.codacy.com/gh/bfast-cloud/bfast-function/dashboard?utm_source=github.com&utm_medium=referral&utm_content=bfast-cloud/bfast-function&utm_campaign=Badge_Grade)

**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.
## Features
* **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.
## Getting Started
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:
```bash
npm install bfast-function
```
**2. From Git:**
You can also clone the BFast Function repository from GitHub:
```bash
git clone https://github.com/bfast-cloud/bfast-function.git
```
Then, install the dependencies:
```bash
cd bfast-function
npm install
```
**3. From a tarball:**
You can also download a tarball of the BFast Function repository from the [releases page](https://github.com/bfast-cloud/bfast-function/releases).
Then, extract the tarball and install the dependencies:
```bash
tar -xvf bfast-function-*.tar.gz
cd bfast-function-*
npm install
```
## Usage
1. **Create a functions folder:**
```bash
mkdir functions
```
2. **Create a function file (e.g., `example.js`):**
```javascript
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);
});
```
3. **Start the BFast Function engine:**
Create an `index.mjs` file in your root workspace and start the Faas server:
```javascript
import {start} from 'bfast-function';
start({
port: '3000',
functionsConfig: {
functionsDirPath: './functions',
}
}).catch(console.log);
```
Then, start the server:
```bash
node index.mjs
```
## Docker
You can also run the BFast Function engine in a Docker container.
**1. Build the Docker image:**
```bash
docker build -t bfast-function .
```
**2. Run the Docker container:**
```bash
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:
```bash
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.
## Configuration
The `bfast.json` file is a JSON file that contains configurations for the BFast Function engine.
```json
{
"ignore": ["**/node_modules/**"]
}
```
| Key | Type | Description |
| -------- | ------- | ----------------------------------------- |
| `ignore` | `Array` | An array of glob patterns to ignore when loading functions. |
## API Reference
For a full list of available options and APIs, please see the [API Reference](./src/models/options.mjs).
## Contributing
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](https://github.com/bfast-cloud/bfast-function/issues).
## License
BFast Function is licensed under the [MIT License](./LICENSE).