@aeriajs/server 0.0.238 → 0.0.240

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,7 +1,9 @@
1
1
  export declare const DEFAULT_API_CONFIG: {
2
2
  baseUrl: "/";
3
- port: number;
4
3
  defaultPaginationLimit: number;
4
+ server: {
5
+ port: number;
6
+ };
5
7
  security: {
6
8
  tokenExpiration: number;
7
9
  linkTokenExpiration: number;
package/dist/constants.js CHANGED
@@ -3,8 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DEFAULT_API_CONFIG = void 0;
4
4
  exports.DEFAULT_API_CONFIG = {
5
5
  baseUrl: '/',
6
- port: 3000,
7
6
  defaultPaginationLimit: 10,
7
+ server: {
8
+ port: 3000,
9
+ },
8
10
  security: {
9
11
  tokenExpiration: 36000,
10
12
  linkTokenExpiration: 36000,
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  export const DEFAULT_API_CONFIG = {
3
3
  baseUrl: "/",
4
- port: 3e3,
5
4
  defaultPaginationLimit: 10,
5
+ server: {
6
+ port: 3e3
7
+ },
6
8
  security: {
7
9
  tokenExpiration: 36e3,
8
10
  linkTokenExpiration: 36e3,
package/dist/init.js CHANGED
@@ -62,12 +62,8 @@ const init = (_options = {}) => {
62
62
  if (!options.config.noWarmup) {
63
63
  await (0, warmup_js_1.warmup)();
64
64
  }
65
- const serverOptions = (0, http_1.defineServerOptions)({
66
- host: options.config.host,
67
- port: options.config.port,
68
- });
69
65
  const apiRouter = (0, routes_js_1.registerRoutes)();
70
- const server = (0, node_http_1.registerServer)(serverOptions, async (request, response) => {
66
+ const server = (0, node_http_1.registerServer)(options.config.server, async (request, response) => {
71
67
  if ((0, http_1.cors)(request, response) === null) {
72
68
  return;
73
69
  }
package/dist/init.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  import { Result, ACError, HTTPStatus } from "@aeriajs/types";
3
3
  import { endpointError, throwIfError, deepMerge } from "@aeriajs/common";
4
- import { defineServerOptions, cors, wrapRouteExecution } from "@aeriajs/http";
4
+ import { cors, wrapRouteExecution } from "@aeriajs/http";
5
5
  import { registerServer } from "@aeriajs/node-http";
6
6
  import { createContext, getDatabase, decodeToken, traverseDocument, ObjectId } from "@aeriajs/core";
7
7
  import { DEFAULT_API_CONFIG } from "./constants.mjs";
@@ -56,12 +56,8 @@ export const init = (_options = {}) => {
56
56
  if (!options.config.noWarmup) {
57
57
  await warmup();
58
58
  }
59
- const serverOptions = defineServerOptions({
60
- host: options.config.host,
61
- port: options.config.port
62
- });
63
59
  const apiRouter = registerRoutes();
64
- const server = registerServer(serverOptions, async (request, response) => {
60
+ const server = registerServer(options.config.server, async (request, response) => {
65
61
  if (cors(request, response) === null) {
66
62
  return;
67
63
  }
package/dist/warmup.js CHANGED
@@ -1,33 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.warmup = void 0;
4
+ const common_1 = require("@aeriajs/common");
4
5
  const core_1 = require("@aeriajs/core");
5
6
  const entrypoint_1 = require("@aeriajs/entrypoint");
6
- const AnsiColor = {
7
- Green: '[32m',
8
- Yellow: '[33m',
9
- Blue: '[36m',
10
- Red: '[31m',
11
- White: '[37m',
12
- };
13
- const METHOD_COLORS = {
14
- GET: AnsiColor.Green,
15
- PUT: AnsiColor.Blue,
16
- POST: AnsiColor.White,
17
- DELETE: AnsiColor.Red,
18
- };
19
- const escape = (code, text) => {
20
- const codeStr = Array.isArray(code)
21
- ? code.map((c) => `\x1b${c}`).join('')
22
- : `\x1b${code}`;
23
- return `${codeStr}${text}\x1b[0m`;
24
- };
25
7
  const colorizedRoute = async (method, endpointUri, endpoint) => {
26
8
  const config = await (0, entrypoint_1.getConfig)();
27
- const color = method in METHOD_COLORS
28
- ? METHOD_COLORS[method]
29
- : AnsiColor.White;
30
- let rolesLine = '', hasContractLine = escape(AnsiColor.Yellow, 'x');
9
+ const color = method in common_1.METHOD_COLORS
10
+ ? common_1.METHOD_COLORS[method]
11
+ : common_1.AnsiColor.White;
12
+ let rolesLine = '', hasContractLine = (0, common_1.escape)(common_1.AnsiColor.Yellow, 'x');
31
13
  if (endpoint) {
32
14
  if ('roles' in endpoint) {
33
15
  const roles = await (async () => {
@@ -42,21 +24,21 @@ const colorizedRoute = async (method, endpointUri, endpoint) => {
42
24
  }
43
25
  return endpoint.roles;
44
26
  })();
45
- rolesLine = ` ${escape('[90m', `[${roles.join('|')}]`)}`;
27
+ rolesLine = ` ${(0, common_1.escape)('[90m', `[${roles.join('|')}]`)}`;
46
28
  }
47
29
  if ('response' in endpoint || endpoint.builtin) {
48
- hasContractLine = escape(AnsiColor.Green, '✓');
30
+ hasContractLine = (0, common_1.escape)(common_1.AnsiColor.Green, '✓');
49
31
  }
50
32
  }
51
- let line = escape([
33
+ let line = (0, common_1.escape)([
52
34
  '[1m',
53
35
  color,
54
36
  ], method) + '\t';
55
37
  line += hasContractLine;
56
- line += escape('[90m', ` ${config.baseUrl === '/'
38
+ line += (0, common_1.escape)('[90m', ` ${config.baseUrl === '/'
57
39
  ? ''
58
40
  : config.baseUrl}`);
59
- line += escape('[1m', endpointUri);
41
+ line += (0, common_1.escape)('[1m', endpointUri);
60
42
  line += rolesLine;
61
43
  return line;
62
44
  };
package/dist/warmup.mjs CHANGED
@@ -1,23 +1,7 @@
1
1
  "use strict";
2
+ import { escape, AnsiColor, METHOD_COLORS } from "@aeriajs/common";
2
3
  import { getEndpoints } from "@aeriajs/core";
3
4
  import { getConfig, getAvailableRoles } from "@aeriajs/entrypoint";
4
- const AnsiColor = {
5
- Green: "[32m",
6
- Yellow: "[33m",
7
- Blue: "[36m",
8
- Red: "[31m",
9
- White: "[37m"
10
- };
11
- const METHOD_COLORS = {
12
- GET: AnsiColor.Green,
13
- PUT: AnsiColor.Blue,
14
- POST: AnsiColor.White,
15
- DELETE: AnsiColor.Red
16
- };
17
- const escape = (code, text) => {
18
- const codeStr = Array.isArray(code) ? code.map((c) => `\x1B${c}`).join("") : `\x1B${code}`;
19
- return `${codeStr}${text}\x1B[0m`;
20
- };
21
5
  const colorizedRoute = async (method, endpointUri, endpoint) => {
22
6
  const config = await getConfig();
23
7
  const color = method in METHOD_COLORS ? METHOD_COLORS[method] : AnsiColor.White;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriajs/server",
3
- "version": "0.0.238",
3
+ "version": "0.0.240",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -33,14 +33,14 @@
33
33
  "mongodb": "^6.5.0"
34
34
  },
35
35
  "peerDependencies": {
36
- "@aeriajs/core": "^0.0.236",
37
- "@aeriajs/builtins": "^0.0.236",
38
- "@aeriajs/common": "^0.0.133",
39
- "@aeriajs/entrypoint": "^0.0.137",
40
- "@aeriajs/http": "^0.0.161",
41
- "@aeriajs/node-http": "^0.0.161",
42
- "@aeriajs/server": "^0.0.238",
43
- "@aeriajs/types": "^0.0.115",
36
+ "@aeriajs/core": "^0.0.238",
37
+ "@aeriajs/builtins": "^0.0.238",
38
+ "@aeriajs/common": "^0.0.135",
39
+ "@aeriajs/entrypoint": "^0.0.139",
40
+ "@aeriajs/http": "^0.0.163",
41
+ "@aeriajs/node-http": "^0.0.163",
42
+ "@aeriajs/server": "^0.0.240",
43
+ "@aeriajs/types": "^0.0.117",
44
44
  "mongodb": "^6.5.0"
45
45
  },
46
46
  "scripts": {