Skip to content

An NPM modules for fetching the credentials used for Maven repositories

License

Notifications You must be signed in to change notification settings

robhrt7/mvn-credentials

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MVN Credentials

This module gets your Maven credentials from the ~/.m2 folder on your system, if it exists.

Build Status

Installation

Install the module in the usual way

$ npm install mvn-credentials

Quick Start (tl;dr)

$ npm install mvn-credentials request
var mvnCredentials = require('mvn-credentials'),
    request = require('request'),
    util = require('util');

var credentials = mvnCredentials.fetch();

request({
    auth: {
      'user': credentials.username,
      'pass': credentials.password
    },
    url: 'www.google.com'
}, function(err, res, body) {

  if(err) return util.error(err);

  console.log(body);

});

Usage

First make sure your Node app knows about the module by requiring it

var mvnCredentials = require('mvn-credentials');

Then in the place you want to use the credentials, for an http.request for example, fill in the details by using the following markup:

var credentials = repoCredentials.fetch();

In your http.request you can use the credentials in the headers

var options = {
  hostname: 'www.google.com',
  port: '80',
  path: '/upload',
  method: 'POST',
  auth: credentials.username + ':' + credentials.password
};

http.request(options, function(res) {
  console.log(res.body);
});

Or when you're using the request module instead:

request({
    auth: {
      'user': credentials.username,
      'pass': credentials.password
    },
    url: 'www.google.com'
}, function(err, res, body) {

  if(err) return util.err(err);

  console.log(body);

});

Contributors

Mark de Jong mark@markdejong.com

Thanks & Credits

Gabriele di Stefano for inspiring me to do more with NodeJS.

License

MIT License

About

An NPM modules for fetching the credentials used for Maven repositories

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%