apeframework 0.0.0-dev.31 → 0.0.0-dev.33

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.
Files changed (53) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +47 -1
  3. package/dist/cipher/Cipher.js +1 -1
  4. package/dist/cli/utils/formatList.js +1 -1
  5. package/dist/cli/utils/formatTable.js +1 -1
  6. package/dist/cli/utils/formatText.js +1 -1
  7. package/dist/cli/utils/printLn.js +1 -1
  8. package/dist/db/DataType.d.ts +2 -0
  9. package/dist/db/DataType.js +2 -0
  10. package/dist/db/Db.d.ts +10 -0
  11. package/dist/db/Db.js +16 -0
  12. package/dist/db/IndexType.d.ts +6 -0
  13. package/dist/db/IndexType.js +7 -0
  14. package/dist/db/Initializer.d.ts +3 -0
  15. package/dist/db/Initializer.js +1 -0
  16. package/dist/db/Migration.d.ts +6 -0
  17. package/dist/db/Migration.js +1 -0
  18. package/dist/db/MigrationStatus.d.ts +5 -0
  19. package/dist/db/MigrationStatus.js +6 -0
  20. package/dist/db/Migrator.d.ts +20 -0
  21. package/dist/db/Migrator.js +69 -0
  22. package/dist/db/Operator.d.ts +2 -0
  23. package/dist/db/Operator.js +2 -0
  24. package/dist/db/Order.d.ts +2 -0
  25. package/dist/db/Order.js +1 -0
  26. package/dist/db/ReferentialAction.d.ts +7 -0
  27. package/dist/db/ReferentialAction.js +7 -0
  28. package/dist/db/Transaction.d.ts +2 -0
  29. package/dist/db/Transaction.js +1 -0
  30. package/dist/db/adapters/mssql/MssqlDb.d.ts +23 -0
  31. package/dist/db/adapters/mssql/MssqlDb.js +40 -0
  32. package/dist/db/adapters/mysql/MysqlDb.d.ts +23 -0
  33. package/dist/db/adapters/mysql/MysqlDb.js +33 -0
  34. package/dist/db/adapters/postgres/PostgresDb.d.ts +23 -0
  35. package/dist/db/adapters/postgres/PostgresDb.js +33 -0
  36. package/dist/db/adapters/sqlite/SqliteDb.d.ts +10 -0
  37. package/dist/db/adapters/sqlite/SqliteDb.js +20 -0
  38. package/dist/db/adapters/sqlite/Storage.d.ts +4 -0
  39. package/dist/db/adapters/sqlite/Storage.js +4 -0
  40. package/dist/db/relationships.d.ts +28 -0
  41. package/dist/db/relationships.js +15 -0
  42. package/dist/logger/adapters/file/FileLogger.js +2 -2
  43. package/dist/logger/adapters/stdio/StdioLogger.js +2 -2
  44. package/dist/mailer/Attachment.d.ts +1 -1
  45. package/dist/mailer/adapters/noop/NoopMailer.js +1 -1
  46. package/dist/mailer/adapters/smtp/SmtpMailer.js +1 -1
  47. package/dist/mailer/adapters/smtp/getAttachments.d.ts +1 -1
  48. package/dist/server/Server.d.ts +7 -0
  49. package/dist/server/Server.js +9 -1
  50. package/dist/tls/getTls.js +1 -1
  51. package/dist/utils/getRandomHexString.js +1 -1
  52. package/dist/utils/getRandomIntString.js +1 -1
  53. package/package.json +132 -17
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 Matthieu Symoens
3
+ Copyright (c) 2025 Matthieu Symoens
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -4,10 +4,56 @@
4
4
 
