-
-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathindex.ts
More file actions
26 lines (21 loc) · 691 Bytes
/
index.ts
File metadata and controls
26 lines (21 loc) · 691 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/* SPDX-FileCopyrightText: 2016-present Kriasoft <hello@kriasoft.com> */
/* SPDX-License-Identifier: MIT */
/// <reference types="./knex" />
import knex from "knex";
import config from "./config";
import { createNewId } from "./utils";
export * from "./types";
/**
* Knex.js database client and query builder for PostgreSQL.
*
* @see https://knexjs.org/
*/
const db = knex(config);
// Extend `db.fn` with an additional functionality.
db.fn.constructor.prototype.newUserId = createNewId(db, "user", 6);
// Ensure that the database connections will be closed when
// the Node.js process is being shut down.
process.once("SIGTERM", function () {
db.destroy();
});
export default db;