Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

115
Visualizações
how to connect a custom nodejs module with mongodb published on azure artifact?

created a nodejs module called role-management, and I published it in azure artifacts(the equivalent of npm repository).

here's the code of this model :

const mongoose = require('mongoose');

exports.getRoles = async (db_url,key) => {
await mongoose.connect(db_url, { useNewUrlParser: true });
const UserSchema= new mongoose.Schema({ },{ strict: false });
const User = mongoose.model('User', UserSchema,'users');
const result = await User.find({ $or: [{ name: key }, { email: key }] });
console.log(result[0].roles)
return result[0].roles
}

I tried to install this module on my project, here's the code which use this module :

const getRoles=required('role-management')

const getItems = async (req, res) => {

try {
    const roles = await getRoles(
        process.env.db-url,
        req.Email
    )
    res.status(200).json(roles)
} catch (error) {

    handleError(res, error)
  }
 }
module.exports = { getItems }

now the problem is, when I try to hit getItem from an api the first time, it works and i'm getting the roles, but when I try the second time i got this error :

(node:21540) UnhandledPromiseRejectionWarning: RangeError [ERR_HTTP_INVALID_STATUS_CODE]: Invalid status code: undefined

is there something wrong with the role-management module ? mongoose connectivity problem ? could help please ?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda