Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,8 @@ jobs:
- name: Run lint
run: pnpm lint

- name: Run typecheck
run: pnpm typecheck

- name: Run tests
run: pnpm vitest run
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pnpm exec lint-staged
pnpm typecheck
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
Interactive CLI for querying Atlassian Forge SQL databases via web triggers.

Announcement and discussion on dev forum: [here](https://community.developer.atlassian.com/t/introducing-fsql-an-interactive-cli-for-querying-forge-sql-databases-via-web-triggers/98076)

## Demo

![demo](demo-usage.gif)
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"lint": "pnpm lint:eslint && pnpm lint:prettier",
"lint:eslint": "eslint '**/*.{ts,tsx,js,jsx}' --ignore-pattern '**/eslint.config.js'",
"lint:prettier": "prettier '**/*.{ts,tsx,js,jsx,json,md,yaml,yml}' --check || echo '⚠️ Warning: Prettier formatting issues found. Run \"pnpm fixstyle\" to fix them.'",
"typecheck": "tsc --noEmit",
"fixall": "pnpm fixstyle && pnpm fixsrc",
"fixsrc": "eslint '**/*.{ts,tsx,js,jsx}' --ignore-pattern '**/eslint.config.js' --fix",
"fixstyle": "prettier '**/*.{ts,tsx,js,jsx,json,md,yaml,yml}' --write",
Expand Down
10 changes: 6 additions & 4 deletions src/execute-sql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ const executeSql = async (req: {
}): Promise<ReturnType<typeof getHttpResponse>> => {
console.log("\n=== Executing Custom SQL Query ===");

if (getAppContext()?.environmentType === `PRODUCTION`) {
const errorMsg = `executeSql is disabled in PRODUCTION for security.`;
const appContext = getAppContext();
if (!appContext || appContext.environmentType === `PRODUCTION`) {
const errorMsg = !appContext
? `executeSql requires a valid Forge context.`
: `executeSql is disabled in PRODUCTION for security.`;
console.log(errorMsg);
return getHttpResponse(403, {
success: false,
Expand All @@ -16,11 +19,10 @@ const executeSql = async (req: {
}

const payload = req.body;
let sqlRequest: { query?: string } | null = null;
let query: string | undefined;

try {
sqlRequest = JSON.parse(payload);
const sqlRequest: { query?: string } | null = JSON.parse(payload);
query = sqlRequest?.query;

if (!query) {
Expand Down
Loading