alp-node 9.0.1 → 10.1.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/src/AlpNodeApp.ts CHANGED
@@ -1,14 +1,10 @@
1
- import type {
2
- IncomingMessage,
3
- RequestListener,
4
- Server,
5
- ServerResponse,
6
- } from "node:http";
1
+ import type { IncomingMessage, Server, ServerResponse } from "node:http";
7
2
  import path from "node:path";
8
3
  import Koa from "koa";
9
4
  import type { DefaultContext, DefaultState, ParameterizedContext } from "koa";
10
5
  import compress from "koa-compress";
11
6
  import serve from "koa-static";
7
+ // eslint-disable-next-line import-x/no-unresolved
12
8
  import { Logger } from "nightingale-logger";
13
9
  import type { Router } from "router-segments";
14
10
  import type { Config } from "./config";
@@ -27,7 +23,6 @@ import type { TranslateBaseContext, TranslateContext } from "./translate/index";
27
23
  import translate from "./translate/index";
28
24
  import type {
29
25
  Context as AlpContext,
30
- ContextSanitizedState,
31
26
  ContextState,
32
27
  NodeApplication,
33
28
  NodeConfig,
@@ -48,7 +43,8 @@ declare module "koa" {
48
43
  interface DefaultState extends ContextState {}
49
44
 
50
45
  interface DefaultContext
51
- extends AlpContext,
46
+ extends
47
+ AlpContext,
52
48
  AlpParamsContext,
53
49
  AlpRouterContext,
54
50
  AlpLanguageContext,
@@ -122,8 +118,7 @@ export class AlpNodeApp
122
118
  res: ServerResponse,
123
119
  ): ParameterizedContext<StateT> {
124
120
  const ctx = super.createContext<StateT>(req, res);
125
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
126
- ctx.sanitizedState = {} as ContextSanitizedState;
121
+ ctx.sanitizedState = {};
127
122
  return ctx;
128
123
  }
129
124
 
@@ -154,7 +149,8 @@ export class AlpNodeApp
154
149
  try {
155
150
  const server = await _listen(
156
151
  this.config,
157
- this.callback() as RequestListener,
152
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
153
+ this.callback(),
158
154
  this.certPath,
159
155
  );
160
156
  this._server = server;
package/src/errors.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { STATUS_CODES } from "node:http";
2
2
  import ErrorHtmlRenderer from "error-html";
3
+ // eslint-disable-next-line import-x/no-unresolved
3
4
  import { Logger } from "nightingale-logger";
4
5
  import type { Context } from "./AlpNodeApp";
5
6
  import type { HtmlError } from "./types";
package/src/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { existsSync, readFileSync } from "node:fs";
2
2
  import path from "node:path";
3
+ // eslint-disable-next-line import-x/no-unresolved
3
4
  import { Logger } from "nightingale-logger";
4
5
  import type { AlpNodeAppOptions } from "./AlpNodeApp";
5
6
  import { AlpNodeApp } from "./AlpNodeApp";
@@ -20,7 +21,7 @@ export const appDirname = path.resolve("build");
20
21
 
21
22
  const packagePath = path.resolve("package.json");
22
23
  if (!packagePath) {
23
- throw new Error(`Could not find package.json: "${String(packagePath)}"`);
24
+ throw new Error(`Could not find package.json: "${packagePath}"`);
24
25
  }
25
26
  export const packageDirname = path.dirname(packagePath);
26
27
 
package/src/language.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { Context } from "koa";
2
+ // eslint-disable-next-line import-x/no-unresolved
2
3
  import { defineLazyProperty } from "object-properties";
3
4
  import type { AlpNodeApp } from "./AlpNodeApp";
4
5
 
package/src/listen.ts CHANGED
@@ -2,6 +2,7 @@ import { chmodSync, readFileSync, unlinkSync } from "node:fs";
2
2
  import { createServer as createServerHttp } from "node:http";
3
3
  import type { IncomingMessage, Server, ServerResponse } from "node:http";
4
4
  import { createServer as createServerHttps } from "node:https";
5
+ // eslint-disable-next-line import-x/no-unresolved
5
6
  import { Logger } from "nightingale-logger";
6
7
  import type { Config } from "./config";
7
8
 
@@ -1,6 +1,6 @@
1
1
  import assert from "node:assert/strict";
2
2
  import { test } from "node:test";
3
- // eslint-disable-next-line import/extensions
3
+ // eslint-disable-next-line import-x/extensions
4
4
  import { ParamValidationResult } from "./ParamValidationResult.ts";
5
5
 
6
6
  // const createContextMock = (): Context &
@@ -1,3 +1,4 @@
1
+ // eslint-disable-next-line import-x/no-unresolved
1
2
  import { defineLazyProperty } from "object-properties";
2
3
  import type { AlpNodeApp, Context } from "../AlpNodeApp";
3
4
  import ParamValid from "./ParamValid";
@@ -28,11 +29,6 @@ export default function alpParams(app: AlpNodeApp): void {
28
29
  return namedParams?.get(name);
29
30
  },
30
31
 
31
- otherRouteParam(this: Context, position: number): string | undefined {
32
- const otherParams = this.route.otherParams;
33
- return otherParams?.[position - 1];
34
- },
35
-
36
32
  queryParam(this: Context, name: string): string | undefined {
37
33
  const searchParams = this.request.searchParams;
38
34
  return searchParams.get(name) ?? undefined;
package/src/router.ts CHANGED
@@ -4,6 +4,7 @@ import type {
4
4
  Router,
5
5
  RouterBuilder,
6
6
  } from "router-segments";
7
+ // eslint-disable-next-line import-x/no-unresolved
7
8
  import { createRouterBuilder } from "router-segments";
8
9
  import type { AlpNodeApp, Context } from "./AlpNodeApp";
9
10
 
@@ -1,3 +1,4 @@
1
+ // eslint-disable-next-line import-x/no-unresolved
1
2
  import { Logger } from "nightingale-logger";
2
3
  import type { AlpNodeApp, Context } from "../AlpNodeApp";
3
4
  import type { Translations } from "./load";
package/src/types.ts CHANGED
@@ -52,8 +52,7 @@ export interface BrowserApplicationInCreation extends ApplicationInCreation {
52
52
  }
53
53
 
54
54
  export interface NodeApplication
55
- extends Application,
56
- NodeApplicationInCreation {
55
+ extends Application, NodeApplicationInCreation {
57
56
  config: NodeConfig;
58
57
  dirname: string;
59
58
  on: (event: "close", callback: () => void) => void;