npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

4shared

v1.0.1

Published

This is small lib, for using 4shared resorces in nodejs

Downloads

6

Readme

4Shared-API / fourShared API (www.4shared.com)

This is API Wrapper Library for Consuming 4Shared API usin NodeJS.Please visit the below link for more info 4Shared_Docs

  • All API's implemented.
  • All API's are only for Authenticated, Except FileSearch.
Search, Filter & Sorting:

Categories: - Music -1 - Video - 2 - Photo - 3 - Archieves - 4 - Books/Office - 5 - Programs - 6 - Web - 7 - Mobile - 8 - Android - 10

Sample use of Libarary is also, in the examples folder. Just Replace your keys there, to start testing the application.

Version

1.0.0

Tech

4Shared Uses OAuth Library for Authentication & Authorization

  • OAuth - Authentication & Authorization
  • Grunt - for JS Hint & Testing
  • Express - for Sample use of Lib Functionality

Installation

You need npm installed globally:

$ npm install -g npm

After that install the module as below,

$ npm install 4shared

Example

First Tab:

var fourSharedApi = require('../index');
var express = require('express');
var app = express();
var fs = require('fs');


var fileId = "";
var rootFolder = "";
var folderID = "";
var userID= "";

var client = new fourSharedApi({
	"oauth_consumer_key": "xxxx",
	"oauth_secret_key": "xxxx",
	"callback": "http://localhost:8080/callback",
	"access_token": "optional",
	"access_secret": "optional",
	"authorized": true
});

client.on('error', function(err) {
	console.log(err);
});

client.on('connected', function(is) {
	console.log(is);
});

app.get('/start', function(req, res) {
	client.authenticate(function(err, data) {
		if (err) throw err;
		res.redirect('https://api.4shared.com/v0/oauth/authorize?oauth_token=' + data.token);
	});
});

app.get('/callback', function(req, res) {
	client.callback(function(err, data) {
		if (err) throw err;
		res.json(data);
	});
});

app.get('/filesearch', function(req, res) {
	client.fileSearch(function(err, resp, body) {
		console.log(err);
		res.send(body)
	});
});

app.get('/filesearchparams', function(req, res) {
	var queryOpts = {
		category: "2",
		query: "Sky"
	};
	client.fileSearch(queryOpts, function(err, resp, body) {
		console.log(err);
		res.send(body)
	});
});

app.get('/userinfo', function(req, res) {
	client.userInfo(function(err, resp, body) {
		console.log(err);
		rootFolder = JSON.parse(body).rootFolderId;
		userID = JSON.parse(body).id;
		res.send(body);
	});
});

app.get('/uploadFile', function(req, res) {
	var formData = {
		folderId: "2iVI6yt1",
		description: "testing",
		tags: "test",
		file: fs.createReadStream(__dirname + '/origin.js')
	};

	client.uploadFile(formData, function(err, resp, body) {
		console.log(err);
		fileId = JSON.parse(body).id;
		res.send(body);
	});
});

app.get('/updateFile', function(req, res) {
	var formData2 = {
		file: fs.createReadStream(__dirname + '/replacement.js')
	}
	console.log(fileId);
	client.updateFile(fileId, formData2, function(err, resp, body) {
		console.log(err);
		res.send(body);
	});
});

app.get('/updateFileInfo', function(req, res) {
	var dad = {
		name: "nameisChanged"
	}
	console.log(fileId);
	client.updateFileInfo(fileId, dad, function(err, resp, body) {
		console.log(err);
		res.send(body);
	});
});

app.get('/fileinfo', function(req, res) {
	client.getfileInfo(fileId, false, function(err, resp, body) {
		console.log(err);
		res.send(body);
	});
})

app.get('/updateUserInfo', function(req, res) {
	var data = {
		firstName: "UpdateUser",
		description: "Hi How Are Yu!!"
	};
	client.updateUserInfo(data, function(err, resp, body) {
		console.log(err);
		res.send(body);
	});
});

app.get('/userfiles', function(req, res) {
	client.userFiles(function(err, resp, body) {
		console.log(err);
		res.send(body);
	});
});

app.get('/getOwnerInfo', function(req, res) {
	client.getOwnerInfo(userID, function(err, resp, body) {
		console.log(err);
		res.send(body);
	});
});

app.get('/foldersInfo', function(req, res) {
	console.log(rootFolder);
	client.foldersInfo(rootFolder, function(err, resp, body) {
		console.log(err);
		res.send(body);
	});
});

app.get('/childrenFolderInfo', function(req, res) {
	client.childrenFolderInfo(rootFolder, function(err, resp, body) {
		console.log(err);
		res.send(body);
	});
});

app.get('/listFilesInFolder', function(req, res) {
	client.listFilesInFolder(rootFolder, function(err, resp, body) {
		console.log(err);
		res.send(body);
	});
});

app.get('/createFolder', function(req, res) {
	var foldata = {
		parentId: "2iVI6yt1",
		name: "testFolder",
		description: "test Folder.."
	}
	client.createFolder(foldata, function(err, resp, body) {
		console.log(err);
		folderID = JSON.parse(body).id;
		res.send(body);
	});
});

app.get('/updateFolderInfo', function(req, res) {
	var foldata = {
		name: "testFolderUpdated",
		description: "test Folder.."
	}
	client.updateFolderInfo(folderID, foldata, function(err, resp, body) {
		console.log(err);
		res.send(body);
	});
});


app.get('/deleteFolder', function(req, res) {
	client.deleteFolder(folderID, function(err, resp, body) {
		console.log(err);
		res.send(body);
	});
});

app.get('/deleteFile', function(req, res) {
	client.deleteFile(fileId, function(err, resp, body) {
		console.log(err);
		res.send(body);
	});
});

var server = app.listen(8080,function(){
	console.log("Server Started");
});

Todo's

  • Write Tests
  • Add Code Comments

License

MIT