@vercel/functions 2.2.6 → 2.2.8
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/CHANGELOG.md +12 -0
- package/db-connections/index.d.ts +6 -2
- package/db-connections/index.js +7 -1
- package/docs/modules/index.md +29 -4
- package/index.d.ts +1 -1
- package/index.js +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @vercel/functions
|
|
2
2
|
|
|
3
|
+
## 2.2.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Declare attachDatabasePool stable ([#13673](https://github.com/vercel/vercel/pull/13673))
|
|
8
|
+
|
|
9
|
+
## 2.2.7
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Make DB pool inert in local dev ([#13647](https://github.com/vercel/vercel/pull/13647))
|
|
14
|
+
|
|
3
15
|
## 2.2.6
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -72,10 +72,14 @@ export type DbPool = PgPool | MySQLPool | MySQL2Pool | MariaDBPool | MongoDBPool
|
|
|
72
72
|
* const pgPool = new Pool({
|
|
73
73
|
* connectionString: process.env.DATABASE_URL,
|
|
74
74
|
* });
|
|
75
|
-
*
|
|
75
|
+
* attachDatabasePool(pgPool);
|
|
76
76
|
* ```
|
|
77
77
|
*
|
|
78
78
|
* @experimental
|
|
79
79
|
*/
|
|
80
|
-
export declare function
|
|
80
|
+
export declare function attachDatabasePool(dbPool: DbPool): void;
|
|
81
|
+
/**
|
|
82
|
+
* @deprecated Use attachDatabasePool instead.
|
|
83
|
+
*/
|
|
84
|
+
export declare const experimental_attachDatabasePool: typeof attachDatabasePool;
|
|
81
85
|
export {};
|
package/db-connections/index.js
CHANGED
|
@@ -18,6 +18,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var db_connections_exports = {};
|
|
20
20
|
__export(db_connections_exports, {
|
|
21
|
+
attachDatabasePool: () => attachDatabasePool,
|
|
21
22
|
experimental_attachDatabasePool: () => experimental_attachDatabasePool
|
|
22
23
|
});
|
|
23
24
|
module.exports = __toCommonJS(db_connections_exports);
|
|
@@ -60,6 +61,9 @@ let idleTimeoutResolve = () => {
|
|
|
60
61
|
const bootTime = Date.now();
|
|
61
62
|
const maximumDuration = 15 * 60 * 1e3 - 1e3;
|
|
62
63
|
function waitUntilIdleTimeout(dbPool) {
|
|
64
|
+
if (!process.env.VERCEL_URL) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
63
67
|
if (idleTimeout) {
|
|
64
68
|
clearTimeout(idleTimeout);
|
|
65
69
|
idleTimeoutResolve();
|
|
@@ -84,7 +88,7 @@ function waitUntilIdleTimeout(dbPool) {
|
|
|
84
88
|
console.warn("Pool release event triggered outside of request scope.");
|
|
85
89
|
}
|
|
86
90
|
}
|
|
87
|
-
function
|
|
91
|
+
function attachDatabasePool(dbPool) {
|
|
88
92
|
if (idleTimeout) {
|
|
89
93
|
idleTimeoutResolve?.();
|
|
90
94
|
clearTimeout(idleTimeout);
|
|
@@ -139,7 +143,9 @@ function experimental_attachDatabasePool(dbPool) {
|
|
|
139
143
|
}
|
|
140
144
|
throw new Error("Unsupported database pool type");
|
|
141
145
|
}
|
|
146
|
+
const experimental_attachDatabasePool = attachDatabasePool;
|
|
142
147
|
// Annotate the CommonJS export names for ESM import in node:
|
|
143
148
|
0 && (module.exports = {
|
|
149
|
+
attachDatabasePool,
|
|
144
150
|
experimental_attachDatabasePool
|
|
145
151
|
});
|
package/docs/modules/index.md
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
### Functions
|
|
12
12
|
|
|
13
|
+
- [attachDatabasePool](index.md#attachdatabasepool)
|
|
13
14
|
- [experimental_attachDatabasePool](index.md#experimental_attachdatabasepool)
|
|
14
15
|
- [geolocation](index.md#geolocation)
|
|
15
16
|
- [getCache](index.md#getcache)
|
|
@@ -21,9 +22,9 @@
|
|
|
21
22
|
|
|
22
23
|
## Functions
|
|
23
24
|
|
|
24
|
-
###
|
|
25
|
+
### attachDatabasePool
|
|
25
26
|
|
|
26
|
-
▸ **
|
|
27
|
+
▸ **attachDatabasePool**(`dbPool`): `void`
|
|
27
28
|
|
|
28
29
|
Call this function right after creating a database pool with the database pool object
|
|
29
30
|
as argument.
|
|
@@ -36,7 +37,7 @@ idle database connections to be removed from the pool.
|
|
|
36
37
|
const pgPool = new Pool({
|
|
37
38
|
connectionString: process.env.DATABASE_URL,
|
|
38
39
|
});
|
|
39
|
-
|
|
40
|
+
attachDatabasePool(pgPool);
|
|
40
41
|
```
|
|
41
42
|
|
|
42
43
|
#### Parameters
|
|
@@ -51,7 +52,31 @@ experimental_attachDatabasePool(pgPool);
|
|
|
51
52
|
|
|
52
53
|
#### Defined in
|
|
53
54
|
|
|
54
|
-
[packages/functions/src/db-connections/index.ts:
|
|
55
|
+
[packages/functions/src/db-connections/index.ts:221](https://github.com/vercel/vercel/blob/main/packages/functions/src/db-connections/index.ts#L221)
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
### experimental_attachDatabasePool
|
|
60
|
+
|
|
61
|
+
▸ **experimental_attachDatabasePool**(`dbPool`): `void`
|
|
62
|
+
|
|
63
|
+
**`Deprecated`**
|
|
64
|
+
|
|
65
|
+
Use attachDatabasePool instead.
|
|
66
|
+
|
|
67
|
+
#### Parameters
|
|
68
|
+
|
|
69
|
+
| Name | Type |
|
|
70
|
+
| :------- | :------- |
|
|
71
|
+
| `dbPool` | `DbPool` |
|
|
72
|
+
|
|
73
|
+
#### Returns
|
|
74
|
+
|
|
75
|
+
`void`
|
|
76
|
+
|
|
77
|
+
#### Defined in
|
|
78
|
+
|
|
79
|
+
[packages/functions/src/db-connections/index.ts:221](https://github.com/vercel/vercel/blob/main/packages/functions/src/db-connections/index.ts#L221)
|
|
55
80
|
|
|
56
81
|
---
|
|
57
82
|
|
package/index.d.ts
CHANGED
|
@@ -4,5 +4,5 @@ export { getEnv } from './get-env';
|
|
|
4
4
|
export { waitUntil } from './wait-until';
|
|
5
5
|
export { rewrite, next } from './middleware';
|
|
6
6
|
export { getCache } from './cache';
|
|
7
|
-
export { experimental_attachDatabasePool } from './db-connections';
|
|
7
|
+
export { attachDatabasePool, experimental_attachDatabasePool, } from './db-connections';
|
|
8
8
|
export type { RuntimeCache } from './cache/types';
|
package/index.js
CHANGED
|
@@ -18,6 +18,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var src_exports = {};
|
|
20
20
|
__export(src_exports, {
|
|
21
|
+
attachDatabasePool: () => import_db_connections.attachDatabasePool,
|
|
21
22
|
experimental_attachDatabasePool: () => import_db_connections.experimental_attachDatabasePool,
|
|
22
23
|
geolocation: () => import_headers.geolocation,
|
|
23
24
|
getCache: () => import_cache.getCache,
|
|
@@ -36,6 +37,7 @@ var import_cache = require("./cache");
|
|
|
36
37
|
var import_db_connections = require("./db-connections");
|
|
37
38
|
// Annotate the CommonJS export names for ESM import in node:
|
|
38
39
|
0 && (module.exports = {
|
|
40
|
+
attachDatabasePool,
|
|
39
41
|
experimental_attachDatabasePool,
|
|
40
42
|
geolocation,
|
|
41
43
|
getCache,
|