@nitunity/api-compiler
Advanced tools
Comparing version 0.2.1 to 0.2.2
require('dotenv').config() | ||
module.exports = require('./modules') | ||
module.exports = require('./modules').run({ | ||
views: '', | ||
cache: '', | ||
static: '', | ||
public: '' | ||
}) |
@@ -7,3 +7,3 @@ const request = require('./request') | ||
module.exports.run = async (config) => { | ||
await destroy(config) | ||
// await destroy(config) | ||
await call(config) | ||
@@ -15,3 +15,3 @@ } | ||
request.home() | ||
/*request.home() | ||
.then(() => { | ||
@@ -25,2 +25,3 @@ let counter = 1; | ||
params.paginator = new paginator(response, process.env.APP_URL) | ||
engine.home(config, params, counter) | ||
@@ -43,5 +44,5 @@ .then(() => { | ||
console.log(e.message) | ||
}) | ||
})*/ | ||
request.categories() | ||
/*request.categories() | ||
.then((response) => { | ||
@@ -59,11 +60,11 @@ params.categories = response | ||
console.log(e.message) | ||
}) | ||
})*/ | ||
request.categorySingle() | ||
.then((response) => { | ||
let counter = 1 | ||
let counter = 0 | ||
let interval = setInterval( () => { | ||
if (counter >= response.length) { | ||
clearInterval(interval) | ||
counter = 1 | ||
counter = 0 | ||
return | ||
@@ -76,3 +77,3 @@ } | ||
.then((res) => { | ||
if (res.posts.current_page !== res.posts.last_page) { | ||
if (res.posts.current_page <= res.posts.last_page) { | ||
params.category = res | ||
@@ -97,6 +98,6 @@ params.posts = res.posts | ||
}) | ||
}, 2000) | ||
counter++ | ||
}, 2000) | ||
}, 4000) | ||
}) | ||
@@ -180,3 +181,2 @@ .catch(e => { | ||
}) | ||
cnt = 1 | ||
@@ -183,0 +183,0 @@ counter++ |
@@ -1,2 +0,2 @@ | ||
const fetch = require('node-fetch') | ||
const axios = require('axios') | ||
@@ -11,15 +11,27 @@ class Request | ||
{ | ||
const response = await fetch(`${process.env.API_URL}?path=${process.env.APP_NAME}&page=${counter}`) | ||
return await response.json() | ||
const response = await axios.get(process.env.API_URL, { | ||
params: { | ||
path: process.env.APP_NAME, | ||
page: counter | ||
} | ||
}) | ||
return response.data | ||
} | ||
async categories() | ||
{ | ||
const response = await fetch(`${process.env.API_URL}/categories?path=${process.env.APP_NAME}`) | ||
return await response.json() | ||
const response = await axios.get(`${process.env.API_URL}/categories`, { | ||
params: { | ||
path: process.env.APP_NAME | ||
} | ||
}) | ||
return response.data | ||
} | ||
async categorySingle() | ||
{ | ||
const response = await fetch(`${process.env.API_URL}/categories?path=${process.env.APP_NAME}`) | ||
const result = await response.json() | ||
return result.map((category) => { | ||
const response = await axios.get(`${process.env.API_URL}/categories`, { | ||
params: { | ||
path: process.env.APP_NAME | ||
} | ||
}) | ||
return response.data.map((category) => { | ||
return category.slug | ||
@@ -30,25 +42,45 @@ }) | ||
{ | ||
const response = await fetch(`${process.env.API_URL}/categories/${slug}?path=${process.env.APP_NAME}&page=${counter}`) | ||
return await response.json() | ||
const response = await axios.get(`${process.env.API_URL}/categories/${slug}`, { | ||
params: { | ||
path: process.env.APP_NAME, | ||
page: counter | ||
} | ||
}) | ||
return response.data | ||
} | ||
async post(slug) | ||
{ | ||
const response = await fetch(`${process.env.API_URL}/posts/${slug}?path=${process.env.APP_NAME}`) | ||
return await response.json() | ||
const response = await axios.get(`${process.env.API_URL}/posts/${slug}`, { | ||
params: { | ||
path: process.env.APP_NAME | ||
} | ||
}) | ||
return response.data | ||
} | ||
async postSingle() | ||
{ | ||
const response = await fetch(`${process.env.API_URL}/posts?path=${process.env.APP_NAME}`) | ||
return await response.json() | ||
const response = await axios.get(`${process.env.API_URL}/posts`, { | ||
params: { | ||
path: process.env.APP_NAME | ||
} | ||
}) | ||
return response.data | ||
} | ||
async tags() | ||
{ | ||
const response = await fetch(`${process.env.API_URL}/tags?path=${process.env.APP_NAME}`) | ||
return await response.json() | ||
const response = await axios.get(`${process.env.API_URL}/tags`, { | ||
params: { | ||
path: process.env.APP_NAME | ||
} | ||
}) | ||
return response.data | ||
} | ||
async tagSingle() | ||
{ | ||
const response = await fetch(`${process.env.API_URL}/tags?path=${process.env.APP_NAME}`) | ||
const result = await response.json() | ||
return result.map((tag) => { | ||
const response = await axios.get(`${process.env.API_URL}/tags`, { | ||
params: { | ||
path: process.env.APP_NAME | ||
} | ||
}) | ||
return response.data.map((tag) => { | ||
return tag.slug | ||
@@ -59,4 +91,9 @@ }) | ||
{ | ||
const response = await fetch(`${process.env.API_URL}/tags/${slug}?path=${process.env.APP_NAME}&page=${counter}`) | ||
return await response.json() | ||
const response = await axios.get(`${process.env.API_URL}/tags/${slug}`, { | ||
params: { | ||
path: process.env.APP_NAME, | ||
page: counter | ||
} | ||
}) | ||
return response.data | ||
} | ||
@@ -63,0 +100,0 @@ } |
{ | ||
"name": "@nitunity/api-compiler", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "This package is API for compiling HTML templates using Nunjucks template engine", | ||
@@ -10,2 +10,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"axios": "^0.19.0", | ||
"dotenv": "^8.1.0", | ||
@@ -12,0 +13,0 @@ "node-fetch": "^2.6.0", |
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
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
13509
421
23
0
4
+ Addedaxios@^0.19.0
+ Addedaxios@0.19.2(transitive)
+ Addedfollow-redirects@1.5.10(transitive)