Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,22 @@ Following extensions can be used to automatically redirect Quora URLs to Quetre:
- [digitalblossom/alternative-frontends](https://github.com/digitalblossom/alternative-frontends): contains other alternative front-ends.
- [mendel5/alternative-front-ends](https://github.com/mendel5/alternative-front-ends): a bit more general, containing alternative clients too.

### Development Helpers

Running any one of:

- `/fetchers/fetcher.js`

- `/fetchers/getAnswers.js`

- `/fetchers/getProfile.js`

- `/fetchers/getTopic.js`

with `node` and an argument will log the returned data to console. For example:

- `node fetchers/fetcher.js What-is-the-Linux-Web-Hosting`

---

## Credits
Expand Down
5 changes: 5 additions & 0 deletions fetchers/fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import * as cheerio from 'cheerio';
import axiosInstance from '../utils/axiosInstance.js';
import AppError from '../utils/AppError.js';
import { basename } from '../utils/misc.js'

////////////////////////////////////////////////////////
// FUNCTION
Expand Down Expand Up @@ -52,3 +53,7 @@ const fetcher = async resourceStr => {
// EXPORTS
////////////////////////////////////////////////////////
export default fetcher;

if (process.argv.length == 3 && basename(process.argv[1]) == 'fetcher.js') {
console.log(await fetcher(process.argv[2]))
}
5 changes: 5 additions & 0 deletions fetchers/getAnswers.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// import log from '../utils/log.js';
import AppError from '../utils/AppError.js';
import fetcher from './fetcher.js';
import { basename } from '../utils/misc.js'

////////////////////////////////////////////////////////
// FUNCTION
Expand Down Expand Up @@ -88,3 +89,7 @@ const getAnswers = async slug => {
// EXPORTS
////////////////////////////////////////////////////////
export default getAnswers;

if (process.argv.length == 3 && basename(process.argv[1]) == 'getAnswers.js') {
console.log(JSON.stringify(await getAnswers(process.argv[2])))
}
5 changes: 5 additions & 0 deletions fetchers/getProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
////////////////////////////////////////////////////////
import AppError from '../utils/AppError.js';
import fetcher from './fetcher.js';
import { basename } from '../utils/misc.js'

////////////////////////////////////////////////////////
// HELPER FUNCTIONS
Expand Down Expand Up @@ -216,3 +217,7 @@ const getProfile = async slug => {
// EXPORTS
////////////////////////////////////////////////////////
export default getProfile;

if (process.argv.length == 3 && basename(process.argv[1]) == 'getProfile.js') {
console.log(await getProfile(process.argv[2]))
}
5 changes: 5 additions & 0 deletions fetchers/getTopic.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
////////////////////////////////////////////////////////
import AppError from '../utils/AppError.js';
import fetcher from './fetcher.js';
import { basename } from '../utils/misc.js'

////////////////////////////////////////////////////////
// FUNCTION
Expand Down Expand Up @@ -59,3 +60,7 @@ const getTopic = async slug => {
// EXPORTS
////////////////////////////////////////////////////////
export default getTopic;

if (process.argv.length == 3 && basename(process.argv[1]) == 'getTopic.js') {
console.log(await getTopic(process.argv[2]))
}
3 changes: 3 additions & 0 deletions utils/misc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const basename = (path) => {
return path.split('/').reverse()[0];
}