🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

jamments-front

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jamments-front - npm Package Compare versions

Comparing version

to
2.0.0

25

lib/index.js

@@ -53,6 +53,11 @@ 'use strict';

* Create the API object
* @param { String } apiBaseAddr The API's full address (ex. https://comments.my-blog.net)
* @param { Object } options The options object
* @param { String } options.endpoint The API's full address (ex. https://comments.my-blog.net)
* @param { String } options.cachedFilesURI URI path to get to static files (without slashes, ex. static)
*/
constructor(apiBaseAddr) {
this.apiBaseAddr = apiBaseAddr;
constructor(config) {
if (!config || !config.endpoint || !config.cachedFilesURI) throw new TypeError('Both endpoint and cachedFilesURI must be defined');
this.endpoint = config.endpoint;
this.cachedFilesURI = config.cachedFilesURI;
this.commentsHash = {};

@@ -104,3 +109,3 @@ }

getSiteInfos() {
return getJsonData(`${this.apiBaseAddr}/infos/site.json`);
return getJsonData(`${this.endpoint}/${this.cachedFilesURI}/site.json`);
}

@@ -116,3 +121,3 @@

getComments(slug) {
return getJsonData(`${this.apiBaseAddr}/article/${cleanSlug(slug)}.json`)
return getJsonData(`${this.endpoint}/${this.cachedFilesURI}/${cleanSlug(slug)}.json`)
.then((comments) => {

@@ -162,3 +167,3 @@ comments.sort((a, b) => {

postComment(slug, comment, name, email, parentId) {
return ajax(`${this.apiBaseAddr}/comment/`, 'POST', { slug, comment, name, email, parent_id: parentId }); // eslint-disable-line
return ajax(`${this.endpoint}/comment/`, 'POST', { slug, comment, name, email, parent_id: parentId }); // eslint-disable-line
}

@@ -174,3 +179,3 @@

updateComment(commentId, secret, comment) {
return ajax(`${this.apiBaseAddr}/comment/${commentId}`, 'PATCH', { comment, user_secret: secret });
return ajax(`${this.endpoint}/comment/${commentId}`, 'PATCH', { comment, user_secret: secret });
}

@@ -185,3 +190,3 @@

deleteComment(commentId, secret) {
return ajax(`${this.apiBaseAddr}/comment/${commentId}`, 'DELETE', { user_secret: secret });
return ajax(`${this.endpoint}/comment/${commentId}`, 'DELETE', { user_secret: secret });
}

@@ -196,3 +201,3 @@

validateComment(commentId, secret) {
return ajax(`${this.apiBaseAddr}/comment/validate/${commentId}/`, 'POST', { user_secret: secret });
return ajax(`${this.endpoint}/comment/validate/${commentId}/`, 'POST', { user_secret: secret });
}

@@ -209,3 +214,3 @@

updateNewCommentsSubscription(articleId, userId, secret, subscribe) {
return ajax(`${this.apiBaseAddr}/notification/article/${articleId}/`, 'PATCH', { subscribe, user_id: userId, user_secret: secret });
return ajax(`${this.endpoint}/notification/article/${articleId}/`, 'PATCH', { subscribe, user_id: userId, user_secret: secret });
}

@@ -212,0 +217,0 @@ }

11

package.json
{
"name": "jamments-front",
"version": "1.0.1",
"version": "2.0.0",
"description": "Jamments frontend API library",

@@ -13,3 +13,3 @@ "main": "lib/index.js",

"prepare": "test -d .git && cd .git/hooks/ && curl -O https://raw.githubusercontent.com/Buzut/git-emojis-hook/master/commit-msg && curl -O https://raw.githubusercontent.com/Buzut/git-emojis-hook/master/prepare-commit-msg && chmod +x * || exit 0",
"buildDocs": "jsdoc -t node_modules/minami src -R README.md -d docs",
"buildDocs": "jsdoc -a all -c jsdoc.config.json src -R README.md -d docs",
"build": "rollup -c",

@@ -29,2 +29,3 @@ "prepublishOnly": "npm run build"

"devDependencies": {
"docdash": "^1.2.0",
"eslint": "^4.19.1",

@@ -34,7 +35,5 @@ "eslint-config-airbnb-base": "^13.0.0",

"eslint-plugin-security": "^1.4.0",
"jsdoc": "^3.5.5",
"minami": "^1.2.3",
"jsdoc": "^3.6.6",
"rollup": "^0.62.0"
},
"dependencies": {}
}
}

@@ -51,6 +51,11 @@ /**

* Create the API object
* @param { String } apiBaseAddr The API's full address (ex. https://comments.my-blog.net)
* @param { Object } options The options object
* @param { String } options.endpoint The API's full address (ex. https://comments.my-blog.net)
* @param { String } options.cachedFilesURI URI path to get to static files (without slashes, ex. static)
*/
constructor(apiBaseAddr) {
this.apiBaseAddr = apiBaseAddr;
constructor(config) {
if (!config || !config.endpoint || !config.cachedFilesURI) throw new TypeError('Both endpoint and cachedFilesURI must be defined');
this.endpoint = config.endpoint;
this.cachedFilesURI = config.cachedFilesURI;
this.commentsHash = {};

@@ -102,3 +107,3 @@ }

getSiteInfos() {
return getJsonData(`${this.apiBaseAddr}/infos/site.json`);
return getJsonData(`${this.endpoint}/${this.cachedFilesURI}/site.json`);
}

@@ -114,3 +119,3 @@

getComments(slug) {
return getJsonData(`${this.apiBaseAddr}/article/${cleanSlug(slug)}.json`)
return getJsonData(`${this.endpoint}/${this.cachedFilesURI}/${cleanSlug(slug)}.json`)
.then((comments) => {

@@ -160,3 +165,3 @@ comments.sort((a, b) => {

postComment(slug, comment, name, email, parentId) {
return ajax(`${this.apiBaseAddr}/comment/`, 'POST', { slug, comment, name, email, parent_id: parentId }); // eslint-disable-line
return ajax(`${this.endpoint}/comment/`, 'POST', { slug, comment, name, email, parent_id: parentId }); // eslint-disable-line
}

@@ -172,3 +177,3 @@

updateComment(commentId, secret, comment) {
return ajax(`${this.apiBaseAddr}/comment/${commentId}`, 'PATCH', { comment, user_secret: secret });
return ajax(`${this.endpoint}/comment/${commentId}`, 'PATCH', { comment, user_secret: secret });
}

@@ -183,3 +188,3 @@

deleteComment(commentId, secret) {
return ajax(`${this.apiBaseAddr}/comment/${commentId}`, 'DELETE', { user_secret: secret });
return ajax(`${this.endpoint}/comment/${commentId}`, 'DELETE', { user_secret: secret });
}

@@ -194,3 +199,3 @@

validateComment(commentId, secret) {
return ajax(`${this.apiBaseAddr}/comment/validate/${commentId}/`, 'POST', { user_secret: secret });
return ajax(`${this.endpoint}/comment/validate/${commentId}/`, 'POST', { user_secret: secret });
}

@@ -207,3 +212,3 @@

updateNewCommentsSubscription(articleId, userId, secret, subscribe) {
return ajax(`${this.apiBaseAddr}/notification/article/${articleId}/`, 'PATCH', { subscribe, user_id: userId, user_secret: secret });
return ajax(`${this.endpoint}/notification/article/${articleId}/`, 'PATCH', { subscribe, user_id: userId, user_secret: secret });
}

@@ -210,0 +215,0 @@ }