apeframework 0.3.0 → 0.4.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/LICENSE +1 -1
- package/README.md +2 -2
- package/dist/db/Db.d.ts +10 -3
- package/dist/db/Db.js +16 -1
- package/dist/db/Migrator.d.ts +2 -0
- package/dist/db/Migrator.js +6 -6
- package/dist/db/adapters/maria/MariaDb.d.ts +23 -0
- package/dist/db/adapters/maria/MariaDb.js +33 -0
- package/dist/db/adapters/mssql/MssqlDb.d.ts +23 -0
- package/dist/db/adapters/mssql/MssqlDb.js +40 -0
- package/dist/db/adapters/mysql/MysqlDb.d.ts +11 -4
- package/dist/db/adapters/mysql/MysqlDb.js +27 -16
- package/dist/db/adapters/postgres/PostgresDb.d.ts +23 -0
- package/dist/db/adapters/postgres/PostgresDb.js +33 -0
- package/dist/db/adapters/sqlite/SqliteDb.d.ts +10 -0
- package/dist/db/adapters/sqlite/SqliteDb.js +20 -0
- package/dist/db/adapters/sqlite/Storage.d.ts +4 -0
- package/dist/db/adapters/sqlite/Storage.js +4 -0
- package/dist/mailer/adapters/smtp/SmtpMailer.js +1 -1
- package/dist/server/InjectParams.d.ts +3 -0
- package/dist/server/InjectParams.js +1 -0
- package/dist/server/InjectResponse.d.ts +3 -0
- package/dist/server/InjectResponse.js +1 -0
- package/dist/server/Route.d.ts +2 -1
- package/dist/server/Schema.d.ts +2 -2
- package/dist/server/Server.d.ts +18 -10
- package/dist/server/Server.js +42 -15
- package/dist/server/multipartErrorCodes.d.ts +2 -0
- package/dist/server/multipartErrorCodes.js +12 -0
- package/dist/tls/getTls.js +1 -1
- package/package.json +70 -15
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -43,13 +43,13 @@ yarn lint
|
|
|
43
43
|
Tag stable release:
|
|
44
44
|
|
|
45
45
|
```
|
|
46
|
-
git tag v<major>.<minor>.<patch>
|
|
46
|
+
git tag framework@v<major>.<minor>.<patch>
|
|
47
47
|
```
|
|
48
48
|
|
|
49
49
|
Tag dev release:
|
|
50
50
|
|
|
51
51
|
```
|
|
52
|
-
git tag v0.0.0-dev.<number>
|
|
52
|
+
git tag framework@v0.0.0-dev.<number>
|
|
53
53
|
```
|
|
54
54
|
|
|
55
55
|
Push tags:
|
package/dist/db/Db.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
type
|
|
3
|
-
|
|
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
CHANGED
|
@@ -1 +1,16 @@
|
|
|
1
|
-
|
|
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, };
|
package/dist/db/Migrator.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { MigrationStatus } from './MigrationStatus.js';
|
|
2
2
|
import type { Db } from './Db.js';
|
|
3
|
+
import type { Migration } from './Migration.js';
|
|
3
4
|
declare class Migrator {
|
|
4
5
|
private readonly umzug;
|
|
5
6
|
constructor(params: {
|
|
@@ -7,6 +8,7 @@ declare class Migrator {
|
|
|
7
8
|
modelName: string;
|
|
8
9
|
directory: string;
|
|
9
10
|
extension: string;
|
|
11
|
+
load: (path: string) => Promise<Migration>;
|
|
10
12
|
onApply?: (name: string) => void;
|
|
11
13
|
onRevert?: (name: string) => void;
|
|
12
14
|
});
|
package/dist/db/Migrator.js
CHANGED
|
@@ -7,13 +7,13 @@ class Migrator {
|
|
|
7
7
|
const glob = `${params.directory}/*.${params.extension}`;
|
|
8
8
|
const resolve = ({ name: filename, context }) => {
|
|
9
9
|
const name = basename(filename, extname(filename));
|
|
10
|
-
const up = async ({ path
|
|
11
|
-
const
|
|
12
|
-
await
|
|
10
|
+
const up = async ({ path }) => {
|
|
11
|
+
const migration = await params.load(String(path));
|
|
12
|
+
await migration.up(context);
|
|
13
13
|
};
|
|
14
|
-
const down = async ({ path
|
|
15
|
-
const
|
|
16
|
-
await
|
|
14
|
+
const down = async ({ path }) => {
|
|
15
|
+
const migration = await params.load(String(path));
|
|
16
|
+
await migration.down(context);
|
|
17
17
|
};
|
|
18
18
|
return { name, up, down };
|
|
19
19
|
};
|
|
@@ -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 MariaDb 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 { MariaDb, };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { getTls } from '../../../tls/getTls.js';
|
|
2
|
+
import { Db } from '../../Db.js';
|
|
3
|
+
class MariaDb extends Db {
|
|
4
|
+
constructor(params) {
|
|
5
|
+
super({
|
|
6
|
+
options: {
|
|
7
|
+
dialect: 'mariadb',
|
|
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 { MariaDb, };
|
|
@@ -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, };
|
|
@@ -1,16 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
1
|
+
import { Db } from '../../Db.js';
|
|
2
|
+
import type { Tls } from '../../../tls/Tls.js';
|
|
3
3
|
import type { Initializer } from '../../Initializer.js';
|
|
4
|
-
declare class MysqlDb extends
|
|
4
|
+
declare class MysqlDb extends Db {
|
|
5
5
|
constructor(params: {
|
|
6
6
|
host: string;
|
|
7
7
|
port?: number;
|
|
8
|
+
tls?: Tls | boolean;
|
|
8
9
|
user: string;
|
|
9
10
|
password: string;
|
|
10
11
|
database: string;
|
|
12
|
+
minConnections?: number;
|
|
11
13
|
maxConnections?: number;
|
|
14
|
+
connectionTimeout?: number;
|
|
15
|
+
connectionAcquireTimeout?: number;
|
|
16
|
+
connectionIdleTimeout?: number;
|
|
17
|
+
connectionEvictInterval?: number;
|
|
18
|
+
connectionMaxUses?: number;
|
|
12
19
|
initializers?: Initializer[];
|
|
13
|
-
|
|
20
|
+
onQuery?: (message: string) => void;
|
|
14
21
|
});
|
|
15
22
|
}
|
|
16
23
|
export { MysqlDb, };
|
|
@@ -1,21 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { getTls } from '../../../tls/getTls.js';
|
|
2
|
+
import { Db } from '../../Db.js';
|
|
3
|
+
class MysqlDb extends Db {
|
|
3
4
|
constructor(params) {
|
|
4
|
-
super(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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,
|
|
10
28
|
},
|
|
11
|
-
|
|
12
|
-
freezeTableName: true,
|
|
13
|
-
timestamps: false,
|
|
14
|
-
},
|
|
15
|
-
logging: params.onLog,
|
|
16
|
-
});
|
|
17
|
-
params.initializers?.forEach((initialize) => {
|
|
18
|
-
initialize(this);
|
|
29
|
+
initializers: params.initializers,
|
|
19
30
|
});
|
|
20
31
|
}
|
|
21
32
|
}
|
|
@@ -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 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/server/Route.d.ts
CHANGED
|
@@ -2,10 +2,11 @@ import type { Handler } from './Handler.js';
|
|
|
2
2
|
import type { Method } from './Method.js';
|
|
3
3
|
import type { Schema } from './Schema.js';
|
|
4
4
|
interface Route {
|
|
5
|
-
path: string;
|
|
6
5
|
method: Method;
|
|
6
|
+
path: string;
|
|
7
7
|
name?: string;
|
|
8
8
|
description?: string;
|
|
9
|
+
tags?: string[];
|
|
9
10
|
schema: Schema;
|
|
10
11
|
handler: Handler;
|
|
11
12
|
}
|
package/dist/server/Schema.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ interface Schema {
|
|
|
3
3
|
params?: OpenAPIV3.SchemaObject;
|
|
4
4
|
query?: OpenAPIV3.SchemaObject;
|
|
5
5
|
headers?: OpenAPIV3.SchemaObject;
|
|
6
|
-
body?: OpenAPIV3.
|
|
7
|
-
response?:
|
|
6
|
+
body?: OpenAPIV3.RequestBodyObject;
|
|
7
|
+
response?: OpenAPIV3.ResponsesObject;
|
|
8
8
|
}
|
|
9
9
|
export { type Schema, };
|
package/dist/server/Server.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { OpenApiFormat } from './OpenApiFormat.js';
|
|
|
2
2
|
import type { ErrorHandler } from './ErrorHandler.js';
|
|
3
3
|
import type { Format } from './Format.js';
|
|
4
4
|
import type { Handler } from './Handler.js';
|
|
5
|
+
import type { InjectParams } from './InjectParams.js';
|
|
6
|
+
import type { InjectResponse } from './InjectResponse.js';
|
|
5
7
|
import type { Route } from './Route.js';
|
|
6
8
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
7
9
|
declare class Server {
|
|
@@ -11,20 +13,28 @@ declare class Server {
|
|
|
11
13
|
constructor(params: {
|
|
12
14
|
host: string;
|
|
13
15
|
port?: number;
|
|
16
|
+
openapi?: {
|
|
17
|
+
name?: string;
|
|
18
|
+
version?: string;
|
|
19
|
+
};
|
|
14
20
|
routes: Route[];
|
|
15
21
|
formats?: Format[];
|
|
22
|
+
validateResponses?: boolean;
|
|
16
23
|
trustProxy?: boolean;
|
|
17
24
|
connectionTimeout?: number;
|
|
18
25
|
requestTimeout?: number;
|
|
19
26
|
keepAliveTimeout?: number;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
connectionMaxUses?: number;
|
|
28
|
+
bodyMaxSize?: number;
|
|
29
|
+
form?: {
|
|
30
|
+
enabled?: boolean;
|
|
31
|
+
};
|
|
32
|
+
multipart?: {
|
|
33
|
+
enabled?: boolean;
|
|
34
|
+
maxFiles?: number;
|
|
35
|
+
fileMaxSize?: number;
|
|
26
36
|
};
|
|
27
|
-
|
|
37
|
+
cookies?: {
|
|
28
38
|
enabled?: boolean;
|
|
29
39
|
};
|
|
30
40
|
compression?: {
|
|
@@ -39,9 +49,6 @@ declare class Server {
|
|
|
39
49
|
exposedHeaders?: string[];
|
|
40
50
|
allowCredentials?: boolean;
|
|
41
51
|
};
|
|
42
|
-
cookies?: {
|
|
43
|
-
enabled?: boolean;
|
|
44
|
-
};
|
|
45
52
|
onRequest?: Handler;
|
|
46
53
|
onResponse?: Handler;
|
|
47
54
|
onNotFound?: Handler;
|
|
@@ -49,6 +56,7 @@ declare class Server {
|
|
|
49
56
|
});
|
|
50
57
|
start(): Promise<string>;
|
|
51
58
|
close(): Promise<void>;
|
|
59
|
+
inject(params: InjectParams): Promise<InjectResponse>;
|
|
52
60
|
openapi(format: OpenApiFormat): OpenAPIV3.Document;
|
|
53
61
|
}
|
|
54
62
|
export { Server, };
|
package/dist/server/Server.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import compress from '@fastify/compress';
|
|
2
|
-
import
|
|
2
|
+
import cookie from '@fastify/cookie';
|
|
3
3
|
import cors from '@fastify/cors';
|
|
4
|
+
import formbody from '@fastify/formbody';
|
|
5
|
+
import multipart from '@fastify/multipart';
|
|
4
6
|
import responseValidation from '@fastify/response-validation';
|
|
5
7
|
import swagger from '@fastify/swagger';
|
|
6
8
|
import fastify from 'fastify';
|
|
@@ -18,9 +20,8 @@ class Server {
|
|
|
18
20
|
connectionTimeout: params.connectionTimeout ?? 30000,
|
|
19
21
|
requestTimeout: params.requestTimeout ?? 30000,
|
|
20
22
|
keepAliveTimeout: params.keepAliveTimeout ?? 30000,
|
|
21
|
-
maxRequestsPerSocket: params.
|
|
22
|
-
|
|
23
|
-
bodyLimit: params.bodyLimit ?? 1000000,
|
|
23
|
+
maxRequestsPerSocket: params.connectionMaxUses ?? 100,
|
|
24
|
+
bodyLimit: params.bodyMaxSize ?? 1000000,
|
|
24
25
|
});
|
|
25
26
|
const ajv = getAjv(params.formats);
|
|
26
27
|
this.server.setValidatorCompiler(({ schema }) => {
|
|
@@ -35,13 +36,28 @@ class Server {
|
|
|
35
36
|
},
|
|
36
37
|
},
|
|
37
38
|
});
|
|
38
|
-
if (params.
|
|
39
|
+
if (params.validateResponses) {
|
|
39
40
|
this.server.register(responseValidation, { ajv });
|
|
40
41
|
}
|
|
42
|
+
if (params.form?.enabled) {
|
|
43
|
+
this.server.register(formbody);
|
|
44
|
+
}
|
|
45
|
+
if (params.multipart?.enabled) {
|
|
46
|
+
this.server.register(multipart, {
|
|
47
|
+
attachFieldsToBody: 'keyValues',
|
|
48
|
+
limits: {
|
|
49
|
+
files: params.multipart.maxFiles ?? 1,
|
|
50
|
+
fileSize: params.multipart.fileMaxSize ?? 1000000,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
if (params.cookies?.enabled) {
|
|
55
|
+
this.server.register(cookie);
|
|
56
|
+
}
|
|
41
57
|
if (params.compression?.enabled) {
|
|
42
58
|
this.server.register(compress, {
|
|
43
59
|
global: true,
|
|
44
|
-
threshold: params.compression.threshold ??
|
|
60
|
+
threshold: params.compression.threshold ?? 1000,
|
|
45
61
|
});
|
|
46
62
|
}
|
|
47
63
|
if (params.cors?.enabled) {
|
|
@@ -53,22 +69,30 @@ class Server {
|
|
|
53
69
|
credentials: params.cors.allowCredentials,
|
|
54
70
|
});
|
|
55
71
|
}
|
|
56
|
-
if (params.cookies?.enabled) {
|
|
57
|
-
this.server.register(cookies);
|
|
58
|
-
}
|
|
59
72
|
this.server.register((server, options, done) => {
|
|
60
73
|
params.routes.forEach((route) => {
|
|
61
74
|
server.route({
|
|
62
|
-
url: route.path,
|
|
63
75
|
method: route.method,
|
|
76
|
+
url: route.path,
|
|
64
77
|
schema: {
|
|
65
78
|
summary: route.name ?? route.path,
|
|
66
79
|
description: route.description,
|
|
67
|
-
|
|
68
|
-
...route.schema.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
...route.schema.
|
|
80
|
+
tags: route.tags,
|
|
81
|
+
...route.schema.params
|
|
82
|
+
? { params: route.schema.params }
|
|
83
|
+
: {},
|
|
84
|
+
...route.schema.query
|
|
85
|
+
? { query: route.schema.query }
|
|
86
|
+
: {},
|
|
87
|
+
...route.schema.headers
|
|
88
|
+
? { headers: route.schema.headers }
|
|
89
|
+
: {},
|
|
90
|
+
...route.schema.body
|
|
91
|
+
? { body: route.schema.body }
|
|
92
|
+
: {},
|
|
93
|
+
...route.schema.response
|
|
94
|
+
? { response: route.schema.response }
|
|
95
|
+
: {},
|
|
72
96
|
},
|
|
73
97
|
handler: route.handler,
|
|
74
98
|
});
|
|
@@ -97,6 +121,9 @@ class Server {
|
|
|
97
121
|
async close() {
|
|
98
122
|
await this.server.close();
|
|
99
123
|
}
|
|
124
|
+
async inject(params) {
|
|
125
|
+
return this.server.inject(params);
|
|
126
|
+
}
|
|
100
127
|
openapi(format) {
|
|
101
128
|
return this.server.swagger({
|
|
102
129
|
yaml: format === OpenApiFormat.YAML,
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const multipartErrorCodes = [
|
|
2
|
+
'FST_FIELDS_LIMIT',
|
|
3
|
+
'FST_FILE_BUFFER_NOT_FOUND',
|
|
4
|
+
'FST_FILES_LIMIT',
|
|
5
|
+
'FST_INVALID_JSON_FIELD_ERROR',
|
|
6
|
+
'FST_INVALID_MULTIPART_CONTENT_TYPE',
|
|
7
|
+
'FST_NO_FORM_DATA',
|
|
8
|
+
'FST_PARTS_LIMIT',
|
|
9
|
+
'FST_PROTO_VIOLATION',
|
|
10
|
+
'FST_REQ_FILE_TOO_LARGE',
|
|
11
|
+
];
|
|
12
|
+
export { multipartErrorCodes, };
|
package/dist/tls/getTls.js
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "apeframework",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"author": "Matthieu Symoens",
|
|
9
|
-
"description": "Node.js
|
|
9
|
+
"description": "Node.js App Framework",
|
|
10
10
|
"keywords": [
|
|
11
11
|
"ape",
|
|
12
12
|
"framework",
|
|
@@ -14,42 +14,49 @@
|
|
|
14
14
|
],
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
17
|
-
"url": "git+https://github.com/MattSyms/apeframework.git"
|
|
17
|
+
"url": "git+https://github.com/MattSyms/apeframework.git",
|
|
18
|
+
"directory": "framework"
|
|
18
19
|
},
|
|
19
20
|
"type": "module",
|
|
20
21
|
"engines": {
|
|
21
22
|
"node": ">=22"
|
|
22
23
|
},
|
|
23
24
|
"dependencies": {
|
|
24
|
-
"@fastify/compress": "^8.
|
|
25
|
+
"@fastify/compress": "^8.3",
|
|
25
26
|
"@fastify/cookie": "^11.0",
|
|
26
|
-
"@fastify/cors": "^11.
|
|
27
|
+
"@fastify/cors": "^11.2",
|
|
28
|
+
"@fastify/formbody": "^8.0",
|
|
29
|
+
"@fastify/multipart": "^9.4",
|
|
27
30
|
"@fastify/response-validation": "^3.0",
|
|
28
|
-
"@fastify/swagger": "^9.
|
|
31
|
+
"@fastify/swagger": "^9.7",
|
|
29
32
|
"@types/fs-extra": "^11.0",
|
|
30
33
|
"@types/nodemailer": "^7.0",
|
|
31
34
|
"@types/yargs-parser": "^21.0",
|
|
32
|
-
"ajv": "^8.
|
|
35
|
+
"ajv": "^8.18",
|
|
33
36
|
"argon2": "^0.44",
|
|
34
|
-
"bullmq": "^5.
|
|
35
|
-
"dotenv": "^17.
|
|
37
|
+
"bullmq": "^5.70",
|
|
38
|
+
"dotenv": "^17.3",
|
|
36
39
|
"fast-uri": "^3.1",
|
|
37
|
-
"fastify": "^5.
|
|
40
|
+
"fastify": "^5.7",
|
|
38
41
|
"fs-extra": "^11.3",
|
|
39
42
|
"ical-generator": "^10.0",
|
|
40
|
-
"ioredis": "^5.
|
|
43
|
+
"ioredis": "^5.10",
|
|
41
44
|
"jose": "^6.1",
|
|
42
|
-
"
|
|
43
|
-
"
|
|
45
|
+
"mariadb": "^3.5",
|
|
46
|
+
"mysql2": "^3.18",
|
|
47
|
+
"nodemailer": "^8.0",
|
|
44
48
|
"openapi-types": "^12.1",
|
|
45
|
-
"
|
|
49
|
+
"pg": "^8.19",
|
|
50
|
+
"pg-hstore": "^2.3",
|
|
51
|
+
"pino": "^10.3",
|
|
46
52
|
"pino-pretty": "^13.1",
|
|
47
53
|
"sequelize": "^6.37",
|
|
54
|
+
"sqlite3": "^5.1",
|
|
48
55
|
"umzug": "^3.8",
|
|
49
56
|
"yargs-parser": "^22.0"
|
|
50
57
|
},
|
|
51
58
|
"peerDependencies": {
|
|
52
|
-
"@types/node": "^
|
|
59
|
+
"@types/node": "^25.3",
|
|
53
60
|
"typescript": "^5.9"
|
|
54
61
|
},
|
|
55
62
|
"exports": {
|
|
@@ -269,12 +276,42 @@
|
|
|
269
276
|
"default": "./dist/db/Transaction.js"
|
|
270
277
|
}
|
|
271
278
|
},
|
|
279
|
+
"./db/adapters/maria/MariaDb": {
|
|
280
|
+
"import": {
|
|
281
|
+
"types": "./dist/db/adapters/maria/MariaDb.d.ts",
|
|
282
|
+
"default": "./dist/db/adapters/maria/MariaDb.js"
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
"./db/adapters/mssql/MssqlDb": {
|
|
286
|
+
"import": {
|
|
287
|
+
"types": "./dist/db/adapters/mssql/MssqlDb.d.ts",
|
|
288
|
+
"default": "./dist/db/adapters/mssql/MssqlDb.js"
|
|
289
|
+
}
|
|
290
|
+
},
|
|
272
291
|
"./db/adapters/mysql/MysqlDb": {
|
|
273
292
|
"import": {
|
|
274
293
|
"types": "./dist/db/adapters/mysql/MysqlDb.d.ts",
|
|
275
294
|
"default": "./dist/db/adapters/mysql/MysqlDb.js"
|
|
276
295
|
}
|
|
277
296
|
},
|
|
297
|
+
"./db/adapters/postgres/PostgresDb": {
|
|
298
|
+
"import": {
|
|
299
|
+
"types": "./dist/db/adapters/postgres/PostgresDb.d.ts",
|
|
300
|
+
"default": "./dist/db/adapters/postgres/PostgresDb.js"
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
"./db/adapters/sqlite/SqliteDb": {
|
|
304
|
+
"import": {
|
|
305
|
+
"types": "./dist/db/adapters/sqlite/SqliteDb.d.ts",
|
|
306
|
+
"default": "./dist/db/adapters/sqlite/SqliteDb.js"
|
|
307
|
+
}
|
|
308
|
+
},
|
|
309
|
+
"./db/adapters/sqlite/Storage": {
|
|
310
|
+
"import": {
|
|
311
|
+
"types": "./dist/db/adapters/sqlite/Storage.d.ts",
|
|
312
|
+
"default": "./dist/db/adapters/sqlite/Storage.js"
|
|
313
|
+
}
|
|
314
|
+
},
|
|
278
315
|
"./db/relationships": {
|
|
279
316
|
"import": {
|
|
280
317
|
"types": "./dist/db/relationships.d.ts",
|
|
@@ -677,6 +714,18 @@
|
|
|
677
714
|
"default": "./dist/server/Handler.js"
|
|
678
715
|
}
|
|
679
716
|
},
|
|
717
|
+
"./server/InjectParams": {
|
|
718
|
+
"import": {
|
|
719
|
+
"types": "./dist/server/InjectParams.d.ts",
|
|
720
|
+
"default": "./dist/server/InjectParams.js"
|
|
721
|
+
}
|
|
722
|
+
},
|
|
723
|
+
"./server/InjectResponse": {
|
|
724
|
+
"import": {
|
|
725
|
+
"types": "./dist/server/InjectResponse.d.ts",
|
|
726
|
+
"default": "./dist/server/InjectResponse.js"
|
|
727
|
+
}
|
|
728
|
+
},
|
|
680
729
|
"./server/Method": {
|
|
681
730
|
"import": {
|
|
682
731
|
"types": "./dist/server/Method.d.ts",
|
|
@@ -725,6 +774,12 @@
|
|
|
725
774
|
"default": "./dist/server/getAjv.js"
|
|
726
775
|
}
|
|
727
776
|
},
|
|
777
|
+
"./server/multipartErrorCodes": {
|
|
778
|
+
"import": {
|
|
779
|
+
"types": "./dist/server/multipartErrorCodes.d.ts",
|
|
780
|
+
"default": "./dist/server/multipartErrorCodes.js"
|
|
781
|
+
}
|
|
782
|
+
},
|
|
728
783
|
"./tls/Tls": {
|
|
729
784
|
"import": {
|
|
730
785
|
"types": "./dist/tls/Tls.d.ts",
|