Skip to content

Commit

Permalink
implement eslint, babel, and prettier, resolve issue #1
Browse files Browse the repository at this point in the history
  • Loading branch information
spencerkordecki committed Jun 19, 2019
1 parent aaf77db commit cb1cc3d
Show file tree
Hide file tree
Showing 8 changed files with 4,742 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["@babel/preset-env"]
}
17 changes: 17 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
'env': {
'es6': true,
'node': true
},
'extends': 'standard',
'globals': {
'Atomics': 'readonly',
'SharedArrayBuffer': 'readonly'
},
'parserOptions': {
'ecmaVersion': 2018,
'sourceType': 'module'
},
'rules': {
}
}
4 changes: 4 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
singleQuote: true,
semi: false,
}
4,667 changes: 4,666 additions & 1 deletion package-lock.json

Large diffs are not rendered by default.

21 changes: 19 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"description": "Node module to communicate with the Vultr API",
"main": "src/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"build": "babel src -d dist",
"test": "echo \"Error: no test specified\" && exit 1",
"lint": "eslint src"
},
"repository": {
"type": "git",
Expand All @@ -19,5 +21,20 @@
"bugs": {
"url": "https://github.com/ddymko/vultr-node/issues"
},
"homepage": "https://github.com/ddymko/vultr-node#readme"
"homepage": "https://github.com/ddymko/vultr-node#readme",
"devDependencies": {
"@babel/cli": "^7.4.4",
"@babel/core": "^7.4.5",
"@babel/preset-env": "^7.4.5",
"eslint": "^5.16.0",
"eslint-config-standard": "^12.0.0",
"eslint-plugin-import": "^2.17.3",
"eslint-plugin-node": "^9.1.0",
"eslint-plugin-promise": "^4.1.1",
"eslint-plugin-standard": "^4.0.0",
"prettier": "^1.18.2"
},
"dependencies": {
"request": "^2.88.0"
}
}
4 changes: 4 additions & 0 deletions src/api/account.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
exports.info = {
url: '/account/info',
requestType: 'GET'
}
15 changes: 12 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
exports.print = function() {
console.log('Hello from Vultr!');
};
exports.initialize = apiKey => {
const makeApiRequest = require('./util/make-api-request').makeApiRequest
const account = require('./api/account')

return {
account: {
info: () => {
makeApiRequest(apiKey, account.info.requestType, account.info.url)
}
}
}
}
17 changes: 17 additions & 0 deletions src/util/make-api-request.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
exports.makeApiRequest = (apiKey, requestType, url) => {
const request = require('request')
const options = {
method: requestType,
url: `https://api.vultr.com/v1${url}`,
headers: {
'API-Key': apiKey
}
}

request(options, function (error, response, body) {
if (!error && response.statusCode === 200) {
const responseInfo = JSON.parse(body)
console.log(responseInfo)
}
})
}

0 comments on commit cb1cc3d

Please sign in to comment.