-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerator.js
42 lines (31 loc) · 1.06 KB
/
generator.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
42
var express = require('express');
var app = express();
app.get('/', function (req, res) {
var sql = require("mssql");
// config for your database
var config = {
user: 'nickpSQL',
password: 'blue1234',
server: 'DESKTOP-UB8RIFR\\SQLEXPRESS',
port: 1433,
database: 'SafeAccountsAPI_Db',
options: {
encrypt: false
}
};
// connect to your database
sql.connect(config, function (err) {
if (err) console.log(err);
// create Request object
var request = new sql.Request();
// query to the database and get the records
request.query('SELECT * FROM INFORMATION_SCHEMA.TABLES;', function (err, recordset) {
if (err) console.log(err)
// send records as a response, but lets shorten that heavy response
res.send(recordset.recordset);
});
});
});
var server = app.listen(5000, function () {
console.log('Server is running..');
});