Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
kaushik94 committed Sep 17, 2021
0 parents commit d4d9bfb
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
39 changes: 39 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import axios from "axios";
import Cookies from 'js-cookie'

const js = {
baseURL: "",
configure: (obj) => {
if (obj && obj.hasOwnProperty("baseURL")) {
if (obj["baseURL"].constructor.name === "String") {
js.baseURL = obj["baseURL"]
}
}
},
login: ({email, password}) => {
return axios.post(js.baseURL+"/login", {
email: email,
password: password,
})
},
logout: () => {
Cookies.remove("jwt");
},
register: ({email, password}) => {
return axios.post(js.baseURL+"/signup", {
email: email,
password: password,
})
},
getJWTToken: () => {
return Cookies.get("jwt");
},
isAuthenticated: () => {
if (Cookies.get("jwt")) {
return true;
}
return false;
},
}

export default js;
26 changes: 26 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "@kaushik_varanasi/rocketsgraphql-js-sdk",
"version": "1.0.4",
"description": "JS SDK to use RocketsGraphQl APIs",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/RocketsGraphQL/rocket-js-sdk.git"
},
"keywords": [
"js",
"sdk",
"graphql"
],
"author": "Kaushik Varanasi",
"license": "ISC",
"bugs": {
"url": "https://github.com/RocketsGraphQL/rocket-js-sdk/issues"
},
"homepage": "https://github.com/RocketsGraphQL/rocket-js-sdk#readme",
"dependencies": {
"axios": "^0.21.4",
"js-cookie": "^3.0.1"
},
"devDependencies": {}
}

0 comments on commit d4d9bfb

Please sign in to comment.