title: I am trying to connect to connect to my SQL server database with node and hapi.js
body: <p>I am trying to test out connection to my sql server using node and hapi.js and run a simple query on one of my tables. I am fairly new to node and Hapi so I am just trying to figure this out</p>
  
  <p>so first my folder structure is as follows I have a folder called api which has routes in it and that is where I am doing my routes get_aosdata.js this works I tested it just passing back 'hello world' then I have a query folder under api this is where I am setting my db connections in connection.js</p>
  
  <p>this is what my route currently looks like </p>
  
  <pre><code>'use strict';
  const query = require('../query/connection');
  
  module.exports = {
      method: 'GET',
      path: '/api/query/{id}',
      config: {
          pre: [
              { method: query.getSqlConnection, assign: 'db' }
          ],
          handler: (request, reply) =&gt; {
                  const request = new db.Request();
                  request.query(`SELECT a.OrdNbr, a.sotypeid, a.user6, a.lupd_datetime, a.user3, a.crtd_user, a.S4Future01, a.slsperid, a.totmerch, a.CustOrdNbr from SOHeader a
                                join customer b
                                on a.CustID = b.CustId
                                join SOLine c
                                on a.OrdNbr = c.OrdNbr
                                where sotypeId = 'Q'`, ((err, recordset) =&gt; {
  
                                  if (err) {
                                      console.log(err);
                                  }
                                  reply(recordset);
                                }));
  
          }
      }
  }
  </code></pre>
  
  <p>I am calling to a prereq to do my connection this is what this code looks like </p>
  
  <pre><code>const sql = require('mssql');
  
  const dbConfig = {
      server: 'myserver',
      database: 'mydatabase',
      user: 'myuser',
      password: 'mypassword'
  }
  
  const getSqlConnection = (request, reply) =&gt; {
      sql.connect(dbConfig, ((err) =&gt; {
                  if (err) {
                      console.log(err);
                  }
      }));
              return reply();
  }
  
  module.exports = getSqlConnection;
  </code></pre>
  
  <p>this is my server </p>
  
  <pre><code>'use strict';
  
  const Hapi = require('hapi');
  
  const server = new Hapi.Server();
  
  server.connection({ port: 3001, host: 'localhost' });
  
  server.route(require('./api/routes/get_AOSdata'));
  
  server.start((err) =&gt; {
      if(err) {
          throw err;
      }
  
      console.log(`Server running at: ${server.info.uri}`);
  });
  </code></pre>
  
  <p>now my error says pre at position 0 does not match any of the allowed types... I am clueless on this error and I cannot find a fix anywhere. I am using hapi and mssql to make the call any help would be appreciated I am new at node and hapi, however I have read a lot on hapi and would really like to use it</p>