From 1151a95d7e8ba896e775971956d62fce1fd08ebd Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Wed, 11 Sep 2024 05:16:53 +0200 Subject: [PATCH] Connected to reddit. --- app.js | 23 ++++++++++++++++++++++- package-lock.json | 19 +++++++++++++++++++ package.json | 1 + 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/app.js b/app.js index 0e41038..3290958 100644 --- a/app.js +++ b/app.js @@ -1 +1,22 @@ -console.log('Reddit post dump'); +'use strict'; + +const config = require('config'); +const yargs = require('yargs').argv; +const snoowrap = require('snoowrap'); + +console.log(yargs.user); + +const reddit = new snoowrap(config.api); + +reddit.getUser(yargs.user).getSubmissions({ + sort: 'top' +}).then(submissions => { + const details = submissions.map(submission => { + return { + title: submission.title, + url: submission.url + }; + }); + + console.log(details); +}); diff --git a/package-lock.json b/package-lock.json index 2266654..ee87b85 100644 --- a/package-lock.json +++ b/package-lock.json @@ -125,6 +125,15 @@ "delayed-stream": "1.0.0" } }, + "config": { + "version": "1.30.0", + "resolved": "https://registry.npmjs.org/config/-/config-1.30.0.tgz", + "integrity": "sha1-HWCp81NIoTwXV5jThOgaWhbDum4=", + "requires": { + "json5": "0.4.0", + "os-homedir": "1.0.2" + } + }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", @@ -433,6 +442,11 @@ "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" }, + "json5": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/json5/-/json5-0.4.0.tgz", + "integrity": "sha1-BUNS5MTIDIbAkjh31EneF2pzLI0=" + }, "jsonfile": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", @@ -574,6 +588,11 @@ "resolved": "https://registry.npmjs.org/options/-/options-0.0.6.tgz", "integrity": "sha1-7CLTEoBrtT5zF3Pnza788cZDEo8=" }, + "os-homedir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=" + }, "os-locale": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-2.1.0.tgz", diff --git a/package.json b/package.json index 5db47a4..42157ff 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "author": "Niels Simenon", "license": "ISC", "dependencies": { + "config": "^1.30.0", "fs-extra": "^5.0.0", "note-log": "^2.1.11", "snoowrap": "^1.15.2",