@nitunity/api-compiler
Advanced tools
Comparing version 0.0.2 to 0.0.3
require('dotenv').config() | ||
require('./modules') | ||
module.exports = require('./modules') |
const request = require('./request') | ||
request.posts() | ||
.then(async (response) => { | ||
let counter = 0; | ||
let interval = setInterval(() => { | ||
if (counter >= response.length) { | ||
clearInterval(interval) | ||
return | ||
} | ||
request.post(response[counter]) | ||
.then((res) => { | ||
console.log(res.id) | ||
}) | ||
.catch(e => { | ||
console.log(e.message) | ||
}) | ||
counter++ | ||
}, 2000) | ||
}) | ||
.catch(e => { | ||
console.log(e.message) | ||
}) | ||
module.exports.run = () => { | ||
request.posts() | ||
.then((response) => { | ||
let counter = 0; | ||
let interval = setInterval(() => { | ||
if (counter >= response.length) { | ||
clearInterval(interval) | ||
return | ||
} | ||
let slug = response[counter] | ||
request.post(slug) | ||
.then((res) => { | ||
request.categories() | ||
.then((response) => { | ||
console.log('Categories exists') | ||
}) | ||
.catch(e => { | ||
console.log(e.message) | ||
}) | ||
}) | ||
.catch(e => { | ||
console.log(e.message) | ||
}) | ||
counter++ | ||
}, 2000) | ||
}) | ||
.catch(e => { | ||
console.log(e.message) | ||
}) | ||
request.category() | ||
.then((response) => { | ||
let counter = 0 | ||
let interval = setInterval( () => { | ||
if (counter >= response.length) { | ||
clearInterval(interval) | ||
return | ||
} | ||
request.categoryPosts(response[counter]) | ||
.then((res) => { | ||
console.log(res) | ||
}) | ||
.catch(e => { | ||
console.log(e.message) | ||
}) | ||
request.categories() | ||
.then((response) => { | ||
console.log(response[0].title) | ||
}) | ||
.catch(e => { | ||
console.log(e.message) | ||
}) | ||
counter++ | ||
}, 2000) | ||
}) | ||
.catch(e => { | ||
console.log(e.message) | ||
}) | ||
request.categorySingle() | ||
.then((response) => { | ||
let counter = 0 | ||
let interval = setInterval( () => { | ||
if (counter >= response.length) { | ||
clearInterval(interval) | ||
counter = 0 | ||
return | ||
} | ||
let slug = response[counter] | ||
let cnt = 1 | ||
let int = setInterval(() => { | ||
request.categoryPosts(slug, cnt) | ||
.then((res) => { | ||
if (res.posts.current_page !== res.posts.last_page) { | ||
cnt++ | ||
} else { | ||
clearInterval(int) | ||
} | ||
}) | ||
.catch(e => { | ||
console.log(e.message) | ||
}) | ||
}, 2000) | ||
counter++ | ||
}, 2000) | ||
}) | ||
.catch(e => { | ||
console.log(e.message) | ||
}) | ||
// request.post() | ||
// .then((response) => { | ||
// | ||
// }) | ||
// .catch(e => { | ||
// console.log(e.message) | ||
// }) | ||
request.postSingle() | ||
.then((response) => { | ||
let counter = 0 | ||
let interval = setInterval(async () => { | ||
if (counter >= response.length) { | ||
clearInterval(interval) | ||
return | ||
} | ||
let slug = response[counter] | ||
let post = await request.post(slug) | ||
console.log(post.title, ' - ', post.id, '-', counter) | ||
counter++ | ||
}, 2000) | ||
}) | ||
.catch(e => { | ||
console.log(e.message) | ||
}) | ||
} |
@@ -15,10 +15,4 @@ const fetch = require('node-fetch') | ||
} | ||
async post(slug) | ||
async categorySingle() | ||
{ | ||
const response = await fetch(`${process.env.API_URL}/posts/${slug}?path=${process.env.APP_NAME}`) | ||
return await response.json() | ||
} | ||
async category() | ||
{ | ||
const response = await fetch(`${process.env.API_URL}/categories?path=${process.env.APP_NAME}`) | ||
@@ -30,15 +24,20 @@ const result = await response.json() | ||
} | ||
async categoryPosts(slug) | ||
async categoryPosts(slug, counter) | ||
{ | ||
let counter = 0 | ||
setInterval(async () => { | ||
counter++ | ||
const response = await fetch(`${process.env.API_URL}/categories/${slug}?path=${process.env.APP_NAME}&page=${counter}`) | ||
return await response.json() | ||
}, 2000) | ||
const response = await fetch(`${process.env.API_URL}/categories/${slug}?path=${process.env.APP_NAME}&page=${counter}`) | ||
return await response.json() | ||
} | ||
async post(slug) | ||
{ | ||
const response = await fetch(`${process.env.API_URL}/posts/${slug}?path=${process.env.APP_NAME}`) | ||
return await response.json() | ||
} | ||
async postSingle() | ||
{ | ||
const response = await fetch(`${process.env.API_URL}/posts?path=${process.env.APP_NAME}`) | ||
return await response.json() | ||
} | ||
} | ||
module.exports = new Request() |
{ | ||
"name": "@nitunity/api-compiler", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "This package is API for compiling HTML templates using Nunjucks template engine", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4507
120
14
6