lambder 3.2.5 → 3.3.0

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.
package/dist/Lambder.d.ts CHANGED
@@ -27,8 +27,11 @@ export type LambderIndexHtmlOptions = {
27
27
  /** Methods that reach the index handler. Default: ["GET", "HEAD"]. */
28
28
  methods?: string[];
29
29
  /**
30
- * Skip paths whose last segment has an extension (missing assets by this
31
- * point; a 200 HTML shell would be a soft-404). Default: true.
30
+ * Skip paths whose last segment contains a dot, treating them as missing
31
+ * assets rather than app routes. Default: false real files have already
32
+ * been served by servePublicFiles at this point, and plenty of app routes
33
+ * carry dots (JWTs, coordinates, domain names, version numbers). Turn it
34
+ * on to get 404s instead of a 200 shell for missing-asset requests.
32
35
  */
33
36
  skipFilePaths?: boolean;
34
37
  /** 301-redirect trailing-slash paths to the canonical no-slash URL. Default: false. */
@@ -150,11 +153,12 @@ export default class Lambder<TSessionData = any, _TContract extends Record<strin
150
153
  servePublicFiles(options?: LambderPublicFilesOptions): this;
151
154
  /**
152
155
  * Serve the app shell for page requests that nothing else handled. Runs
153
- * after servePublicFiles in the fallback chain, gated by a built-in
154
- * filter: only configured methods (default GET/HEAD) and, by default, only
155
- * paths that do not look like files. Gated-out requests fall through to
156
- * setRouteFallbackHandler. Without a handler, publicPath/index.html is
157
- * served via res.templateFile (markers optional) with no-cache.
156
+ * after servePublicFiles in the fallback chain, so real files are already
157
+ * gone; everything left is an app route (option `skipFilePaths` opts back
158
+ * into 404ing dotted paths). Only configured methods reach it, default
159
+ * GET/HEAD. Gated-out requests fall through to setRouteFallbackHandler.
160
+ * Without a handler, publicPath/index.html is served via res.templateFile
161
+ * (markers optional) with no-cache.
158
162
  */
159
163
  serveIndexHtml(handler?: FallbackHandlerFunction, options?: LambderIndexHtmlOptions): this;
160
164
  /** Apply the serveIndexHtml gates; null means fall through. */
package/dist/Lambder.js CHANGED
@@ -121,11 +121,12 @@ export default class Lambder {
121
121
  }
122
122
  /**
123
123
  * Serve the app shell for page requests that nothing else handled. Runs
124
- * after servePublicFiles in the fallback chain, gated by a built-in
125
- * filter: only configured methods (default GET/HEAD) and, by default, only
126
- * paths that do not look like files. Gated-out requests fall through to
127
- * setRouteFallbackHandler. Without a handler, publicPath/index.html is
128
- * served via res.templateFile (markers optional) with no-cache.
124
+ * after servePublicFiles in the fallback chain, so real files are already
125
+ * gone; everything left is an app route (option `skipFilePaths` opts back
126
+ * into 404ing dotted paths). Only configured methods reach it, default
127
+ * GET/HEAD. Gated-out requests fall through to setRouteFallbackHandler.
128
+ * Without a handler, publicPath/index.html is served via res.templateFile
129
+ * (markers optional) with no-cache.
129
130
  */
130
131
  serveIndexHtml(handler, options = {}) {
131
132
  this.indexHtmlConfig = { handler: handler ?? null, options };
@@ -139,7 +140,7 @@ export default class Lambder {
139
140
  const methods = (options.methods ?? ["GET", "HEAD"]).map((m) => m.toUpperCase());
140
141
  if (!methods.includes(ctx.method.toUpperCase()))
141
142
  return null;
142
- if ((options.skipFilePaths ?? true) && (ctx.path.split("/").pop() ?? "").includes("."))
143
+ if ((options.skipFilePaths ?? false) && (ctx.path.split("/").pop() ?? "").includes("."))
143
144
  return null;
144
145
  if (options.redirectTrailingSlash && ctx.path.length > 1 && ctx.path.endsWith("/")) {
145
146
  const target = ctx.path.replace(/\/+$/, "") || "/";
@@ -16,6 +16,11 @@ export const createContext = (event, lambdaContext, apiPath) => {
16
16
  if (isV2HttpEvent(event)) {
17
17
  host = headers.host || event.requestContext.domainName || "";
18
18
  path = event.rawPath;
19
+ // Named stages (non-$default) are included in rawPath; v1 strips them.
20
+ const stage = event.requestContext.stage;
21
+ if (stage && stage !== "$default" && (path === `/${stage}` || path.startsWith(`/${stage}/`))) {
22
+ path = path.slice(stage.length + 1) || "/";
23
+ }
19
24
  method = event.requestContext.http.method;
20
25
  get = {};
21
26
  for (const [key, value] of new URLSearchParams(event.rawQueryString ?? "").entries()) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lambder",
3
- "version": "3.2.5",
3
+ "version": "3.3.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",