Skip to content

Fastify plugin function - please help ... #4408

Closed Answered by Rimokas
Rimokas asked this question in Q&A
Discussion options

You must be logged in to vote

Jsummers, thank for the answer ...

Read this - https://www.fastify.io/docs/latest/Reference/Plugins/

At the end is a sample ...
Did own logas.js

  `  const fp = require( 'fastify-plugin' )
  module.exports = fp( function( fastify, prm, done )
  {
     fastify.decorate( 'jungtis', function()
     {
           const qryStr = "SELECT * FROM usersWHERE usr_id = ? and usr_psw = ? and allw = 1 LIMIT 1;"
           fastify.mysql.query( qryStr, [ prm.vrt, prm.slp ], function onResult ( err, result ) 
           {
              return ( err || result )
           })
        })
     done()
  })
  ` 

Now it's working :) ... Tfuuuu ... I can say that at this moment fully don't understand how and why…

Replies: 7 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@climba03003
Comment options

Comment options

You must be logged in to vote
2 replies
@climba03003
Comment options

@climba03003
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@melroy89
Comment options

Answer selected by Rimokas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants