Skip to content

Latest commit

 

History

History
239 lines (167 loc) · 9.92 KB

README.md

File metadata and controls

239 lines (167 loc) · 9.92 KB

Killswitch is a clever control panel built by Mirego that allows mobile developers to apply
runtime version-specific behaviors to their iOS or Android application.



Screenshot of Killswitch showing the logged out homepage Screenshot of Killswitch showing the logged in homepage Screenshot of Killswitch showing a project page

Section Description
🚧 Dependencies Technical dependencies and how to install them
🏎 Kickstart Details on how to kickstart development on the project
🏇 Usage Details on how to use the application
🚑 Troubleshooting Recurring problems and proven solutions
🚀 Deploy Deployment instructions

🚧 Dependencies

Every runtime dependencies are defined in the .tool-versions file. These external dependencies are also required:

  • PostgreSQL (~> 10.0)

🏎 Kickstart

Environment variables

All required environment variables are documented in .env.dev.

When running rails, rake or make commands, it is important that these variables are present in the environment. There are several ways to achieve this. Using nv is recommended since it works out of the box with .env.* files.

Initial setup

  1. Create both .env.dev.local and .env.test.local from empty values in .env.dev and .env.test
  2. Install Ruby and NPM dependencies with make dependencies
  3. Generate values for mandatory secrets in .env.dev with rake secret

Then, with variables from .env.dev and .env.dev.local present in the environment:

  1. Create and migrate the database with rake db:setup
  2. Start the Rails server with rails s

Sample data

You can use the sample_data:create Rake task to create an organization, an admin user and a few applications.

$ KILLSWITCH_SAMPLE_DATA_EMAIL=foo@example.com KILLSWITCH_SAMPLE_DATA_PASSWORD=p@ssw0rd rake sample_data:create

make commands

A Makefile is present at the root and expose common tasks. The list of these commands is available with make help.

Tests

Tests can be ran with make test.

Linting

Several linting and formatting tools can be ran to ensure coding style consistency:

  • make lint ensures code follows our guidelines and best practices
  • make format formats files using Prettier

Continuous integration

The .github/workflows/ci.yaml workflow ensures that the codebase is in good shape on each pull request and branch push.

🏇 Usage

HTTP requests

Request a behavior

GET /killswitch
Parameters
Field Type Description
key String The API key (eg. "f206934e29160b43924308251b88")
version String The version of the application to test against (see Conventions → Version numbers section)
Headers
Header Description
Accept-Language The application language (the API will return localized messages, if available (eg. Accept-Language: fr)
Possible erroneous responses
Status Code Reason
400 Bad Request Parameters are malformed or missing
404 Not Found The API key is not for a valid project or application
Possible successful responses
Status Code Message
200 OK Everything is under control, yay
304 Not Modified If an If-None-Match header is passed and a cached response exist, a 304 will be returned with an empty body

Conventions

Version numbers

Version numbers supported by Killswitch must match the following regular expression:

/^\d+(\.\d+)?(\.\d+)?(\.\w+)?$/

Here are some valid and invalid version number examples:

Version number Valid
1
1.2
1.2.3
1.2.3.4
1.2.3.foo
foo
1.
1.2.
1.2.3.4.5

Behaviors JSON representations

Root element

Key Type Description
action String The action the application should enforce ("ok", "alert" or "kill")
message String A message to display to the user
buttons Array An array of buttons to show to the user
Buttons
Key Type Description
type String The type of button ("cancel, "url" or "reload"), defaults to "cancel" if not specified
label String The button label
url String The button URL, if the type is "url"

Examples

OK
{
  "action": "ok",
  "buttons": []
}
Alert
{
  "action": "alert",
  "message": "SUP?",
  "buttons": [
    {
      "type": "cancel",
      "label": "Nothing"
    }
  ]
}
Kill
{
  "action": "kill",
  "message": "The app will be killed now. Please upgrade to the latest version.",
  "buttons": [
    {
      "type": "url",
      "label": "Upgrade",
      "url": "itms://foo"
    },
    {
      "type": "cancel",
      "label": "I don’t want to."
    }
  ]
}

🚑 Troubleshooting

System readiness

The project exposes a GET /ping route that sends an HTTP 200 OK response as soon as the server is ready to accept requests. The response also contains the project version for debugging purpose.

System health

The project exposes a GET /health route that contains checks to make sure the application and its external dependencies are healthy.

Name Description
noop This check is always healthy
database Check if the database connection is active

🚀 Deploy

Container

A Docker image can be created with make build and pushed to a registry with make push.

Official Docker images can be pulled from GitHub Container registry. For example, to get the latest main image:

$ docker pull ghcr.io/mirego/killswitch:latest

License

Killswitch is © 2013-2022 Mirego and may be freely distributed under the New BSD license. See the LICENSE.md file.

The shield logo is based on this lovely icon by Kimmi Studio, from The Noun Project. Used under a Creative Commons BY 3.0 license.

About Mirego

Mirego is a team of passionate people who believe that work is a place where you can innovate and have fun. We’re a team of talented people who imagine and build beautiful Web and mobile applications. We come together to share ideas and change the world.

We also love open-source software and we try to give back to the community as much as we can.