Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fastify-mssql

Package Overview
Dependencies
Maintainers
8
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastify-mssql - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

.github/workflows/release.yml

18

package.json
{
"name": "fastify-mssql",
"version": "1.1.1",
"version": "1.2.0",
"description": "Fastify Plugin to manage MSSQL connections",

@@ -37,14 +37,14 @@ "main": "plugin.js",

"dependencies": {
"fastify-plugin": "^3.0.0"
"fastify-plugin": "^4.1.0"
},
"devDependencies": {
"@types/jest": "^26.0.20",
"@types/mssql": "^6.0.7",
"eslint": "^7.27.0",
"@types/jest": "^29.0.0",
"@types/mssql": "^8.0.0",
"eslint": "^8.0.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.23.3",
"eslint-plugin-prettier": "^3.4.0",
"fastify": "^3.11.0",
"jest": "^27.0.1",
"mssql": "^7.1.0",
"eslint-plugin-prettier": "^4.0.0",
"fastify": "^4.0.0",
"jest": "^29.0.0",
"mssql": "^9.0.1",
"prettier": "^2.3.0"

@@ -51,0 +51,0 @@ },

@@ -26,3 +26,6 @@ 'use strict'

})
fastify.decorate('mssql', { pool })
fastify.decorate('mssql', {
pool,
sqlTypes: MSSql
})
}

@@ -29,0 +32,0 @@

@@ -41,1 +41,19 @@ # fastify-mssql

```
If you need to access the [SQL Data Types](https://github.com/tediousjs/node-mssql#data-types) you can access them by using the `mssql.sqlTypes` property:
```js
app.get('/users/:userId', async function (request) {
try {
const pool = await app.mssql.pool.connect()
const query = 'SELECT * FROM users where id=@userID'
const res = await pool
.request()
.input('userID', app.mssql.sqlTypes.Int, request.params.userId)
.query(query)
return { user: res.recordset }
} catch (err) {
return { error: err.message }
}
})
```

@@ -56,12 +56,39 @@ const buildServer = require('./build-server')

})
const response = await app.inject({
method: 'GET',
url: '/users'
app.get('/users/:userId', async function (request) {
try {
const pool = await app.mssql.pool.connect()
const query = 'SELECT * FROM [dbo].[Users] where id=@userID;'
const res = await pool
.request()
.input('userID', app.mssql.sqlTypes.Int, request.params.userId)
.query(query)
return { user: res.recordset }
} catch (err) {
return { error: err.message }
}
})
const body = JSON.parse(response.body)
expect(app.mssql.pool).not.toBe(undefined)
expect(response.statusCode).toBe(200)
expect(body.users.length).toBe(2)
{
const response = await app.inject({
method: 'GET',
url: '/users'
})
const body = JSON.parse(response.body)
expect(app.mssql.pool).not.toBe(undefined)
expect(response.statusCode).toBe(200)
expect(body.users.length).toBe(2)
}
{
const response = await app.inject({
method: 'GET',
url: '/users/2'
})
expect(response.statusCode).toBe(200)
expect(response.json()).toEqual({
user: [{ id: '2', name: 'fizzbuzz', email: 'fizzbuzz@gmail.com' }]
})
}
})
})

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc