mirror of
https://github.com/Raghu-Ch/nodeRestAPI.git
synced 2026-02-10 20:53:02 -05:00
initial commit
This commit is contained in:
49
node_modules/package-json/index.js
generated
vendored
Normal file
49
node_modules/package-json/index.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
'use strict';
|
||||
var got = require('got');
|
||||
var registryUrl = require('registry-url');
|
||||
|
||||
function get(url, cb) {
|
||||
got(url, {json: true}, function (err, data) {
|
||||
if (err && err.code === 404) {
|
||||
cb(new Error('Package or version doesn\'t exist'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (err) {
|
||||
cb(err);
|
||||
return;
|
||||
}
|
||||
|
||||
cb(null, data);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = function (name, version, cb) {
|
||||
var url = registryUrl(name.split('/')[0]) + name + '/';
|
||||
|
||||
if (typeof version !== 'string') {
|
||||
cb = version;
|
||||
version = '';
|
||||
}
|
||||
|
||||
get(url + version, cb);
|
||||
};
|
||||
|
||||
module.exports.field = function (name, field, cb) {
|
||||
var url = registryUrl(name.split('/')[0]) +
|
||||
'-/by-field/?key=%22' + name + '%22&field=' + field;
|
||||
|
||||
get(url, function (err, res) {
|
||||
if (err) {
|
||||
cb(err);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Object.keys(res).length === 0) {
|
||||
cb(new Error('Field `' + field + '` doesn\'t exist'));
|
||||
return;
|
||||
}
|
||||
|
||||
cb(null, res[name][field]);
|
||||
});
|
||||
};
|
||||
21
node_modules/package-json/license
generated
vendored
Normal file
21
node_modules/package-json/license
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
102
node_modules/package-json/package.json
generated
vendored
Normal file
102
node_modules/package-json/package.json
generated
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "package-json@^1.0.0",
|
||||
"scope": null,
|
||||
"escapedName": "package-json",
|
||||
"name": "package-json",
|
||||
"rawSpec": "^1.0.0",
|
||||
"spec": ">=1.0.0 <2.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"C:\\Users\\chvra\\Documents\\angular-play\\nodeRest\\node_modules\\latest-version"
|
||||
]
|
||||
],
|
||||
"_from": "package-json@>=1.0.0 <2.0.0",
|
||||
"_id": "package-json@1.2.0",
|
||||
"_inCache": true,
|
||||
"_location": "/package-json",
|
||||
"_nodeVersion": "0.12.4",
|
||||
"_npmUser": {
|
||||
"name": "sindresorhus",
|
||||
"email": "sindresorhus@gmail.com"
|
||||
},
|
||||
"_npmVersion": "2.10.1",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "package-json@^1.0.0",
|
||||
"scope": null,
|
||||
"escapedName": "package-json",
|
||||
"name": "package-json",
|
||||
"rawSpec": "^1.0.0",
|
||||
"spec": ">=1.0.0 <2.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/latest-version"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/package-json/-/package-json-1.2.0.tgz",
|
||||
"_shasum": "c8ecac094227cdf76a316874ed05e27cc939a0e0",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "package-json@^1.0.0",
|
||||
"_where": "C:\\Users\\chvra\\Documents\\angular-play\\nodeRest\\node_modules\\latest-version",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/sindresorhus/package-json/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"got": "^3.2.0",
|
||||
"registry-url": "^3.0.0"
|
||||
},
|
||||
"description": "Get the package.json of a package from the npm registry",
|
||||
"devDependencies": {
|
||||
"mocha": "*"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "c8ecac094227cdf76a316874ed05e27cc939a0e0",
|
||||
"tarball": "https://registry.npmjs.org/package-json/-/package-json-1.2.0.tgz"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"gitHead": "0119e976716d376994fd8d40ef7112dca597f4b6",
|
||||
"homepage": "https://github.com/sindresorhus/package-json",
|
||||
"keywords": [
|
||||
"npm",
|
||||
"registry",
|
||||
"package",
|
||||
"pkg",
|
||||
"package.json",
|
||||
"json",
|
||||
"module",
|
||||
"scope",
|
||||
"scoped"
|
||||
],
|
||||
"license": "MIT",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "sindresorhus",
|
||||
"email": "sindresorhus@gmail.com"
|
||||
}
|
||||
],
|
||||
"name": "package-json",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/sindresorhus/package-json.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"version": "1.2.0"
|
||||
}
|
||||
57
node_modules/package-json/readme.md
generated
vendored
Normal file
57
node_modules/package-json/readme.md
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
# package-json [](https://travis-ci.org/sindresorhus/package-json)
|
||||
|
||||
> Get the package.json of a package from the npm registry
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save package-json
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var packageJson = require('package-json');
|
||||
|
||||
packageJson('pageres', 'latest', function (err, json) {
|
||||
console.log(json);
|
||||
//=> { name: 'pageres', ... }
|
||||
});
|
||||
|
||||
// also works with scoped packages
|
||||
packageJson('@company/package', 'latest', function (err, json) {
|
||||
console.log(json);
|
||||
//=> { name: 'package', ... }
|
||||
});
|
||||
|
||||
packageJson.field('pageres', 'description', function (err, field) {
|
||||
console.log(field);
|
||||
//=> 'Capture website screenshots'
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### packageJson(name, [version], callback)
|
||||
|
||||
You can optionally specify a version (e.g. `0.1.0`) or `latest`.
|
||||
If you don't specify a version you'll get the [main entry](http://registry.npmjs.org/pageres/) containing all versions.
|
||||
|
||||
### packageJson.field(name, field, callback)
|
||||
|
||||
Get a specific field in the `package.json`.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [npm-keyword](https://github.com/sindresorhus/npm-keyword) - Get a list of npm packages with a certain keyword
|
||||
- [npm-user](https://github.com/sindresorhus/npm-user) - Get user info of a npm user
|
||||
- [npm-email](https://github.com/sindresorhus/npm-email) - Get the email of a npm user
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](http://sindresorhus.com)
|
||||
Reference in New Issue
Block a user