{"id":15011145,"url":"https://github.com/fahamutech/bfast-tools","last_synced_at":"2025-04-09T19:04:28.322Z","repository":{"id":40793178,"uuid":"219109867","full_name":"fahamutech/bfast-tools","owner":"fahamutech","description":"CLI tools for BFast::Cloud platform. https://www.npmjs.com/package/bfast-tools","archived":false,"fork":false,"pushed_at":"2024-12-31T06:33:29.000Z","size":3537,"stargazers_count":6,"open_issues_count":6,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-23T21:01:37.806Z","etag":null,"topics":["bfast","bfast-ee-cloud","cli","cloud","faas","faas-cli","faas-platform","functions","functions-as-a-service","nodejs","nodejs-api","nodejs-express","nodeserver"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fahamutech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-11-02T05:47:19.000Z","updated_at":"2024-12-31T06:33:32.000Z","dependencies_parsed_at":"2025-02-15T15:41:36.212Z","dependency_job_id":null,"html_url":"https://github.com/fahamutech/bfast-tools","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fahamutech%2Fbfast-tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fahamutech%2Fbfast-tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fahamutech%2Fbfast-tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fahamutech%2Fbfast-tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fahamutech","download_url":"https://codeload.github.com/fahamutech/bfast-tools/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247623008,"owners_count":20968574,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bfast","bfast-ee-cloud","cli","cloud","faas","faas-cli","faas-platform","functions","functions-as-a-service","nodejs","nodejs-api","nodejs-express","nodeserver"],"created_at":"2024-09-24T19:39:15.198Z","updated_at":"2025-04-09T19:04:28.295Z","avatar_url":"https://github.com/fahamutech.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bfast-tools\nCLI tools for manage your project ( s ) in [BFast Cloud](https://bfast.mraba.co.tz).\n\n## Pre request\n\n* Download and install [NodeJs](https://nodejs.org/en/download/) in your local PC. If you have it your good to go.\n\n## Get stated\nInstall package from npm by run for linux: `sudo npm install -g bfast-tools`. For windows run: `npm install -g bfast-tools`\n\n## BFast::Cloud Projects\n\nYou use this sub command to manage your remote bfast projects. `bfast cloud` for more commands.\n\n### Create a new project\n\nRun the following command to create a new project\n```shell script\njosh@xps:~/Desktop$ bfast cloud create\n```\n\n### List all projects\n\nRun the following command to list all projects exist to your bfast cloud account\n```shell script\njosh@xps:~/Desktop$ bfast cloud list\n```\n\n### Delete project\n\nRun the following command to delete exist project to your bfast cloud account\n```shell script\njosh@xps:~/Desktop$ bfast cloud delete\n```\n\n### Add a member to you project\n\nRun the following command to add exist user of bfast to your bfast cloud account\n```shell script\njosh@xps:~/Desktop$ bfast cloud add-member\n```\n\n## BFast::Cloud Database\n\nYou can manage your database instance using this sub command `bfast database`.\n\n### Switch dashboard on\n\nYou can switch a dashboard on for data browser.\n```shell script\njosh@xps:~/Desktop$ bfast database dashboard-on\n```\n\n### Switch dashboard off\n\nYou can switch a dashboard off for data browser.\n```shell script\njosh@xps:~/Desktop$ bfast database dashboard-off\n```\n\n### Open Database Playground\n\nYou must add manually a specif collection/table/domain to a realtime engine to subscribe to its events.\n```shell script\njosh@xps:~/Desktop$ bfast database playground\n```\n\n## BFast::Cloud Functions\n\nWrite your system functions with zero effort. Sub command to manage your functions is `bfast functions` \nor `bfast fs` \n\n### Create a workspace\n\nrun `bfast functions create \u003cprojectName\u003e`. For example. \n```shell script\njosh@xps:~/Desktop$ bfast functions create bfastDemoFaas\n```\n\nafter that navigate inside your project directory. \n```shell script\njosh@xps:~/Desktop$ cd bfastDemoFaas\njosh@xps:~/Desktop/bfastDemoFaas$ \n```\n\nafter that install dependencies \n```shell script\njosh@xps:~/Desktop/bfastDemoFaas$ npm install\n```\n\nInside your workspace folder you will find a following folder structure\n\n```\n.\n|__ functions\n|   |__ .ignore\n|   |__ index.mjs\n|   |__ package.json\n|__ bfast.json\n```\n\nOpen `index.mjs` in your favorite text editor. You will see a commented  example.\n\nFile `bfast.json` contain information of your BFast::Cloud project.\n\n### Write your custom functions\n\nYou use [bfastnode](https://www.npmjs.com/package/bfastnode) package from npm to write your functions \n\nChoose text editor of your choice like VSCode or WebStorm. You can write your function is different ways. \n\nSingle callback function\n\n```javascript\nconst {BFast} = require('bfastnode');\n\nexports.mySingleFunctionName = BFast.functions().onHttpRequest('/mySingleFunctionName',(request, response)=\u003e{\n        // your business logic\n        response.send('your response');\n    }\n);\n```\n\nMany callback in array. Good if your apply a middleware before execute finally logic. Refer to ExpressJS Middlware\n```javascript\nconst {BFast} = require('bfastnode');\n\nexports.myArrayFunctionName = BFast.funtion().onHttpRequest('/myArrayFunctionName', [\n        (request, response, next)=\u003e{\n            // middleware logic\n            request.query.from1 =  'query added in first callback';\n            next();\n        },\n        (request, response)=\u003e{\n            // your business logic\n            response.send(request.query.from1);\n        }\n    ]\n);\n```\n\nMount express router. Your can use Express Router to manage complex routing. First run `npm install express` inside functions folder to add express module\n\n```javascript\nconst express = require('express');\nconst router = express.Router();\nconst {BFast} = require('bfastnode');\n\nrouter.get('/', function (request, response) {\n    // your logic\n    response.send('get users');\n});\n\nrouter.post('/user', function (request, response) {\n    // your logic\n    response.send('User saved');\n})\n\nexports.functionNameUsingRouter = BFast.function().onHttpRequest('/functionNameUsingRouter',router);\n```\n\nYou can mount an express app too!. First run `npm install express` inside functions folder to add express module\n\n```javascript\nconst express = require('express');\nconst app = new express();\nconst {BFast} = require('bfastnode');\n\napp.get('/', function (request, response) {\n    // your logic\n    response.send('get users');\n});\n\napp.post('/user', function (request, response) {\n    // your logic\n    response.send('User saved');\n})\n\nexports.functionNameUsingExpressApp = BFast.function().onHttpRequest('/functionNameUsingExpressApp', app);\n```\n\n### Serve functions locally\n\nIn your current project folder, run following script\n\n* Start a dev server ( auto restart when you change or edit a function )\n```shell script\njosh@xps:~/Desktop/bfastDemoFaas$ bfast functions serve --port 3000\n```\n\nOr\n\n```shell script\njosh@xps:~/Desktop/bfastDemoFaas$ npm start\n```\n\n* Start a static server which do not auto restart when you change or edit files in working directory\n```shell script\njosh@xps:~/Desktop/bfastDemoFaas$ bfast functions serve --port 3000 --static\n```\n\nDefault port is 3000, but you can change it by change a value of `port` option.\n\nWhen everything is ok, you will see `BfastFunctions Engine Listening on 3000` or any port number you specify.\n\n### Use functions you write\n\n* If you use `path` field to specify address of your function you will use that path\n* If your do not use `path` field the your function will be available in this format \n`\u003chostname\u003e/function/\u003cfunctionName\u003e`. For example by using curl\n```shell script\njosh@xps:~$ curl http://localhost:3000/functions/functionName\n```\nOr\n```shell script\njosh@xps:~$ curl http://localhost:3000/\u003cpath\u003e\n```\n\nOr open your browser and enter `http://localhost:3000/functions/mySingleFunctionName` if you use `path` field \nin your browser put this address http://localhost:3000/pathYouUse\n\nReplace `mySingleFunctionName` with a function name you want to call.\n\n\n## Cloud Functions Deployment\n\nYou can deploy your functions to bfast cloud and host your server-less functions across our network.\n\n#### Open Account\nTo publish your functions you must have a bfast cloud functions open one here [BFAST::CLOUD](http://bfast.mraba.co.tz). \nAfter open account now you create your new project and you go to next step\n\n#### Login from your computer\nLogin from your computer by run.\n```shell script\njosh@xps:~/Desktop/bfastDemoFaas$ bfast user login\n```\n\n#### Link your local project to remote bfast project\nRun their following in your bfast local project folder\n```shell script\njosh@xps:~/Desktop/bfastDemoFaas$ bfast cloud link\n```\n\n#### Set git environments\n\nWe use git to deploy your functions to bfast cloud function instance(s). Run thr following to set up git environments.\n```shell script\njosh@xps:~/Desktop/bfastDemoFaas$ bfast functions config\n```\n\n#### To publish your functions\n* Make sure you push all your production functions to `master` branch\n* Then run\n```shell script\njosh@xps:~/Desktop/bfastDemoFaas$ bfast functions deploy\n```\n\n*NOTE* You must push your project to a git repository you specify. BFast will look from master branch for functions.\n\n#### Continuous Integration\n\n* Generate token to use it for your favorite CI tool\n\n```shell script\njosh@xps:~/Desktop/bfastDemoFaas$ bfast user login:ci --username \u003cPUT_EMAIL_YOU_USE_TO_OPEN_BFAST_ACCOUNT\u003e\n```\n\nYou can use token generated and example given to set your continuous integration \nenvironment.\n\n**NOTE**\n\nIn CI mode you must set projectId manually to deploy your functions your can find projectId from your project console \nin bfast cloud account\n\n\n## Notes To Take\n\n* In this documentation we use port 3000, if you use a different port to run your functions replace 3000 with a port number you use in all examples found in this document to be relevant.\n\n* You can create a javascript file anywhere inside functions folder or even create a sub folder and put your functions as illustrated above and bfast-tools package will discover your functions\n\n## Help\n\nContact FahamuTech Team @Joshua Mshana ( mama27j@gmail.com ) or leave an issue here at github\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffahamutech%2Fbfast-tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffahamutech%2Fbfast-tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffahamutech%2Fbfast-tools/lists"}