DefinitelyTyped/types/express-myconnection/express-myconnection-tests.ts
maximelkin 3543dcb85e Update mysql library definitions (#20639)
* updated definitions

* fixes duplicated names

* add allow synthetic def imports, add ts version

* bump module version

* little test fixes

* removed ts version

* fix module name and link to github, revert tsconfig

* fix of tsconfig(2)

* add fake interface for express-myconnection

* lint config and fixes, typeCasting, interface renaming

* fix naming, fix express-myconnection

* node-mysql-wrapper fix
2017-10-23 17:25:11 -07:00

39 lines
832 B
TypeScript

import express = require('express');
import mysql = require('mysql');
import connection = require('express-myconnection');
var app = express();
app.use(
connection(
mysql,
{
host: 'localhost',
user: 'dbuser',
password: 'password',
port: 3306,
database: 'mydb'
},
'single'
)
);
app.use(function list(req: express.Request, res: express.Response, next: Function){
req.getConnection(function(err: mysql.MysqlError, connection: mysql.Connection) {
if (err) return next(err);
connection.query('SELECT 1 AS RESULT', [], function(err: mysql.MysqlError, results: any) {
if (err) return next(err);
results[0].RESULT;
// -> 1
res.send(200);
});
});
});