Coder Social home page Coder Social logo

sorohan / mvn-credentials Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mistermark/mvn-credentials

0.0 1.0 0.0 2.36 MB

An NPM modules for fetching the credentials used for Maven repositories

License: MIT License

JavaScript 55.52% Shell 29.53% Batchfile 14.95%

mvn-credentials's Introduction

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 request = require('request');
var mvnCredentials = require('mvn-credentials');

var promise = mvnCredentials.fetch();
promise
  .then(function (credentials) {
    request({
      auth: {
        'user': credentials.username,
        'pass': credentials.password
      },
      url: 'http://www.google.com'
    }, function (err, res, body) {
      if (err) return console.error(err);

      console.log(body);

    });
  }).fail(function (err) {
    throw new Error(err);
  });

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();

repoCredentials.fetch() will return a Promise with credentials payload:

{
  username: "username",
  password: "password"
}

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

var options = {
  hostname: 'http://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 [email protected]

Thanks & Credits

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

License

MIT License

mvn-credentials's People

Contributors

mistermark avatar robhrt7 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.