Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork68
Backend server API handling user mgmt, database, storage and real-time component
License
staticbackendhq/core
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
StaticBackend is a simple backend server API thathelps you create web applications. It handles most of the building blocks you'llneed on the backend.
- Authentication (docs →)
- Account->users management (docs →)
- Database CRUD, queries and full-text search (docs →)
- Realtime/Websockets (docs →)
- File storage (docs →)
- server-side functions (docs →)
- Schedule jobs
- Send mails/sms (docs →)
- Caching (docs →)
- Handle forms (docs →)
- Resize images & convert URL to PDF (docs →)
You'll want to install different pieces depending on what you want to build.Here's what you can install:
OurCLI includes a fully functionaldevelopment server. You don't need to install anything else.
$ npm install -g @staticbackend/cli
You mayinstall the CLI manually aswell.
This will install as thebackend program. Start the development server with:
$ backend server
This command creates a new application and an admin user for you. You'llreceive a PublicKey and a RootToken.
All HTTP request to the API requires a public key. The root token allows youto sign in to the dashboard for this application as the owner.
Add the library to your dependencies:
$ npm install @staticbackend/js
Inside your module:
import{Backend}from"@staticbackend/js";constbkn=newBackend("dev_memory_pk","dev");
dev_memory_pk is the default local development public key anddev is thedefault region / host for the instance you're targetting.
You may also include the library inside a<script tag if you're not usinga module system:
<scriptsrc="https://cdn.jsdelivr.net/npm/@staticbackend/js@1.5.0/dist/backend.min.js"></script><script>constbkn=newsb.Backend("dev_memory_pk","dev");</script>
We've pre-built backend client libraries you may use directly:
Node:
$ npm install @staticbackend/backend
Go:
$ go get github.com/staticbackendhq/backend-go
View the Go package documentation
Python:
$ pip install staticbackend
You can import a Go package directly into your Go program and build yourapplication with the same building blocks without hosting the API separately.
$ go get github.com/staticbackendhq/core/backend
You may build web and mobile applications using StaticBackend as your mainbackend API.
StaticBackend is a multi-tenant platform allowing you to host multiple isolatedapplications.
You need an instance of the backend API running via the CLI for localdevelopment or running as a normal process with required dependencies.
You create your first application before you can start.
Using the CLI:
$ backend server
Using the source code:
$ git clone https://github.com/staticbackendhq/core$cd core$ cp .local.env .env$ make startVisithttp://localhost:8099 and create an application.
Note that the Nodejs client library has the same API / function names as theJavaScript library.
import{Backend}from"@staticbackend/js";constbkn=newBackend("dev_memory_pk","dev");lettoken="";login=async()=>{constres=awaitbkn.register("email@test.com","password");if(!res.ok){console.error(res.content);return;}token=res.content;createTask();}createTask=async()=>{consttask={desc:"Do something for XYZ",done:false};constres=bkn.create(token,"tasks",task);if(!res.ok){console.error(res.content);return;}console.log(res.content);}
package mainimport ("fmt""github.com/staticbackendhq/backend-go")funcmain() {backend.PublicKey="dev_memory_pk"backend.Region="dev"token,err:=backend.Login("admin@dev.com","devpw1234")// no err handling in exampletask:=new(struct{IDstring`json:"id"`AccountIDstring`json:"accountId"`Titlestring`json:"title"`Donebool`json:"done"`})task.Title="A todo item"err=backend.Create(token,"tasks",task,&task)// task.ID and task.AccountID would be filled with proper values}
// using the cache & pub/subbackend.Cache.Set("key","value")msg:= model.Command{Type:"chan_out",Channel:"#lobby",Data:"hello world"}backend.Cache.Publish(msg)// use the generic Collection for strongly-typed CRUD and queryingtypeTaskstruct {IDstring`json:"id"`Titlestring`json:"title"`}// auth is the currently authenticated user performing the action.// base is the current tenant's database to execute action// "tasks" is the collection nametasks:=backend.Collection[Task](auth,base,"tasks")newTask,err:=tasks.Create(Task{Title:"testing"})// newTask.ID is filled with the unique ID of the created task in DB
View afull example in the doc.
We're trying to have the best experience possible reading our documentation.
Please help us improve if you have any feedback.
- Documentation with code samples for client libraries and CURL
- Go client library package
- Go importable package
- Self-host guide
- Install the CLI
Examples:
- To-do list example
- Realtime collaboration
- Live chat using server-side function & real-time component
- Jamstack Bostom talk
To deploy StaticBackend you'll need the following:
- Either PostgreSQL or MongoDB
- Redis
StaticBackend is a single file binary you can run as asystemd daemon.
Here's some quick way to deploy an instance.
If you have Docker and Docker Compose ready, here's how to run StaticBackend:
$ git clone https://github.com/staticbackendhq/core$cd core$ cp .demo.env .env$ docker build. -t staticbackend:latest$ docker-compose -f docker-compose-demo.yml up
Open a browser athttp://localhost:8099 to createyour first application.
For production, you'll want to configure environment variables found in.envfile.
You may use the following channels to get help and support.
- Discord: for any help and joining the conversation.
- GitHub issues: To report bugs / contributing code.
- GitHub Discussions: For ideas, feature requests and general discussions.
If you have any feedback (good or bad) we'd be more than happy to talk. Pleaseuse theDiscussions tab.
Same for contributing. The easiest is to get in touch first. We're workingto make it easier to contribute code. If you'd like to work on somethingprecise let us know.
Here are videos made specifically for people wanting to contribute:
Check thecontributing file for details.
If you're looking to help the project, here are multiple ways:
- Use it and share your experiences.
- Sponsor the development via GitHub sponsors.
- Spread the words, a tweet, a blog post, any mention is helpful.
- Join theDiscord server.
About
Backend server API handling user mgmt, database, storage and real-time component
Topics
Resources
License
Code of conduct
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Contributors9
Uh oh!
There was an error while loading.Please reload this page.