5
5
  NPM package: [apeframework](https://www.npmjs.com/package/apeframework).
6
6
 
7
- GitHub repository: [ApeFramework/apeframework](https://github.com/ApeFramework/apeframework).
7
+ GitHub repository: [MattSyms/apeframework](https://github.com/MattSyms/apeframework).
8
8
 
9
9
  ## Installation
10
10
 
11
11
  ```
12
12
  yarn add apeframework
13
13
  ```
14
+
15
+ ## Development
16
+
17
+ Install dependencies:
18
+
19
+ ```
20
+ yarn
21
+ ```
22
+
23
+ Update dependencies:
24
+
25
+ ```
26
+ yarn update
27
+ ```
28
+
29
+ Compile:
30
+
31
+ ```
32
+ yarn compile
33
+ ```
34
+
35
+ Lint:
36
+
37
+ ```
38
+ yarn lint
39
+ ```
40
+
41
+ ## Release:
42
+
43
+ Tag stable release:
44
+
45
+ ```
46
+ git tag v<major>.<minor>.<patch>
47
+ ```
48
+
49
+ Tag dev release:
50
+
51
+ ```
52
+ git tag v0.0.0-dev.<number>
53
+ ```
54
+
55
+ Push tags:
56
+
57
+ ```
58
+ git push --tags
59
+ ```
@@ -1,4 +1,4 @@
1
- import { createCipheriv, createDecipheriv, randomBytes } from 'crypto';
1
+ import { createCipheriv, createDecipheriv, randomBytes } from 'node:crypto';
2
2
  import { DecryptError } from './errors/DecryptError.js';
3
3
  import { validateSecretLength } from './validateSecretLength.js';
4
4
  class Cipher {
@@ -1,4 +1,4 @@
1
- import { EOL } from 'os';
1
+ import { EOL } from 'node:os';
2
2
  const formatList = (list) => {
3
3
  return list
4
4
  .map((item) => { return ` ${item}`; })
@@ -1,4 +1,4 @@
1
- import { EOL } from 'os';
1
+ import { EOL } from 'node:os';
2
2
  const formatTable = (table) => {
3
3
  const colLength = [];
4
4
  table.forEach((row) => {
@@ -1,4 +1,4 @@
1
- import { EOL } from 'os';
1
+ import { EOL } from 'node:os';
2
2
  const formatText = (text) => {
3
3
  return text.join(EOL);
4
4
  };
@@ -1,4 +1,4 @@
1
- import { EOL } from 'os';
1
+ import { EOL } from 'node:os';
2
2
  const printLn = (s) => {
3
3
  process.stdout.write(`${s}${EOL}`);
4
4
  };
@@ -0,0 +1,2 @@
1
+ import { DataTypes } from 'sequelize';
2
+ export { DataTypes as DataType, };
@@ -0,0 +1,2 @@
1
+ import { DataTypes } from 'sequelize';
2
+ export { DataTypes as DataType, };
@@ -0,0 +1,10 @@
1
+ import { Sequelize } from 'sequelize';
2
+ import type { Initializer } from './Initializer.js';
3
+ import type { Options } from 'sequelize';
4
+ declare abstract class Db extends Sequelize {
5
+ protected constructor(params: {
6
+ options: Options;
7
+ initializers?: Initializer[];
8
+ });
9
+ }
10
+ export { Db, };
package/dist/db/Db.js ADDED
@@ -0,0 +1,16 @@
1
+ import { Sequelize } from 'sequelize';
2
+ class Db extends Sequelize {
3
+ constructor(params) {
4
+ super({
5
+ ...params.options,
6
+ define: {
7
+ freezeTableName: true,
8
+ timestamps: false,
9
+ },
10
+ });
11
+ params.initializers?.forEach((initialize) => {
12
+ initialize(this);
13
+ });
14
+ }
15
+ }
16
+ export { Db, };
@@ -0,0 +1,6 @@
1
+ declare enum IndexType {
2
+ FULLTEXT = "FULLTEXT",
3
+ SPATIAL = "SPATIAL",
4
+ UNIQUE = "UNIQUE"
5
+ }
6
+ export { IndexType, };
@@ -0,0 +1,7 @@
1
+ var IndexType;
2
+ (function (IndexType) {
3
+ IndexType["FULLTEXT"] = "FULLTEXT";
4
+ IndexType["SPATIAL"] = "SPATIAL";
5
+ IndexType["UNIQUE"] = "UNIQUE";
6
+ })(IndexType || (IndexType = {}));
7
+ export { IndexType, };
@@ -0,0 +1,3 @@
1
+ import type { Sequelize } from 'sequelize';
2
+ type Initializer = (db: Sequelize) => void;
3
+ export { type Initializer, };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { QueryInterface } from 'sequelize';
2
+ interface Migration {
3
+ up: (db: QueryInterface) => Promise<void>;
4
+ down: (db: QueryInterface) => Promise<void>;
5
+ }
6
+ export { type Migration, };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ declare enum MigrationStatus {
2
+ APPLIED = "APPLIED",
3
+ PENDING = "PENDING"
4
+ }
5
+ export { MigrationStatus, };
@@ -0,0 +1,6 @@
1
+ var MigrationStatus;
2
+ (function (MigrationStatus) {
3
+ MigrationStatus["APPLIED"] = "APPLIED";
4
+ MigrationStatus["PENDING"] = "PENDING";
5
+ })(MigrationStatus || (MigrationStatus = {}));
6
+ export { MigrationStatus, };
@@ -0,0 +1,20 @@
1
+ import { MigrationStatus } from './MigrationStatus.js';
2
+ import type { Db } from './Db.js';
3
+ declare class Migrator {
4
+ private readonly umzug;
5
+ constructor(params: {
6
+ db: Db;
7
+ modelName: string;
8
+ directory: string;
9
+ extension: string;
10
+ onApply?: (name: string) => void;
11
+ onRevert?: (name: string) => void;
12
+ });
13
+ list(status?: MigrationStatus): Promise<{
14
+ name: string;
15
+ status: MigrationStatus;
16
+ }[]>;
17
+ apply(count?: number): Promise<string[]>;
18
+ revert(count?: number): Promise<string[]>;
19
+ }
20
+ export { Migrator, };
@@ -0,0 +1,69 @@
1
+ import { basename, extname } from 'node:path';
2
+ import { SequelizeStorage, Umzug } from 'umzug';
3
+ import { MigrationStatus } from './MigrationStatus.js';
4
+ class Migrator {
5
+ umzug;
6
+ constructor(params) {
7
+ const glob = `${params.directory}/*.${params.extension}`;
8
+ const resolve = ({ name: filename, context }) => {
9
+ const name = basename(filename, extname(filename));
10
+ const up = async ({ path }) => {
11
+ const migration = await import(String(path));
12
+ await migration.up(context);
13
+ };
14
+ const down = async ({ path }) => {
15
+ const migration = await import(String(path));
16
+ await migration.down(context);
17
+ };
18
+ return { name, up, down };
19
+ };
20
+ this.umzug = new Umzug({
21
+ storage: new SequelizeStorage({
22
+ sequelize: params.db,
23
+ modelName: params.modelName,
24
+ }),
25
+ migrations: { glob, resolve },
26
+ context: params.db.getQueryInterface(),
27
+ logger: undefined,
28
+ });
29
+ this.umzug.on('migrating', (e) => {
30
+ params.onApply?.(e.name);
31
+ });
32
+ this.umzug.on('reverting', (e) => {
33
+ params.onRevert?.(e.name);
34
+ });
35
+ }
36
+ async list(status) {
37
+ return [
38
+ ...status === MigrationStatus.PENDING
39
+ ? []
40
+ : (await this.umzug.executed()).map((migration) => {
41
+ return {
42
+ name: migration.name,
43
+ status: MigrationStatus.APPLIED,
44
+ };
45
+ }),
46
+ ...status === MigrationStatus.APPLIED
47
+ ? []
48
+ : (await this.umzug.pending()).map((migration) => {
49
+ return {
50
+ name: migration.name,
51
+ status: MigrationStatus.PENDING,
52
+ };
53
+ }),
54
+ ];
55
+ }
56
+ async apply(count) {
57
+ return (await this.umzug.up(count ? { step: count } : undefined))
58
+ .map((migration) => {
59
+ return migration.name;
60
+ });
61
+ }
62
+ async revert(count) {
63
+ return (await this.umzug.down(count ? { step: count } : { to: 0 }))
64
+ .map((migration) => {
65
+ return migration.name;
66
+ });
67
+ }
68
+ }
69
+ export { Migrator, };
@@ -0,0 +1,2 @@
1
+ import { Op } from 'sequelize';
2
+ export { Op as Operator, };
@@ -0,0 +1,2 @@
1
+ import { Op } from 'sequelize';
2
+ export { Op as Operator, };
@@ -0,0 +1,2 @@
1
+ import type { Order } from 'sequelize';
2
+ export { type Order, };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ declare const ReferentialAction: {
2
+ CASCADE: string;
3
+ RESTRICT: string;
4
+ SET_DEFAULT: string;
5
+ SET_NULL: string;
6
+ };
7
+ export { ReferentialAction, };
@@ -0,0 +1,7 @@
1
+ const ReferentialAction = {
2
+ CASCADE: 'CASCADE',
3
+ RESTRICT: 'RESTRICT',
4
+ SET_DEFAULT: 'SET DEFAULT',
5
+ SET_NULL: 'SET NULL',
6
+ };
7
+ export { ReferentialAction, };
@@ -0,0 +1,2 @@
1
+ import type { Transaction } from 'sequelize';
2
+ export { type Transaction, };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,23 @@
1
+ import { Db } from '../../Db.js';
2
+ import type { Tls } from '../../../tls/Tls.js';
3
+ import type { Initializer } from '../../Initializer.js';
4
+ declare class MssqlDb extends Db {
5
+ constructor(params: {
6
+ host: string;
7
+ port?: number;
8
+ tls?: Tls | boolean;
9
+ user: string;
10
+ password: string;
11
+ database: string;
12
+ minConnections?: number;
13
+ maxConnections?: number;
14
+ connectionTimeout?: number;
15
+ connectionAcquireTimeout?: number;
16
+ connectionIdleTimeout?: number;
17
+ connectionEvictInterval?: number;
18
+ connectionMaxUses?: number;
19
+ initializers?: Initializer[];
20
+ onQuery?: (message: string) => void;
21
+ });
22
+ }
23
+ export { MssqlDb, };
@@ -0,0 +1,40 @@
1
+ import { getTls } from '../../../tls/getTls.js';
2
+ import { Db } from '../../Db.js';
3
+ class MssqlDb extends Db {
4
+ constructor(params) {
5
+ const tls = typeof params.tls === 'boolean'
6
+ ? undefined
7
+ : getTls(params.tls);
8
+ super({
9
+ options: {
10
+ dialect: 'mssql',
11
+ dialectOptions: {
12
+ options: {
13
+ encrypt: typeof params.tls === 'boolean'
14
+ ? params.tls
15
+ : Boolean(tls),
16
+ cryptoCredentialsDetails: tls,
17
+ trustServerCertificate: tls?.rejectUnauthorized === false,
18
+ connectTimeout: params.connectionTimeout ?? 10000,
19
+ },
20
+ },
21
+ host: params.host,
22
+ port: params.port ?? 1433,
23
+ username: params.user,
24
+ password: params.password,
25
+ database: params.database,
26
+ pool: {
27
+ min: params.minConnections ?? 0,
28
+ max: params.maxConnections ?? 10,
29
+ acquire: params.connectionAcquireTimeout ?? 30000,
30
+ idle: params.connectionIdleTimeout ?? 30000,
31
+ evict: params.connectionEvictInterval ?? 30000,
32
+ maxUses: params.connectionMaxUses ?? 100,
33
+ },
34
+ logging: params.onQuery,
35
+ },
36
+ initializers: params.initializers,
37
+ });
38
+ }
39
+ }
40
+ export { MssqlDb, };
@@ -0,0 +1,23 @@
1
+ import { Db } from '../../Db.js';
2
+ import type { Tls } from '../../../tls/Tls.js';
3
+ import type { Initializer } from '../../Initializer.js';
4
+ declare class MysqlDb extends Db {
5
+ constructor(params: {
6
+ host: string;
7
+ port?: number;
8
+ tls?: Tls | boolean;
9
+ user: string;
10
+ password: string;
11
+ database: string;
12
+ minConnections?: number;
13
+ maxConnections?: number;
14
+ connectionTimeout?: number;
15
+ connectionAcquireTimeout?: number;
16
+ connectionIdleTimeout?: number;
17
+ connectionEvictInterval?: number;
18
+ connectionMaxUses?: number;
19
+ initializers?: Initializer[];
20
+ onQuery?: (message: string) => void;
21
+ });
22
+ }
23
+ export { MysqlDb, };
@@ -0,0 +1,33 @@
1
+ import { getTls } from '../../../tls/getTls.js';
2
+ import { Db } from '../../Db.js';
3
+ class MysqlDb extends Db {
4
+ constructor(params) {
5
+ super({
6
+ options: {
7
+ dialect: 'mysql',
8
+ dialectOptions: {
9
+ ssl: typeof params.tls === 'boolean'
10
+ ? params.tls
11
+ : getTls(params.tls),
12
+ connectTimeout: params.connectionTimeout ?? 10000,
13
+ },
14
+ host: params.host,
15
+ port: params.port ?? 3306,
16
+ username: params.user,
17
+ password: params.password,
18
+ database: params.database,
19
+ pool: {
20
+ min: params.minConnections ?? 0,
21
+ max: params.maxConnections ?? 10,
22
+ acquire: params.connectionAcquireTimeout ?? 30000,
23
+ idle: params.connectionIdleTimeout ?? 30000,
24
+ evict: params.connectionEvictInterval ?? 30000,
25
+ maxUses: params.connectionMaxUses ?? 100,
26
+ },
27
+ logging: params.onQuery,
28
+ },
29
+ initializers: params.initializers,
30
+ });
31
+ }
32
+ }
33
+ export { MysqlDb, };
@@ -0,0 +1,23 @@
1
+ import { Db } from '../../Db.js';
2
+ import type { Tls } from '../../../tls/Tls.js';
3
+ import type { Initializer } from '../../Initializer.js';
4
+ declare class PostgresDb extends Db {
5
+ constructor(params: {
6
+ host: string;
7
+ port?: number;
8
+ tls?: Tls | boolean;
9
+ user: string;
10
+ password: string;
11
+ database: string;
12
+ minConnections?: number;
13
+ maxConnections?: number;
14
+ connectionTimeout?: number;
15
+ connectionAcquireTimeout?: number;
16
+ connectionIdleTimeout?: number;
17
+ connectionEvictInterval?: number;
18
+ connectionMaxUses?: number;
19
+ initializers?: Initializer[];
20
+ onQuery?: (message: string) => void;
21
+ });
22
+ }
23
+ export { PostgresDb, };
@@ -0,0 +1,33 @@
1
+ import { getTls } from '../../../tls/getTls.js';
2
+ import { Db } from '../../Db.js';
3
+ class PostgresDb extends Db {
4
+ constructor(params) {
5
+ super({
6
+ options: {
7
+ dialect: 'postgres',
8
+ dialectOptions: {
9
+ ssl: typeof params.tls === 'boolean'
10
+ ? params.tls
11
+ : getTls(params.tls),
12
+ connectionTimeoutMillis: params.connectionTimeout ?? 10000,
13
+ },
14
+ host: params.host,
15
+ port: params.port ?? 5432,
16
+ username: params.user,
17
+ password: params.password,
18
+ database: params.database,
19
+ pool: {
20
+ min: params.minConnections ?? 0,
21
+ max: params.maxConnections ?? 10,
22
+ acquire: params.connectionAcquireTimeout ?? 30000,
23
+ idle: params.connectionIdleTimeout ?? 30000,
24
+ evict: params.connectionEvictInterval ?? 30000,
25
+ maxUses: params.connectionMaxUses ?? 100,
26
+ },
27
+ logging: params.onQuery,
28
+ },
29
+ initializers: params.initializers,
30
+ });
31
+ }
32
+ }
33
+ export { PostgresDb, };
@@ -0,0 +1,10 @@
1
+ import { Db } from '../../Db.js';
2
+ import type { Initializer } from '../../Initializer.js';
3
+ declare class SqliteDb extends Db {
4
+ constructor(params: {
5
+ storage: string;
6
+ initializers?: Initializer[];
7
+ onQuery?: (message: string) => void;
8
+ });
9
+ }
10
+ export { SqliteDb, };
@@ -0,0 +1,20 @@
1
+ import SQLite from 'sqlite3';
2
+ import { Db } from '../../Db.js';
3
+ class SqliteDb extends Db {
4
+ constructor(params) {
5
+ super({
6
+ options: {
7
+ dialect: 'sqlite',
8
+ dialectOptions: {
9
+ mode: SQLite.OPEN_FULLMUTEX
10
+ | SQLite.OPEN_READWRITE
11
+ | SQLite.OPEN_CREATE,
12
+ },
13
+ storage: params.storage,
14
+ logging: params.onQuery,
15
+ },
16
+ initializers: params.initializers,
17
+ });
18
+ }
19
+ }
20
+ export { SqliteDb, };
@@ -0,0 +1,4 @@
1
+ declare const Storage: {
2
+ MEMORY: string;
3
+ };
4
+ export { Storage, };
@@ -0,0 +1,4 @@
1
+ const Storage = {
2
+ MEMORY: ':memory:',
3
+ };
4
+ export { Storage, };
@@ -0,0 +1,28 @@
1
+ import type { Model, ModelStatic } from 'sequelize';
2
+ declare const oneToOne: (fk: string, a: {
3
+ model: ModelStatic<Model>;
4
+ asOne: string;
5
+ }, b: {
6
+ model: ModelStatic<Model>;
7
+ asOne: string;
8
+ }) => void;
9
+ declare const oneToMany: (fk: string, a: {
10
+ model: ModelStatic<Model>;
11
+ asOne: string;
12
+ }, b: {
13
+ model: ModelStatic<Model>;
14
+ asMany: string;
15
+ }) => void;
16
+ declare const manyToMany: (fkA: string, fkB: string, a: {
17
+ model: ModelStatic<Model>;
18
+ asOne: string;
19
+ asMany: string;
20
+ }, b: {
21
+ model: ModelStatic<Model>;
22
+ asOne: string;
23
+ asMany: string;
24
+ }, through: {
25
+ model: ModelStatic<Model>;
26
+ asMany: string;
27
+ }) => void;
28
+ export { manyToMany, oneToMany, oneToOne, };
@@ -0,0 +1,15 @@
1
+ const oneToOne = (fk, a, b) => {
2
+ a.model.hasOne(b.model, { foreignKey: fk, as: b.asOne });
3
+ b.model.belongsTo(a.model, { foreignKey: fk, as: a.asOne });
4
+ };
5
+ const oneToMany = (fk, a, b) => {
6
+ a.model.hasMany(b.model, { foreignKey: fk, as: b.asMany });
7
+ b.model.belongsTo(a.model, { foreignKey: fk, as: a.asOne });
8
+ };
9
+ const manyToMany = (fkA, fkB, a, b, through) => {
10
+ a.model.belongsToMany(b.model, { through: through.model, foreignKey: fkA, otherKey: fkB, as: b.asMany });
11
+ b.model.belongsToMany(a.model, { through: through.model, foreignKey: fkB, otherKey: fkA, as: a.asMany });
12
+ oneToMany(fkA, a, through);
13
+ oneToMany(fkB, b, through);
14
+ };
15
+ export { manyToMany, oneToMany, oneToOne, };
@@ -1,4 +1,4 @@
1
- import { pino } from 'pino';
1
+ import { destination, pino } from 'pino';
2
2
  import { Level } from '../../Level.js';
3
3
  import { Logger } from '../../Logger.js';
4
4
  import { initFile } from './initFile.js';
@@ -8,7 +8,7 @@ class FileLogger extends Logger {
8
8
  constructor(params) {
9
9
  super();
10
10
  initFile(params.path);
11
- const stream = pino.destination(params.path);
11
+ const stream = destination(params.path);
12
12
  this.logger = pino({
13
13
  enabled: params.level !== Level.OFF,
14
14
  level: params.level ?? Level.INFO,
@@ -1,4 +1,4 @@
1
- import { pino } from 'pino';
1
+ import { destination, pino } from 'pino';
2
2
  import pretty from 'pino-pretty';
3
3
  import { Level } from '../../Level.js';
4
4
  import { Logger } from '../../Logger.js';
@@ -9,7 +9,7 @@ class StdioLogger extends Logger {
9
9
  super();
10
10
  const stream = params?.pretty
11
11
  ? pretty()
12
- : pino.destination(process.stdout.fd);
12
+ : destination(process.stdout.fd);
13
13
  this.logger = pino({
14
14
  enabled: params?.level !== Level.OFF,
15
15
  level: params?.level ?? Level.INFO,
@@ -1,4 +1,4 @@
1
- import type { Readable } from 'stream';
1
+ import type { Readable } from 'node:stream';
2
2
  interface Attachment {
3
3
  fileName: string;
4
4
  contentType?: string;
@@ -1,4 +1,4 @@
1
- import { randomUUID } from 'crypto';
1
+ import { randomUUID } from 'node:crypto';
2
2
  import { Mailer } from '../../Mailer.js';
3
3
  class NoopMailer extends Mailer {
4
4
  async sendMail(mail) {
@@ -21,7 +21,7 @@ class SmtpMailer extends Mailer {
21
21
  }
22
22
  : undefined,
23
23
  pool: true,
24
- maxConnections: params.maxConnections ?? 5,
24
+ maxConnections: params.maxConnections ?? 10,
25
25
  });
26
26
  }
27
27
  async sendMail(mail) {
@@ -1,5 +1,5 @@
1
1
  import type { Attachment } from '../../Attachment.js';
2
- import type { Readable } from 'stream';
2
+ import type { Readable } from 'node:stream';
3
3
  interface NodemailerAttachment {
4
4
  filename: string;
5
5
  cid: string;
@@ -13,6 +13,13 @@ declare class Server {
13
13
  port?: number;
14
14
  routes: Route[];
15
15
  formats?: Format[];
16
+ trustProxy?: boolean;
17
+ connectionTimeout?: number;
18
+ requestTimeout?: number;
19
+ keepAliveTimeout?: number;
20
+ connectionMaxUses?: number;
21
+ maxParams?: number;
22
+ maxBodySize?: number;
16
23
  openapi?: {
17
24
  name?: string;
18
25
  version?: string;
@@ -13,7 +13,15 @@ class Server {
13
13
  constructor(params) {
14
14
  this.host = params.host;
15
15
  this.port = params.port;
16
- this.server = fastify();
16
+ this.server = fastify({
17
+ trustProxy: params.trustProxy ?? false,
18
+ connectionTimeout: params.connectionTimeout ?? 30000,
19
+ requestTimeout: params.requestTimeout ?? 30000,
20
+ keepAliveTimeout: params.keepAliveTimeout ?? 30000,
21
+ maxRequestsPerSocket: params.connectionMaxUses ?? 100,
22
+ maxParamLength: params.maxParams ?? 100,
23
+ bodyLimit: params.maxBodySize ?? 1000000,
24
+ });
17
25
  const ajv = getAjv(params.formats);
18
26
  this.server.setValidatorCompiler(({ schema }) => {
19
27
  return ajv.compile(schema);
@@ -6,7 +6,7 @@ const getTls = (tls) => {
6
6
  ...tls.cert ? { cert: readFile(tls.cert) } : {},
7
7
  ...tls.ca ? { ca: readFile(tls.ca) } : {},
8
8
  ...tls.verify === undefined
9
- ? {}
9
+ ? { rejectUnauthorized: true }
10
10
  : { rejectUnauthorized: tls.verify },
11
11
  }
12
12
  : undefined;
@@ -1,4 +1,4 @@
1
- import { randomBytes } from 'crypto';
1
+ import { randomBytes } from 'node:crypto';
2
2
  const getRandomHexString = (length) => {
3
3
  return randomBytes(length / 2 + 1).toString('hex').substring(0, length);
4
4
  };
@@ -1,4 +1,4 @@
1
- import { randomInt } from 'crypto';
1
+ import { randomInt } from 'node:crypto';
2
2
  const getRandomIntString = (length) => {
3
3
  let string = '';
4
4
  for (let i = 0; i < length; i += 1) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apeframework",
3
- "version": "0.0.0-dev.31",
3
+ "version": "0.0.0-dev.33",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -14,40 +14,47 @@
14
14
  ],
15
15
  "repository": {
16
16
  "type": "git",
17
- "url": "git+https://github.com/ApeFramework/apeframework.git"
17
+ "url": "git+https://github.com/MattSyms/apeframework.git"
18
18
  },
19
19
  "type": "module",
20
20
  "engines": {
21
21
  "node": ">=22"
22
22
  },
23
23
  "dependencies": {
24
- "@fastify/compress": "^8.0",
24
+ "@fastify/compress": "^8.1",
25
25
  "@fastify/cookie": "^11.0",
26
- "@fastify/cors": "^11.0",
26
+ "@fastify/cors": "^11.1",
27
27
  "@fastify/response-validation": "^3.0",
28
28
  "@fastify/swagger": "^9.5",
29
29
  "@types/fs-extra": "^11.0",
30
- "@types/nodemailer": "^6.4",
30
+ "@types/nodemailer": "^7.0",
31
31
  "@types/yargs-parser": "^21.0",
32
32
  "ajv": "^8.17",
33
- "argon2": "^0.43",
34
- "bullmq": "^5.53",
35
- "dotenv": "^16.5",
36
- "fast-uri": "^3.0",
37
- "fastify": "^5.3",
33
+ "argon2": "^0.44",
34
+ "bullmq": "^5.63",
35
+ "dotenv": "^17.2",
36
+ "fast-uri": "^3.1",
37
+ "fastify": "^5.6",
38
38
  "fs-extra": "^11.3",
39
- "ical-generator": "^9.0",
40
- "ioredis": "^5.6",
41
- "jose": "^6.0",
39
+ "ical-generator": "^10.0",
40
+ "ioredis": "^5.8",
41
+ "jose": "^6.1",
42
+ "mariadb": "^3.4",
43
+ "mysql2": "^3.15",
42
44
  "nodemailer": "^7.0",
43
45
  "openapi-types": "^12.1",
44
- "pino": "^9.7",
45
- "pino-pretty": "^13.0",
46
+ "pg": "^8.16",
47
+ "pg-hstore": "^2.3",
48
+ "pino": "^10.1",
49
+ "pino-pretty": "^13.1",
50
+ "sequelize": "^6.37",
51
+ "sqlite3": "^5.1",
52
+ "umzug": "^3.8",
46
53
  "yargs-parser": "^22.0"
47
54
  },
48
55
  "peerDependencies": {
49
- "@types/node": "^24.0",
50
- "typescript": "^5.8"
56
+ "@types/node": "^24.10",
57
+ "typescript": "^5.9"
51
58
  },
52
59
  "exports": {
53
60
  "./cipher/Algorithm": {
@@ -200,6 +207,114 @@
200
207
  "default": "./dist/config/validatePropertyName.js"
201
208
  }
202
209
  },
210
+ "./db/DataType": {
211
+ "import": {
212
+ "types": "./dist/db/DataType.d.ts",
213
+ "default": "./dist/db/DataType.js"
214
+ }
215
+ },
216
+ "./db/Db": {
217
+ "import": {
218
+ "types": "./dist/db/Db.d.ts",
219
+ "default": "./dist/db/Db.js"
220
+ }
221
+ },
222
+ "./db/IndexType": {
223
+ "import": {
224
+ "types": "./dist/db/IndexType.d.ts",
225
+ "default": "./dist/db/IndexType.js"
226
+ }
227
+ },
228
+ "./db/Initializer": {
229
+ "import": {
230
+ "types": "./dist/db/Initializer.d.ts",
231
+ "default": "./dist/db/Initializer.js"
232
+ }
233
+ },
234
+ "./db/Migration": {
235
+ "import": {
236
+ "types": "./dist/db/Migration.d.ts",
237
+ "default": "./dist/db/Migration.js"
238
+ }
239
+ },
240
+ "./db/MigrationStatus": {
241
+ "import": {
242
+ "types": "./dist/db/MigrationStatus.d.ts",
243
+ "default": "./dist/db/MigrationStatus.js"
244
+ }
245
+ },
246
+ "./db/Migrator": {
247
+ "import": {
248
+ "types": "./dist/db/Migrator.d.ts",
249
+ "default": "./dist/db/Migrator.js"
250
+ }
251
+ },
252
+ "./db/Operator": {
253
+ "import": {
254
+ "types": "./dist/db/Operator.d.ts",
255
+ "default": "./dist/db/Operator.js"
256
+ }
257
+ },
258
+ "./db/Order": {
259
+ "import": {
260
+ "types": "./dist/db/Order.d.ts",
261
+ "default": "./dist/db/Order.js"
262
+ }
263
+ },
264
+ "./db/ReferentialAction": {
265
+ "import": {
266
+ "types": "./dist/db/ReferentialAction.d.ts",
267
+ "default": "./dist/db/ReferentialAction.js"
268
+ }
269
+ },
270
+ "./db/Transaction": {
271
+ "import": {
272
+ "types": "./dist/db/Transaction.d.ts",
273
+ "default": "./dist/db/Transaction.js"
274
+ }
275
+ },
276
+ "./db/adapters/maria/MariaDb": {
277
+ "import": {
278
+ "types": "./dist/db/adapters/maria/MariaDb.d.ts",
279
+ "default": "./dist/db/adapters/maria/MariaDb.js"
280
+ }
281
+ },
282
+ "./db/adapters/mssql/MssqlDb": {
283
+ "import": {
284
+ "types": "./dist/db/adapters/mssql/MssqlDb.d.ts",
285
+ "default": "./dist/db/adapters/mssql/MssqlDb.js"
286
+ }
287
+ },
288
+ "./db/adapters/mysql/MysqlDb": {
289
+ "import": {
290
+ "types": "./dist/db/adapters/mysql/MysqlDb.d.ts",
291
+ "default": "./dist/db/adapters/mysql/MysqlDb.js"
292
+ }
293
+ },
294
+ "./db/adapters/postgres/PostgresDb": {
295
+ "import": {
296
+ "types": "./dist/db/adapters/postgres/PostgresDb.d.ts",
297
+ "default": "./dist/db/adapters/postgres/PostgresDb.js"
298
+ }
299
+ },
300
+ "./db/adapters/sqlite/SqliteDb": {
301
+ "import": {
302
+ "types": "./dist/db/adapters/sqlite/SqliteDb.d.ts",
303
+ "default": "./dist/db/adapters/sqlite/SqliteDb.js"
304
+ }
305
+ },
306
+ "./db/adapters/sqlite/Storage": {
307
+ "import": {
308
+ "types": "./dist/db/adapters/sqlite/Storage.d.ts",
309
+ "default": "./dist/db/adapters/sqlite/Storage.js"
310
+ }
311
+ },
312
+ "./db/relationships": {
313
+ "import": {
314
+ "types": "./dist/db/relationships.d.ts",
315
+ "default": "./dist/db/relationships.js"
316
+ }
317
+ },
203
318
  "./env/Env": {
204
319
  "import": {
205
320
  "types": "./dist/env/Env.d.ts",