@vyriy/static 0.5.2 → 0.5.3

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,5 @@
1
1
  #!/usr/bin/env node
2
2
  import { staticServer } from '../index.js';
3
- const directory = process.argv.find((arg, index) => index > 1 && !arg.startsWith('-')) ?? '.';
4
- void staticServer({ directory }).then((code) => {
5
- process.exitCode = code;
3
+ process.exitCode = await staticServer({
4
+ directory: process.argv.find((arg, index) => index > 1 && !arg.startsWith('-')) ?? '.',
6
5
  });
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@vyriy/static",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "Static file and SPA serving helpers for Vyriy servers.",
5
5
  "type": "module",
6
6
  "bin": "./bin/vyriy-static.js",
7
7
  "dependencies": {
8
- "@vyriy/handler": "0.5.2",
9
- "@vyriy/router": "0.5.2",
10
- "@vyriy/server": "0.5.2"
8
+ "@vyriy/handler": "0.5.3",
9
+ "@vyriy/router": "0.5.3",
10
+ "@vyriy/server": "0.5.3"
11
11
  },
12
12
  "agents": "./AGENTS.md",
13
13
  "license": "MIT",
package/types.d.ts CHANGED
@@ -1,13 +1,12 @@
1
1
  import type { ApiEvent, ApiResult, Handler } from '@vyriy/handler';
2
2
  import type { RouterApi } from '@vyriy/router';
3
- export type StaticServerOptions = StaticOptions;
4
3
  export type StaticOptions = {
5
4
  readonly directory?: string;
6
5
  readonly index?: string;
7
6
  readonly error?: string;
8
7
  };
9
8
  export type StaticHandler = Handler<ApiEvent, ApiResult>;
10
- export type StaticServer = (options?: StaticServerOptions) => Promise<number>;
9
+ export type StaticServer = (options?: StaticOptions) => Promise<number>;
11
10
  export type StaticRouterApi = Omit<RouterApi, 'delete' | 'fallback' | 'get' | 'patch' | 'post' | 'put'> & {
12
11
  static(path: string): StaticRouterApi;
13
12
  } & {
package/with-static.js CHANGED
@@ -1,7 +1,11 @@
1
1
  import { useStatic } from './use-static.js';
2
2
  const normalizeMount = (path) => {
3
3
  const mount = path.startsWith('/') ? path : `/${path}`;
4
- return mount === '/' ? mount : mount.replace(/\/+$/, '');
4
+ let end = mount.length;
5
+ while (end > 1 && mount[end - 1] === '/') {
6
+ end--;
7
+ }
8
+ return mount.slice(0, end);
5
9
  };
6
10
  const toStaticPath = (mount, requestPath) => {
7
11
  if (mount === '/') {