Skip to content

Commit 7e84439

Browse files
authored
feat(promisify): use native promisify and remove es6-promisify (#165)
* (feat) use native promisify and remove es6-promisify * (revert) undo promise array * fix: reverted and removed package via npm uninstall
1 parent 60ba247 commit 7e84439

File tree

5 files changed

+21
-29
lines changed

5 files changed

+21
-29
lines changed

example/oracle/index.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
11
const express = require('express')
22
const http = require('http')
3-
var oracledb = require('oracledb');
3+
var oracledb = require('oracledb')
44
const terminus = require('../../lib/terminus')
55
const app = express()
66

77
var config = {
8-
user: process.env.NODE_ORACLEDB_USER || "scott",
9-
password: process.env.NODE_ORACLEDB_PASSWORD || "tiger",
10-
connectString: process.env.NODE_ORACLEDB_CONNECTIONSTRING || "localhost:1521/XE",
8+
user: process.env.NODE_ORACLEDB_USER || 'scott',
9+
password: process.env.NODE_ORACLEDB_PASSWORD || 'tiger',
10+
connectString: process.env.NODE_ORACLEDB_CONNECTIONSTRING || 'localhost:1521/XE',
1111
poolMin: 1,
1212
poolMax: 10,
1313
poolIncrement: 1
1414
}
1515

16-
async function dbConnect() {
17-
await oracledb.createPool(config);
18-
var conn = await oracledb.getConnection();
16+
async function dbConnect () {
17+
await oracledb.createPool(config)
18+
var conn = await oracledb.getConnection()
1919
}
2020

2121
app.get('/dual', async (req, res) => {
22-
var conn = await oracledb.getConnection();
22+
var conn = await oracledb.getConnection()
2323
const result = await conn
24-
.execute(`select JSON_OBJECT('id' value sys_guid()) from dual`)
25-
res.json(result.rows[0]);
24+
.execute('select JSON_OBJECT(\'id\' value sys_guid()) from dual')
25+
res.json(result.rows[0])
2626
})
2727

28-
async function onHealthCheck() {
29-
var conn = await oracledb.getConnection();
28+
async function onHealthCheck () {
29+
var conn = await oracledb.getConnection()
3030
console.log('pinging oracle db')
31-
return conn.ping();
31+
return conn.ping()
3232
}
3333

34-
function onSignal() {
34+
function onSignal () {
3535
console.log('server is starting cleanup')
3636
oracledb.getPool().close().then(() => console.log('Oracle database connection closed'))
3737
.catch(err => console.error('error during disconnection', err.stack))
3838
}
3939

40-
async function startServer() {
40+
async function startServer () {
4141
// get oracle connection
42-
await dbConnect();
42+
await dbConnect()
4343
console.log('Oracle database connection established')
4444

4545
terminus.createTerminus(http.createServer(app), {
@@ -54,4 +54,4 @@ async function startServer() {
5454
}
5555

5656
startServer()
57-
.catch(err => console.error('connection error', err.stack))
57+
.catch(err => console.error('connection error', err.stack))

lib/terminus.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict'
22

33
const stoppable = require('stoppable')
4-
const { promisify } = require('es6-promisify')
4+
const { promisify } = require('util')
55

66
const SUCCESS_RESPONSE = JSON.stringify({
77
status: 'ok'
@@ -15,9 +15,7 @@ function noopResolves () {
1515
return Promise.resolve()
1616
}
1717

18-
async function sendSuccess (res, options) {
19-
const { info, verbatim } = options
20-
18+
async function sendSuccess (res, { info, verbatim }) {
2119
res.statusCode = 200
2220
res.setHeader('Content-Type', 'application/json')
2321
if (info) {

lib/terminus.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ describe('Terminus', () => {
108108
let hasUnhandledRejection = false
109109

110110
process.once('unhandledRejection', () => {
111-
hasUnhandledRejection = true;
111+
hasUnhandledRejection = true
112112
})
113113

114114
server.on('request', () => {
@@ -121,7 +121,7 @@ describe('Terminus', () => {
121121
healthCheckRanTimes++
122122
return Promise.resolve()
123123
}
124-
},
124+
}
125125
})
126126
server.listen(8000)
127127

package-lock.json

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
"author": "",
2121
"license": "MIT",
2222
"dependencies": {
23-
"es6-promisify": "^6.0.2",
2423
"stoppable": "^1.1.0"
2524
},
2625
"devDependencies": {

0 commit comments

Comments
 (0)