-
Notifications
You must be signed in to change notification settings - Fork 229
Open
Description
I reimplemented the server.js with using the nodejs package mssql instead of tedious.
The trustServerCertificate: true option must be added for local connection to avoid certificate error.
Actually, two things should be changed only:
- Replace the line RUN npm install tedious in Dockerfile with RUN npm install mssql
- Replace server.js with this block of text
var express = require("express");
var app = express();
var sql = require('mssql')
app.get('/', async function (req, res) {
console.log("********** SERVER.JS app.get")
var config = {
server: 'localhost',
user: 'sa',
password: 'Yukon900', // update me
database: 'DemoData', // doesn't seem to work?
options: {
encrypt: true, // for azure
trustServerCertificate: true // change to true for local dev / self-signed certs
},
};
var pool
try {
pool = await sql.connect(config)
console.log("********** SERVER.JS connected")
const result = await sql.query`SELECT * FROM DemoData.dbo.Products` // FOR JSON AUTO
console.dir(result)
res.send(result?.recordset);
} catch (err) {
console.log(err)
res.send(JSON.stringify(err))
} finally {
pool?.close()
}
})
var server = app.listen(8080, function () {
console.log(`========== Listening on http://localhost:${server.address().port}`);
});
I have provided an updated readme, too.
Metadata
Metadata
Assignees
Labels
No labels