
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
react-router-endpoint-diff
Advanced tools
CLI tool to detect API endpoint changes in React Router applications
A CLI tool to detect API endpoint changes in React Router applications by analyzing Git diffs and identifying changes to loader and action functions.
loader and action functionsnpm install -g react-router-endpoint-diff
Or use with npx:
npx react-router-endpoint-diff
# Compare last commit with current HEAD
rrdiff
# Compare specific commits
rrdiff --from HEAD~3 --to HEAD
# Compare with a specific tag
rrdiff --from v1.0.0 --to HEAD
# Compare staged changes
rrdiff --staged
| Option | Description | Default |
|---|---|---|
--from <ref> | Git reference to compare from | HEAD~1 |
--to <ref> | Git reference to compare to | HEAD |
--staged | Compare staged changes with HEAD | false |
--routes-dir <path> | Base directory containing route files | app/routes |
--file-pattern <glob> | File pattern to match route files | **/*.{ts,tsx,js,jsx} |
--git-dir <path> | Git repository path | . |
--verbose | Enable verbose logging | false |
--json | Output in JSON format | false |
--summary-only | Output only summary text | false |
# Analyze changes in a specific routes directory
rrdiff --routes-dir src/routes
# Get JSON output for CI/CD integration
rrdiff --json
# Compare changes from last week
rrdiff --from 'HEAD@{1.week.ago}' --to HEAD
# Verbose output for debugging
rrdiff --verbose
# Quick summary only
rrdiff --summary-only
# API Endpoint Change Report
Comparing `HEAD~1` and `HEAD`
## Summary
- **2** new endpoint(s) detected
- **1** endpoint(s) with potential parameter changes
## New Endpoints
### New `loader` for `/users/:userId`
**File:** `app/routes/users/$userId.tsx`
**Description:** New loader function in new file
**Relevant Diff:**
```diff
--- /dev/null
+++ b/app/routes/users/$userId.tsx
@@ -0,0 +1,8 @@
+export const loader: LoaderFunction = async ({ params }) => {
+ const user = await getUser(params.userId);
+ return json(user);
+};
action for /productsFile: app/routes/products.tsx
Description: Request parameter pattern changes detected in action function
Relevant Diff:
--- a/app/routes/products.tsx
+++ b/app/routes/products.tsx
@@ -10,7 +10,8 @@
export const action: ActionFunction = async ({ request }) => {
- const formData = await request.formData();
- const productName = formData.get("name");
+ const data = await request.json();
+ const productName = data.productName;
+ const productPrice = data.price;
return redirect("/products");
};
### JSON Output
```json
{
"summary": {
"fromRef": "HEAD~1",
"toRef": "HEAD",
"totalChanges": 3,
"newEndpoints": 2,
"modifiedEndpoints": 1,
"generatedAt": "2024-01-15T10:30:00.000Z"
},
"changes": [
{
"type": "new-api",
"endpointPath": "/users/:userId",
"functionType": "loader",
"filePath": "app/routes/users/$userId.tsx",
"description": "New loader function in new file"
}
]
}
You can also use this tool as a library in your Node.js applications:
import { ReactRouterEndpointDiff } from 'react-router-endpoint-diff';
const analyzer = new ReactRouterEndpointDiff({
routesDir: 'app/routes',
gitDir: '.'
});
const result = await analyzer.analyze({
from: 'HEAD~1',
to: 'HEAD',
verbose: false
});
console.log(result.summary);
console.log(result.markdownReport);
// Or get JSON report
const jsonReport = await analyzer.generateJsonReport({
from: 'HEAD~1',
to: 'HEAD'
});
git diff between specified referencesloader and action function exportsThe tool detects the following React Router patterns:
// Variable declaration
export const loader = async ({ params, request }) => { ... };
// Function declaration
export async function loader({ params, request }) { ... }
// Variable declaration
export const action = async ({ params, request }) => { ... };
// Function declaration
export async function action({ params, request }) { ... }
The tool detects changes to these request parameter patterns:
params.propertyNamerequest.json()request.formData()request.text()request.arrayBuffer()request.blob()new URL(request.url).searchParamsformData.get(), formData.getAll(), formData.has()The tool converts file paths to URL paths following React Router conventions:
| File Path | URL Path |
|---|---|
app/routes/users.tsx | /users |
app/routes/users/$userId.tsx | /users/:userId |
app/routes/posts/index.tsx | /posts |
app/routes/files/$.tsx | /files/* |
This tool is designed to integrate well with CI/CD pipelines:
# GitHub Actions example
- name: Check API Changes
run: |
npx react-router-endpoint-diff --json > api-changes.json
if [ -s api-changes.json ]; then
echo "API changes detected!"
cat api-changes.json
fi
Build
pnpm build
Help
./dist/cli.js --help
Specify the test directory and execute
./dist/cli.js --routes-dir . --verbose
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
MIT License - see LICENSE file for details.
FAQs
CLI tool to detect API endpoint changes in React Router applications
We found that react-router-endpoint-diff demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.