{"id":13602149,"url":"https://github.com/mrusme/xbsapi","last_synced_at":"2025-04-13T02:13:17.372Z","repository":{"id":75669328,"uuid":"577113268","full_name":"mrusme/xbsapi","owner":"mrusme","description":"Alternative xBrowserSync API that is a single binary and supports SQLite3, PostgreSQL and MySQL","archived":false,"fork":false,"pushed_at":"2025-03-14T13:20:25.000Z","size":272,"stargazers_count":45,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-13T02:13:01.262Z","etag":null,"topics":["api","api-rest","bookmark","bookmark-manager","bookmarks","bookmarks-manager","rest-api","sync","xbrowsersync","xbrowsersync-api","xbs","xbsapi"],"latest_commit_sha":null,"homepage":"https://xn--gckvb8fzb.com","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mrusme.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","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},"funding":{"custom":["https://github.com/mrusme#support"]}},"created_at":"2022-12-12T01:40:47.000Z","updated_at":"2025-03-14T13:20:25.000Z","dependencies_parsed_at":"2023-10-15T01:38:20.016Z","dependency_job_id":"8beb52c8-374d-406f-b658-48da3fe312b7","html_url":"https://github.com/mrusme/xbsapi","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrusme%2Fxbsapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrusme%2Fxbsapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrusme%2Fxbsapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrusme%2Fxbsapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrusme","download_url":"https://codeload.github.com/mrusme/xbsapi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248654094,"owners_count":21140236,"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":["api","api-rest","bookmark","bookmark-manager","bookmarks","bookmarks-manager","rest-api","sync","xbrowsersync","xbrowsersync-api","xbs","xbsapi"],"created_at":"2024-08-01T18:01:15.301Z","updated_at":"2025-04-13T02:13:17.351Z","avatar_url":"https://github.com/mrusme.png","language":"Go","funding_links":["https://github.com/mrusme#support"],"categories":["api"],"sub_categories":[],"readme":"xbsapi\n------\n[![Release](https://github.com/mrusme/xbsapi/actions/workflows/release.yml/badge.svg)](https://github.com/mrusme/xbsapi/releases)\n[![Docker](https://github.com/mrusme/xbsapi/actions/workflows/docker.yml/badge.svg)](https://hub.docker.com/r/mrusme/xbsapi)\n\nAlternative [xBrowserSync](https://www.xbrowsersync.org/) API that is a single \nbinary and supports SQLite3, PostgreSQL and MySQL.\n\nSee [xbscli](https://github.com/mrusme/xbscli) for a command line interface \n(client).\n\n\n## Build\n\n```sh\n$ make install-deps\n$ make\n```\n\n\n## Run\n\n```sh\n$ xbsapi\n```\n\nConnect from xBrowserSync clients by using e.g. `http://host:8000/api/v1` as \nservice URL. It is important to add `/api/v1` to the server URL!\n\n\n## Configuration\n\nxbsapi will read its config either from a file or from environment\nvariables. Every configuration key available in the \n[`lib/config.go`](lib/config.go) can be exported as\nenvironment variable, by separating scopes using `_` and prepend `XBSAPI` to\nit. For example, the following configuration:\n\n```toml\n[Server]\nBindIP = \"0.0.0.0\"\n```\n\n... can also be specified as an environment variable:\n\n```sh\nexport XBSAPI_SERVER_BINDIP=\"0.0.0.0\"\n```\n\nxbsapi will try to read the `xbsapi.toml` file from one of the following\npaths:\n\n- `/etc/xbsapi.toml`\n- `$XDG_CONFIG_HOME/xbsapi.toml`\n- `$HOME/.config/xbsapi.toml`\n- `$HOME/xbsapi.toml`\n- `$PWD/xbsapi.toml`\n\n\n### Database\n\nxbsapi requires a database to store bookmarks. Supported database types are \nSQLite, PostgreSQL and MySQL. The database can be configured using the \n`XBSAPI_DATABASE_TYPE` and `XBSAPI_DATABASE_CONNECTION` env,\nor the `Database.Type` and `Database.Connection` config properties.\n\n**WARNING:** If you do not specify a database configuration, xbsapi will use\nan in-memory SQLite database! As soon as xbsapi shuts down, all data\ninside the in-memory database is gone!\n\n\n#### SQLite File Example\n\n```toml\n[Database]\nType = \"sqlite3\"\nConnection = \"file:my-database.sqlite?cache=shared\u0026_fk=1\"\n```\n\n\n#### PostgreSQL Example *(using Docker for PostgreSQL)*\n\nRun the database:\n\n```sh\ndocker run -it --name postgres \\\n  -e POSTGRES_PASSWORD=postgres \\\n  -e POSTGRES_DB=xbsapi \\\n  -p 127.0.0.1:5432:5432 \\\n  -d postgres:alpine\n```\n\nConfigure `Database.Type` and `Database.Connection`:\n\n```toml\n[Database]\nType = \"postgres\"\nConnection = \"host=127.0.0.1 port=5432 dbname=xbsapi user=postgres password=postgres\"\n```\n\n\n#### MySQL Example\n\n```toml\n[Database]\nType = \"mysql\"\nConnection = \"mysqluser:mysqlpassword@tcp(mysqlhost:port)/database?parseTime=true\"\n```\n\n\n### Deployment\n\n#### Custom\n\nAll that's needed is a [configuration](#configuration) and xbsapi can be\nlaunched by e.g. running `./xbsapi` in a terminal.\n\n\n#### Supervisor\n\nTo run xbsapi via `supervisord`, create a config like this inside\n`/etc/supervisord.conf` or `/etc/supervisor/conf.d/xbsapi.conf`:\n\n```ini\n[program:xbsapi]\ncommand=/path/to/binary/of/xbsapi\nprocess_name=%(program_name)s\nnumprocs=1\ndirectory=/home/xbsapi\nautostart=true\nautorestart=unexpected\nstartsecs=10\nstartretries=3\nexitcodes=0\nstopsignal=TERM\nstopwaitsecs=10\nuser=xbsapi\nredirect_stderr=false\nstdout_logfile=/var/log/xbsapi.out.log\nstdout_logfile_maxbytes=1MB\nstdout_logfile_backups=10\nstdout_capture_maxbytes=1MB\nstdout_events_enabled=false\nstderr_logfile=/var/log/xbsapi.err.log\nstderr_logfile_maxbytes=1MB\nstderr_logfile_backups=10\nstderr_capture_maxbytes=1MB\nstderr_events_enabled=false\n```\n\n**Note:** It is advisable to run xbsapi under its own, dedicated daemon\nuser (`xbsapi` in this example), so make sure to either adjust `directory`\nas well as `user` or create a user called `xbsapi`.\n\n\n#### OpenBSD rc\n\nAs before, create a configuration file under `/etc/xbsapi.toml`.\n\nThen copy the [example rc.d script](examples/etc/rc.d/xbsapi) to\n`/etc/rc.d/xbsapi` and copy the binary to e.g.\n`/usr/local/bin/xbsapi`. Last but not least, update the `/etc/rc.conf.local`\nfile to contain the following line:\n\n```conf\nxbsapi_user=\"_xbsapi\"\n```\n\nIt is advisable to run xbsapi as a dedicated user, hence create the\n`_xbsapi` daemon account or adjust the line above according to your setup.\n\nYou can now run xbsapi by enabling and starting the service:\n\n```sh\nrcctl enable xbsapi\nrcctl start xbsapi\n```\n\n\n#### systemd\n\nCopy the file `examples/systemd/xbsapi.service` to `/etc/systemd/system/`.\nEdit the file to make sure it uses the correct xbsapi user in your system\nand also the correct path for the executable `xbsapi` file.\n\nEnable and start the unit file with:\n\n```sh\nsudo systemctl enable xbsapi.service\nsudo systemctl start xbsapi.service\n```\n\n#### Docker\n\nOfficial images are available on Docker Hub at \n[mrusme/xbsapi](https://hub.docker.com/r/mrusme/xbsapi) \nand can be pulled using the following command:\n\n```sh\ndocker pull mrusme/xbsapi\n```\n\nGitHub release versions are available as Docker image tags (e.g. `1.0.0`). \nThe `latest` image tag contains the latest code of the `master` branch.\n\nIt's possible to build xbsapi locally as a Docker container like this:\n\n```sh\ndocker build -t xbsapi:latest . \n```\n\nIt can then be run using the following command:\n\n```sh\ndocker run -it --rm --name xbsapi \\\n  -e XBSAPI_... \\\n  -e XBSAPI_... \\\n  -p 0.0.0.0:8000:8000 \\\n  xbsapi:latest\n```\n\nAlternatively a configuration TOML can be passed into the container like so:\n\n```sh\ndocker run -it --rm --name xbsapi \\\n  -v /path/to/my/local/xbsapi.toml:/etc/xbsapi.toml \\\n  -p 0.0.0.0:8000:8000 \\\n  xbsapi:latest\n```\n\n\n#### Kubernetes\n\nTODO\n\n\n#### Render\n\nFork this repo into your GitHub account, adjust the\n[`render.yaml`](render.yaml) accordingly and connect the forked repo [on\nRender](https://dashboard.render.com/select-repo?type=blueprint).\n\nAlternatively, you can also directly connect this public repo.\n\n\n#### Heroku\n\n[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/mrusme/xbsapi)\n\n\n#### DigitalOcean App Platform\n\n[![Deploy to DO](https://www.deploytodo.com/do-btn-blue-ghost.svg)](https://cloud.digitalocean.com/apps/new?repo=https://github.com/mrusme/xbsapi/tree/master\u0026refcode=9d48825ddae1)\n  \nAlternatively, fork this repo into your GitHub account, adjust the\n[`.do/app.yaml`](.do/app.yaml) accordingly and connect the forked repo [on\nDigitalOcean](https://cloud.digitalocean.com/apps/new).\n\n\n#### DigitalOcean Function\n\nAvailable soon.\n\n\n#### Aamazon Web Services Lambda Function\n\nTODO\n\n\n#### Google Cloud Function\n\n```sh\ngcloud functions deploy GCFHandler --runtime go116 --trigger-http\n```\n\nTODO: Database\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrusme%2Fxbsapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrusme%2Fxbsapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrusme%2Fxbsapi/lists"}