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

dsgstng-api

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dsgstng-api - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

.eslintrc

73

app.js

@@ -11,3 +11,3 @@ const request = require('request'),

constructor(token) {
this.token = token || ''
this.token = token || ''
this.stream = {

@@ -20,7 +20,16 @@ resolution: {

return new Promise((res, rej) => {
request.get(`${origin}/stream/resolution?token=${this.token}`, (err, response, body) => {
if (err){
request.get({
url: `${origin}/stream/resolution`,
qs: {
token: this.token
}
}, (err, response, body) => {
if (err) {
util.log(err)
return rej(err)
}
if (response.statusCode != 200){
util.log(body)
return rej(body.data.message)
}
return res(JSON.parse(body).data)

@@ -35,3 +44,8 @@ })

return new Promise((res, rej) => {
request.post(`${origin}/stream/resolution?token=${this.token}`, {
request.post({
url: `${origin}/stream/resolution`
}, {
qs: {
token: this.token
},
json: true,

@@ -42,6 +56,10 @@ body: {

}, (err, response, body) => {
if (err){
if (err) {
util.log(err)
return rej(err)
}
if (response.statusCode != 200){
util.log(body)
return rej(body.data.message)
}
return res(JSON.parse(body).data)

@@ -58,11 +76,24 @@ })

* @param {string} [params.year] Year (default gets from Date.now())
* @param {string} params.season Anime season (example:'summer'or'spring')
* @param {string} [params.season] Anime season (example:'summer'or'spring')
*/
get: (params) => {
return new Promise((res, rej) => {
request.get(`${origin}/calendar/schedule`+ params ? `?year=${params.year ? params.year :new Date(Date.now()).getFullYear()}&season=${params.season}`:'' , (err, response, body) => {
if (err){
let conf = {
uri: `${origin}/calendar/schedule`
}
if (params.season && params.year){
conf.qs= {
year: params.year,
season: params.season
}
}
request.get(conf, (err, response, body) => {
if (err) {
util.log(err)
return rej(err)
}
if (response.statusCode != 200){
util.log(body)
return rej(body.data.message)
}
return res(JSON.parse(body).data)

@@ -76,2 +107,26 @@ })

}
module.exports = Api
module.exports = Api
// function request(data) {
// return new Promise(function (res, rej) {
// let xmlhttp = new XMLHttpRequest()
// xmlhttp.onreadystatechange = function () {
// let myObj
// if (this.responseText) {
// try {
// myObj = JSON.parse(this.responseText)
// } catch (e) {
// return rej('Error while parsing response')
// }
// res(myObj)
// }
// }
// xmlhttp.open('GET', data.url, true)
// if (data.header) {
// xmlhttp.setRequestHeader(data.header.name, data.header.value)
// }
// xmlhttp.send()
// })
// }

22

package.json
{
"name": "dsgstng-api",
"version": "0.0.3",
"version": "0.0.4",
"description": "Interface of interaction with dsgstng.com api",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"build": "cross-env NODE_ENV=production webpack --config webpack/prod.config.js --progress --display-error-details --colors",
"dev": "cross-env NODE_ENV=development webpack-dev-server --config webpack/dev.config.js --watch --colors"
},
"private": false,
"keywords":[
"dsgstng",
"api",
"request"
"keywords": [
"dsgstng",
"api",
"request"
],

@@ -18,2 +19,3 @@ "author": "ejnshtein",

"dependencies": {
"promise": "^8.0.1",
"request": "^2.87.0"

@@ -24,3 +26,11 @@ },

"url": "https://github.com/dsgstng/api.git"
},
"devDependencies": {
"cross-env": "^5.2.0",
"eslint": "^5.0.1",
"eslint-loader": "^2.0.0",
"webpack": "^4.14.0",
"webpack-cli": "^3.0.8",
"write-file-webpack-plugin": "^4.3.2"
}
}
Interface of interaction with [dsgstng.com](https://dsgstng.com) api
Docs soon
```
// api usage example
// backend api usage example
const Api = require('dsgstng-api')
const dsgstngApi = new Api() // OR if you had token, put it there.
dsgstngApi.stream.resolution.get()
.then(resolution => {
const dsgstngApi = new Api() // OR if you had token, put it here.
dsgstngApi.calendar.schedule.get()
.then(calendar => {
// Do something

@@ -14,4 +13,27 @@ })

})
// frontend api usage example (using webpack)
import Api from 'dsgstng-api/web.api'
const dsgstngApi = new Api() // again token if you had
dsgstngApi.calendar.schedule.get()
.then(calendar => {
// Do something
})
.catch(err => {
// Display error
})
// frontend without frameworks
// some.html
<script src="/node_modules/dsgstng-api/dist/DsgstngApi.min.js'></script>
// some.js
const dsgstngApi = new DsgstngApi()
dsgstngApi.calendar.schedule.get()
.then(calendar => {
// REEEEEEEEEEEEEEEEEEEEEEEE
})
.catch(err => {
// REEEEEEEEEEEEEEEEEEEEEEEE
})
```
Full doc soon
```
For more details contact [him](https://t.me/ejnshtein)
For details contact [him](https://t.me/ejnshtein)
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