Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nitunity/api-compiler

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nitunity/api-compiler - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

2

index.js
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",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc