@aryanbansal-launch/edge-utils 0.1.7 β†’ 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,3 @@
1
- /**
2
- * Generates a standard launch.json configuration object.
3
- */
4
1
  export function generateLaunchConfig(options) {
5
2
  return {
6
3
  redirects: options.redirects || [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aryanbansal-launch/edge-utils",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "repository": {
package/readme.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # πŸš€ Edge Utils for Contentstack Launch
2
2
 
3
- [![npm version](https://img.shields.io/npm/v/@launch/edge-utils.svg)](https://www.npmjs.com/package/@aryanbansal-launch/edge-utils)
3
+ [![npm version](https://img.shields.io/npm/v/@aryanbansal-launch/edge-utils.svg)](https://www.npmjs.com/package/@aryanbansal-launch/edge-utils)
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
5
 
6
6
  A lightweight, high-performance toolkit specifically designed for **Contentstack Launch Edge Functions**. Speed up your development with production-ready utilities for security, authentication, routing, and Next.js compatibilityβ€”all optimized to run at the edge.
@@ -36,7 +36,7 @@ npx launch-init
36
36
  This will automatically create the `functions/` directory and a boilerplate `[proxy].edge.js` handler for you.
37
37
 
38
38
  ### 3. Configure (Optional)
39
- Manage your `launch.json` (Redirects, Rewrites, and Cache Priming) interactively:
39
+ Manage your `launch.json` ([Redirects](https://www.contentstack.com/docs/developers/launch/edge-url-redirects), [Rewrites](https://www.contentstack.com/docs/developers/launch/edge-url-rewrites), and [Cache Priming](https://www.contentstack.com/docs/developers/launch/cache-priming)) interactively:
40
40
  ```bash
41
41
  npx launch-config
42
42
  ```
@@ -71,15 +71,15 @@ export default async function handler(request, context) {
71
71
  });
72
72
  if (rscResponse) return rscResponse;
73
73
 
74
- // 2. πŸ›‘οΈ Block AI bots immediately
74
+ // 3. πŸ€– Block AI bots immediately
75
75
  const botResponse = blockAICrawlers(request);
76
76
  if (botResponse) return botResponse;
77
77
 
78
- // 3. 🧱 IP Whitelisting
78
+ // 4. 🧱 IP Whitelisting
79
79
  const ipResponse = ipAccessControl(request, { allow: ["203.0.113.10"] });
80
80
  if (ipResponse) return ipResponse;
81
81
 
82
- // 4. πŸ” Domain-specific Basic Auth (e.g., for staging)
82
+ // 5. πŸ” Domain-specific Basic Auth (e.g., for staging)
83
83
  const authResponse = await protectWithBasicAuth(request, {
84
84
  hostnameIncludes: "staging.myapp.com",
85
85
  username: "admin",
@@ -87,7 +87,7 @@ export default async function handler(request, context) {
87
87
  });
88
88
  if (authResponse && authResponse.status === 401) return authResponse;
89
89
 
90
- // 5. πŸ”€ SEO-friendly Redirects
90
+ // 6. πŸ”€ SEO-friendly Redirects
91
91
  const redirectResponse = redirectIfMatch(request, {
92
92
  path: "/legacy-url",
93
93
  to: "/modern-url",
@@ -95,11 +95,11 @@ export default async function handler(request, context) {
95
95
  });
96
96
  if (redirectResponse) return redirectResponse;
97
97
 
98
- // 6. πŸ“ Geo-Location Access
98
+ // 7. πŸ“ Geo-Location Access
99
99
  const geo = getGeoHeaders(request);
100
100
  console.log(`Request from ${geo.city}, ${geo.country}`);
101
101
 
102
- // 7. πŸš€ Pass through to origin
102
+ // 8. πŸš€ Pass through to origin
103
103
  return passThrough(request);
104
104
  }
105
105
  ```
@@ -109,9 +109,9 @@ export default async function handler(request, context) {
109
109
  ## πŸ“– API Reference
110
110
 
111
111
  ### πŸ›‘οΈ Security
112
- - **`blockAICrawlers(request, bots?)`**: Blocks common AI crawlers.
113
- - **`blockDefaultDomains(request, { domainToBlock? })`**: Blocks access via default Contentstack Launch domains (e.g., `contentstackapps.com`).
114
- - **`ipAccessControl(request, { allow?, deny? })`**: Simple IP-based firewall.
112
+ - **`blockAICrawlers(request, bots?)`**: Detects and blocks known AI crawlers (GPTBot, ClaudeBot, etc.) based on the User-Agent.
113
+ - **`blockDefaultDomains(request, { domainToBlock? })`**: Prevents users from accessing your site via the default `*.contentstackapps.com` domains, forcing them to use your custom domain.
114
+ - **`ipAccessControl(request, { allow?, deny? })`**: A simple firewall to whitelist or blacklist specific IP addresses at the edge.
115
115
 
116
116
  ### πŸ” Authentication
117
117
  - **`protectWithBasicAuth(request, options)`**: Prompt for credentials based on hostname.
@@ -130,3 +130,9 @@ export default async function handler(request, context) {
130
130
  ## 🌐 Platform Support
131
131
 
132
132
  This library is exclusively optimized for **[Contentstack Launch](https://www.contentstack.com/docs/developers/launch)**.
133
+
134
+ ---
135
+
136
+ ## πŸ“„ License
137
+
138
+ Distributed under the MIT License. See `LICENSE` for more information.