diff --git a/demos/basic/server.js b/demos/basic/server.js index 6d1ec33..55b36b5 100644 --- a/demos/basic/server.js +++ b/demos/basic/server.js @@ -17,7 +17,10 @@ await sequelize.query('INSERT INTO Users VALUES("John", 69);') //set up the WebSocket SocioServer and give it the DB querying function that comes from whatever your DB interface lib provides. //it needs the raw sql string, which can contain formatting parameters - insert dynamic data into the string. //Either you in a wrapper function or your DB interface lib should do the sql validation and sanitization, as this lib does not! -const QueryWrap = async ({ id = 0, ses_id = '', sql = '', params = {} } = {}) => (await sequelize.query(sql, { logging: false, raw: true, replacements: params }))[0] +async function QueryWrap({ id = 0, ses_id = '', sql = '', params = {} } = {}) { + return (await sequelize.query(sql, { logging: false, raw: true, replacements: params }))[0] +} + const socserv = new SocioServer({ port: ws_port }, QueryWrap, {verbose:true} ) done(`Created SocioServer on port`, ws_port) diff --git a/demos/framework/server.js b/demos/framework/server.js index 89d6679..3ddd662 100644 --- a/demos/framework/server.js +++ b/demos/framework/server.js @@ -18,7 +18,9 @@ await sequelize.query('INSERT INTO Users VALUES("John", 69);') //set up the WebSocket SocioServer and give it the DB querying function that comes from whatever your DB interface lib provides. //it needs the raw sql string, which can contain formatting parameters - insert dynamic data into the string. //Either you in a wrapper function or your DB interface lib should do the sql validation and sanitization, as this lib does not! -const QueryWrap = async ({ id = 0, ses_id = '', sql = '', params = {} } = {}) => (await sequelize.query(sql, { logging: false, raw: true, replacements: params }))[0] +async function QueryWrap({ id = 0, ses_id = '', sql = '', params = {} } = {}){ + return (await sequelize.query(sql, { logging: false, raw: true, replacements: params }))[0] +} //note that these key and iv are here for demonstration purposes and you should always generate your own. You may also supply any cipher algorithm supported by node's crypto module. //It is always advised to load these keys from a .env file!