aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-09-06 05:55:13 -0400
committerGravatar Vitaly Takmazov2023-06-14 06:16:56 +0300
commit84c842b0bbf23d0097b8df591573e98f41da6cc7 (patch)
treeec77fc82422bdd76722fb59e9a02ac3403d8c304
parentcdf5450067fae3a737db550eeb211524ddf663d8 (diff)
[backup] Initial version
-rw-r--r--backup/index.js37
-rw-r--r--backup/package.json20
2 files changed, 57 insertions, 0 deletions
diff --git a/backup/index.js b/backup/index.js
new file mode 100644
index 00000000..049c5bb9
--- /dev/null
+++ b/backup/index.js
@@ -0,0 +1,37 @@
+var argv = require('minimist')(process.argv.slice(2));
+var fetch = require('node-fetch');
+var _ = require('lodash');
+var url = require('url');
+
+if (typeof argv.u !== "string") {
+ console.log("username must be specified (-u ugnich)");
+ return;
+}
+
+var messages = [];
+
+function getBlogData(blogUrl, callback) {
+ fetch(url.format(blogUrl))
+ .then(function(res) {
+ return res.json()
+ })
+ .then(function(msgs) {
+ _.each(msgs, function(message) {
+ messages.push(message);
+ });
+ if (msgs.length == 20) {
+ blog.query.before_mid = msgs.slice(-1).pop().mid;
+ setTimeout(getBlogData, 1000, blog, callback);
+ } else {
+ callback();
+ }
+ });
+};
+
+var blog = url.parse("https://api.juick.com/messages", true);
+blog.query.uname = argv.u;
+
+getBlogData(blog, function() {
+ console.log(JSON.stringify(messages));
+});
+
diff --git a/backup/package.json b/backup/package.json
new file mode 100644
index 00000000..347dd428
--- /dev/null
+++ b/backup/package.json
@@ -0,0 +1,20 @@
+{
+ "name": "juick-backup",
+ "version": "1.0.0",
+ "description": "Juick export utility",
+ "main": "index.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/juick/backup.git"
+ },
+ "private": true,
+ "license": "MIT",
+ "dependencies": {
+ "lodash": "^4.15.0",
+ "minimist": "^1.2.0",
+ "node-fetch": "^1.6.0"
+ }
+}