Introducing fsql - an interactive cli for querying Forge SQL databases via web triggers

Overview

fsql is a tool designed to feel like a mysql or psql session for your Forge SQL database.

It makes it easy to explore your data, insert test records, work on queries, etc.

Install it into a Forge development deployment by running fsql-setup from the project root. It will setup a webtrigger that fsql will use to run the sql commands.

Get Started
Github repo

Demo

fsql usage demo

Feedback

Create an issue on github (see link above) or post a message here with your thoughts and any issues encountered. Thank you!

7 Likes

Hi, Nice tool :+1:

One important thing to be careful about: it should be restricted to the dev environment only, or at least clearly documented as dangerous for production use .

Otherwise, this web trigger becomes a direct ingress point to the database, and since web triggers can be called without authorization, it may expose your Forge SQL instance in production.

My recommendation is to explicitly block execution in production right at the beginning of the web trigger, for example:

import { getAppContext } from "@forge/api";

const environmentType = getAppContext()?.environmentType;
if (environmentType === "PRODUCTION") {
  return {
    statusCode: 500,
    body: "This trigger is disabled in production",
  };
}

Alternatively, adding strong authorization on top of the trigger would also work.

2 Likes

Thanks @vzakharchenko. :+1: I will look at adding something for that.

Yes maybe a hard block for production and a clear warning otherwise.

Authorization would be a nice add for a staging or qa environment adding a layer of protection on top the URI whilst still allowing the tool to be used there … :thinking:

1 Like