apeframework 0.2.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/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 +21 -6
- package/dist/server/Server.js +48 -13
- 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 +67 -24
- package/dist/db/Seed.d.ts +0 -3
- package/dist/db/Seeder.d.ts +0 -16
- package/dist/db/Seeder.js +0 -26
- /package/dist/{db/Seed.js → server/InjectParams.js} +0 -0
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 {};
|
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,13 +13,28 @@ declare class Server {
|
|
|
11
13
|
constructor(params: {
|
|
12
14
|
host: string;
|
|
13
15
|
port?: number;
|
|
14
|
-
routes: Route[];
|
|
15
|
-
formats?: Format[];
|
|
16
16
|
openapi?: {
|
|
17
17
|
name?: string;
|
|
18
18
|
version?: string;
|
|
19
19
|
};
|
|
20
|
-
|
|
20
|
+
routes: Route[];
|
|
21
|
+
formats?: Format[];
|
|
22
|
+
validateResponses?: boolean;
|
|
23
|
+
trustProxy?: boolean;
|
|
24
|
+
connectionTimeout?: number;
|
|
25
|
+
requestTimeout?: number;
|
|
26
|
+
keepAliveTimeout?: number;
|
|
27
|
+
connectionMaxUses?: number;
|
|
28
|
+
bodyMaxSize?: number;
|
|
29
|
+
form?: {
|
|
30
|
+
enabled?: boolean;
|
|
31
|
+
};
|
|
32
|
+
multipart?: {
|
|
33
|
+
enabled?: boolean;
|
|
34
|
+
maxFiles?: number;
|
|
35
|
+
fileMaxSize?: number;
|
|
36
|
+
};
|
|
37
|
+
cookies?: {
|
|
21
38
|
enabled?: boolean;
|
|
22
39
|
};
|
|
23
40
|
compression?: {
|
|
@@ -32,9 +49,6 @@ declare class Server {
|
|
|
32
49
|
exposedHeaders?: string[];
|
|
33
50
|
allowCredentials?: boolean;
|
|
34
51
|
};
|
|
35
|
-
cookies?: {
|
|
36
|
-
enabled?: boolean;
|
|
37
|
-
};
|
|
38
52
|
onRequest?: Handler;
|
|
39
53
|
onResponse?: Handler;
|
|
40
54
|
onNotFound?: Handler;
|
|
@@ -42,6 +56,7 @@ declare class Server {
|
|
|
42
56
|
});
|
|
43
57
|
start(): Promise<string>;
|
|
44
58
|
close(): Promise<void>;
|
|
59
|
+
inject(params: InjectParams): Promise<InjectResponse>;
|
|
45
60
|
openapi(format: OpenApiFormat): OpenAPIV3.Document;
|
|
46
61
|
}
|
|
47
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';
|
|
@@ -13,7 +15,14 @@ class Server {
|
|
|
13
15
|
constructor(params) {
|
|
14
16
|
this.host = params.host;
|
|
15
17
|
this.port = params.port;
|
|
16
|
-
this.server = fastify(
|
|
18
|
+
this.server = fastify({
|
|
19
|
+
trustProxy: params.trustProxy ?? false,
|
|
20
|
+
connectionTimeout: params.connectionTimeout ?? 30000,
|
|
21
|
+
requestTimeout: params.requestTimeout ?? 30000,
|
|
22
|
+
keepAliveTimeout: params.keepAliveTimeout ?? 30000,
|
|
23
|
+
maxRequestsPerSocket: params.connectionMaxUses ?? 100,
|
|
24
|
+
bodyLimit: params.bodyMaxSize ?? 1000000,
|
|
25
|
+
});
|
|
17
26
|
const ajv = getAjv(params.formats);
|
|
18
27
|
this.server.setValidatorCompiler(({ schema }) => {
|
|
19
28
|
return ajv.compile(schema);
|
|
@@ -27,13 +36,28 @@ class Server {
|
|
|
27
36
|
},
|
|
28
37
|
},
|
|
29
38
|
});
|
|
30
|
-
if (params.
|
|
39
|
+
if (params.validateResponses) {
|
|
31
40
|
this.server.register(responseValidation, { ajv });
|
|
32
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
|
+
}
|
|
33
57
|
if (params.compression?.enabled) {
|
|
34
58
|
this.server.register(compress, {
|
|
35
59
|
global: true,
|
|
36
|
-
threshold: params.compression.threshold ??
|
|
60
|
+
threshold: params.compression.threshold ?? 1000,
|
|
37
61
|
});
|
|
38
62
|
}
|
|
39
63
|
if (params.cors?.enabled) {
|
|
@@ -45,22 +69,30 @@ class Server {
|
|
|
45
69
|
credentials: params.cors.allowCredentials,
|
|
46
70
|
});
|
|
47
71
|
}
|
|
48
|
-
if (params.cookies?.enabled) {
|
|
49
|
-
this.server.register(cookies);
|
|
50
|
-
}
|
|
51
72
|
this.server.register((server, options, done) => {
|
|
52
73
|
params.routes.forEach((route) => {
|
|
53
74
|
server.route({
|
|
54
|
-
url: route.path,
|
|
55
75
|
method: route.method,
|
|
76
|
+
url: route.path,
|
|
56
77
|
schema: {
|
|
57
78
|
summary: route.name ?? route.path,
|
|
58
79
|
description: route.description,
|
|
59
|
-
|
|
60
|
-
...route.schema.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
...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
|
+
: {},
|
|
64
96
|
},
|
|
65
97
|
handler: route.handler,
|
|
66
98
|
});
|
|
@@ -89,6 +121,9 @@ class Server {
|
|
|
89
121
|
async close() {
|
|
90
122
|
await this.server.close();
|
|
91
123
|
}
|
|
124
|
+
async inject(params) {
|
|
125
|
+
return this.server.inject(params);
|
|
126
|
+
}
|
|
92
127
|
openapi(format) {
|
|
93
128
|
return this.server.swagger({
|
|
94
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": {
|
|
@@ -263,22 +270,22 @@
|
|
|
263
270
|
"default": "./dist/db/ReferentialAction.js"
|
|
264
271
|
}
|
|
265
272
|
},
|
|
266
|
-
"./db/
|
|
273
|
+
"./db/Transaction": {
|
|
267
274
|
"import": {
|
|
268
|
-
"types": "./dist/db/
|
|
269
|
-
"default": "./dist/db/
|
|
275
|
+
"types": "./dist/db/Transaction.d.ts",
|
|
276
|
+
"default": "./dist/db/Transaction.js"
|
|
270
277
|
}
|
|
271
278
|
},
|
|
272
|
-
"./db/
|
|
279
|
+
"./db/adapters/maria/MariaDb": {
|
|
273
280
|
"import": {
|
|
274
|
-
"types": "./dist/db/
|
|
275
|
-
"default": "./dist/db/
|
|
281
|
+
"types": "./dist/db/adapters/maria/MariaDb.d.ts",
|
|
282
|
+
"default": "./dist/db/adapters/maria/MariaDb.js"
|
|
276
283
|
}
|
|
277
284
|
},
|
|
278
|
-
"./db/
|
|
285
|
+
"./db/adapters/mssql/MssqlDb": {
|
|
279
286
|
"import": {
|
|
280
|
-
"types": "./dist/db/
|
|
281
|
-
"default": "./dist/db/
|
|
287
|
+
"types": "./dist/db/adapters/mssql/MssqlDb.d.ts",
|
|
288
|
+
"default": "./dist/db/adapters/mssql/MssqlDb.js"
|
|
282
289
|
}
|
|
283
290
|
},
|
|
284
291
|
"./db/adapters/mysql/MysqlDb": {
|
|
@@ -287,6 +294,24 @@
|
|
|
287
294
|
"default": "./dist/db/adapters/mysql/MysqlDb.js"
|
|
288
295
|
}
|
|
289
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
|
+
},
|
|
290
315
|
"./db/relationships": {
|
|
291
316
|
"import": {
|
|
292
317
|
"types": "./dist/db/relationships.d.ts",
|
|
@@ -689,6 +714,18 @@
|
|
|
689
714
|
"default": "./dist/server/Handler.js"
|
|
690
715
|
}
|
|
691
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
|
+
},
|
|
692
729
|
"./server/Method": {
|
|
693
730
|
"import": {
|
|
694
731
|
"types": "./dist/server/Method.d.ts",
|
|
@@ -737,6 +774,12 @@
|
|
|
737
774
|
"default": "./dist/server/getAjv.js"
|
|
738
775
|
}
|
|
739
776
|
},
|
|
777
|
+
"./server/multipartErrorCodes": {
|
|
778
|
+
"import": {
|
|
779
|
+
"types": "./dist/server/multipartErrorCodes.d.ts",
|
|
780
|
+
"default": "./dist/server/multipartErrorCodes.js"
|
|
781
|
+
}
|
|
782
|
+
},
|
|
740
783
|
"./tls/Tls": {
|
|
741
784
|
"import": {
|
|
742
785
|
"types": "./dist/tls/Tls.d.ts",
|
package/dist/db/Seed.d.ts
DELETED
package/dist/db/Seeder.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { Db } from './Db.js';
|
|
2
|
-
declare class Seeder {
|
|
3
|
-
private readonly db;
|
|
4
|
-
private readonly directory;
|
|
5
|
-
private readonly extension;
|
|
6
|
-
private readonly onApply?;
|
|
7
|
-
constructor(params: {
|
|
8
|
-
db: Db;
|
|
9
|
-
directory: string;
|
|
10
|
-
extension: string;
|
|
11
|
-
onApply?: (name: string) => void;
|
|
12
|
-
});
|
|
13
|
-
list(): string[];
|
|
14
|
-
apply(name: string): Promise<void>;
|
|
15
|
-
}
|
|
16
|
-
export { Seeder, };
|
package/dist/db/Seeder.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { basename, extname, resolve } from 'node:path';
|
|
2
|
-
import fs from 'fs-extra';
|
|
3
|
-
class Seeder {
|
|
4
|
-
db;
|
|
5
|
-
directory;
|
|
6
|
-
extension;
|
|
7
|
-
onApply;
|
|
8
|
-
constructor(params) {
|
|
9
|
-
this.db = params.db;
|
|
10
|
-
this.directory = params.directory;
|
|
11
|
-
this.extension = params.extension;
|
|
12
|
-
this.onApply = params.onApply;
|
|
13
|
-
}
|
|
14
|
-
list() {
|
|
15
|
-
return fs.readdirSync(this.directory).map((filename) => {
|
|
16
|
-
return basename(filename, extname(filename));
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
async apply(name) {
|
|
20
|
-
this.onApply?.(name);
|
|
21
|
-
const file = resolve(this.directory, `${name}.${this.extension}`);
|
|
22
|
-
const { seed } = await import(file);
|
|
23
|
-
await seed(this.db);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
export { Seeder, };
|
|
File without changes
|