Advertisement
Guest User

Untitled

a guest
Aug 16th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. var sql = require('mssql');
  2. var router = express.Router();
  3. router.use(function(req, res, next){
  4. // Add database connection
  5. var connection = new sql.Connection(sqlConfig: {
  6. user: 'username',
  7. password: 'password',
  8. server: 'IP address',
  9. database: 'database name',
  10. options: {
  11. encrypt: true
  12. }
  13. }, function(err) {
  14. if (err) {
  15. logger.error('Connection error: ' + err.message);
  16. res.sendStatus(400);
  17. }
  18. else {
  19. req.connection = connection;
  20. next();
  21. }
  22. });
  23. });
  24. module.exports = router;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement