Skip to content

AIsBreaker Server ​

Introduction ​

The AIsBreaker Server provides a REST API to access the AIs for the AIsBreaker Client API. It is implemented in TypeScript/JavaScript and can be used as a standalone server or as a library in your own Node.js app.

Features ​

Public Demo Server ​

For testing purposes, we provide a public demo server at api.demo.aisbreaker.org. It is a free service and can be used by anyone. However, it is not intended for production use and may be shut down at any time without notice.

Installation ​

With Docker ​

The server is available as standalone Docker image (Dockerfile, repo aisbreaker/aisbreaker-server). It has no further container dependecies and it currently doesn't require persistent storage (because the server is stateless).

Start server on host port 8080

bash
export AUTH_ENCRYPTION_KEYPHRASE="my secret server keyphrase"
docker run \
  -e AUTH_ENCRYPTION_KEYPHRASE="$AUTH_ENCRYPTION_KEYPHRASE" \
  -p 8080:3000 \
  aisbreaker/aisbreaker-server:latest

and check if it's running (in a 2nd terminal)

bash
curl -X GET "http://localhost:8080/api/v1/version"

should return something like

json
{
  "version": "unknown version",
  "message": "Hello stranger, ... I'm AIsBreaker.org server version unknown version !"
}

With Kubernetes ​

Here we explain hot to run the server under Kubernetes.

First set the required secret(s) aisbreaker-api-server-secrets in your namespace:

yaml
apiVersion: v1
kind: Secret
metadata:
  name: aisbreaker-api-server-secrets
  namespace: <NAMESPACE>
type: Opaque
data:
  # key is base64 encoded:
  #   export AUTH_ENCRYPTION_KEYPHRASE='api.demo...'
  #   echo -n "${AUTH_ENCRYPTION_KEYPHRASE}" | base64 -w 0
  auth-encryption-keyphrase: YXB...

Then customize aisbreaker-demo-api-server-server.yaml.tmpl with replacement of

  • ${IMAGE_NAME} by aisbreaker/aisbreaker-server
  • ${VERSION} by latest or a specific version number from aisbreaker-server/tags

and apply it with kubectl apply -n <NAMESPACE> -f aisbreaker-server.yaml.

In addition you can configure a Kubernetes service and ingress as needed.

With Plain Node.js ​

Prepare

bash
git clone git@github.com:aisbreaker/aisbreaker-js.git
cd aisbreaker-js/packages/aisbreaker-server/
npm install
npm run build

and start the server

bash
export AUTH_ENCRYPTION_KEYPHRASE="my secret server keyphrase"
# ./start.sh
npm run start
bash
export AUTH_ENCRYPTION_KEYPHRASE="my secret server keyphrase"
node build/index.js
bash
export AUTH_ENCRYPTION_KEYPHRASE="my secret server keyphrase"
startDev.sh

Implementation Details ​

  • aisbreaker-server
    • code to run an NodeJS + Express HTTP server, to serve the AIsBreaker API via REST
    • inclusive server default setup
    • source code

Released under the MIT License.