-
Notifications
You must be signed in to change notification settings - Fork 4
/
test-api.js
41 lines (37 loc) · 1.31 KB
/
test-api.js
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const
restify = require('restify'),
oracledb = require('oracledb'),
oracledbMiddleware = require('./index'),
server = restify.createServer();
server
.use(oracledbMiddleware({
poolPingInterval: 10,
// poolIncrement: 2,
// poolTimeout: 5
}))
.get('/test', (req, res, next) => {
req.connection
.then(conn => conn.execute(
'begin dbms_lock.sleep(3); :ret := systimestamp || \'\'; end;',
// 'begin :ret := systimestamp || \'\'; end;',
{
ret: { dir: oracledb.BIND_OUT, type: oracledb.STRING },
}
))
.then(result => res.json(result.outBinds))
.then(() => next())
.catch(err => {
console.error(new Date().toISOString(), 'GET error', err);
next(new Error(err));
})
});
setInterval(() => {
console.log('used:', oracledb.getPool().connectionsInUse, 'open:', oracledb.getPool().connectionsOpen);
}, 1000);
server.listen(process.env.PORT || 8080, () => {
console.log('%s listening at %s', server.name, server.url);
});
// Ctrl-C doesn't kill node on Mac: workaround https://github.com/oracle/node-oracledb/issues/128
process.on('SIGINT', function () {
process.kill(process.pid);
});