Skip to content
This repository has been archived by the owner on Nov 30, 2019. It is now read-only.

Commit

Permalink
Merge ca67f1e into 65b4c34
Browse files Browse the repository at this point in the history
  • Loading branch information
migo315 committed Oct 11, 2019
2 parents 65b4c34 + ca67f1e commit db515f8
Show file tree
Hide file tree
Showing 8 changed files with 147 additions and 110 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@ jobs:
with:
node-version: '10.x'
- run: npm install
- run: npm test
- run: npm run test-coverage
- name: Coveralls GitHub Action
uses: coverallsapp/github-action@v1.0.1
with:
github-token: ${{ secrets.github_token }}
path-to-lcov: 'coverage.info'
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ official [coaster.cloud](https://coaster.cloud) api.

This library is currently in early development. Contribution is welcome.

[![npm version](https://badge.fury.io/js/coaster.js.svg)](https://badge.fury.io/js/coaster.js)
[![Coverage Status](https://coveralls.io/repos/github/migo315/coaster.js/badge.svg?branch=master)](https://coveralls.io/github/migo315/coaster.js?branch=master)

## Installation
```
yarn add coaster.js
Expand Down
4 changes: 1 addition & 3 deletions config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
require('dotenv').config();

module.exports = {
baseUrl: 'https://api.coaster.cloud',
withAcl: false,
language: 'en',
baseUrl: 'https://api.coaster.cloud'
};
65 changes: 65 additions & 0 deletions package-lock.json

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

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"main": "src/client.js",
"scripts": {
"build": "minify src/client.js --mangle.keepClassName --deadcode.keepFnArgs --outFile dist/client.min.js",
"test": "jest"
"test": "jest",
"test-coverage": "jest --collectCoverage --coverageReporters=text-lcov >> coverage.info"
},
"repository": {
"type": "git",
Expand All @@ -25,6 +26,7 @@
"babel-jest": "^24.9.0",
"babel-minify": "^0.5.1",
"babel-preset-es2015": "^6.24.1",
"coveralls": "^3.0.7",
"jest": "^24.9.0"
}
}
9 changes: 1 addition & 8 deletions src/build-query.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const _ = require('lodash');
const { language } = require('../config');

const buildQuery = (config, withAcl) => {
const buildQuery = (config) => {
let query = [];

if (config.hasOwnProperty('page') && config.page) {
Expand All @@ -18,8 +17,6 @@ const buildQuery = (config, withAcl) => {

if (config.hasOwnProperty('language') && config.language) {
query.push('language=' + encodeURIComponent(config.language));
} else {
query.push('language=' + encodeURIComponent(language));
}

if (config.hasOwnProperty('sort') && config.sort) {
Expand Down Expand Up @@ -60,10 +57,6 @@ const buildQuery = (config, withAcl) => {
query.push('filter[]=' + encodeURIComponent(`founded.year:${year}`));
}

if (withAcl === true) {
query.push('acl=true');
}

return query.length > 0 ? '?' + query.join('&') : '';
};

Expand Down
12 changes: 6 additions & 6 deletions src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

// Imports
const Axios = require('axios');
const { baseUrl, withAcl } = require('../config');
const { baseUrl } = require('../config');
const { buildQuery } = require('./build-query');

module.exports = {
Expand All @@ -19,7 +19,7 @@ module.exports = {
let result = null;

try {
let response = await Axios.get(baseUrl + '/parks' + buildQuery(config, withAcl));
let response = await Axios.get(baseUrl + '/parks' + buildQuery(config));
result = response.data;
} catch (error) {
console.error(error)
Expand All @@ -33,7 +33,7 @@ module.exports = {
let result = null;

try {
let response = await Axios.get(baseUrl + '/parks/' + uuid + buildQuery(config, withAcl));
let response = await Axios.get(baseUrl + '/parks/' + uuid + buildQuery(config));
result = response.data;
} catch (error) {
console.error(error)
Expand All @@ -48,7 +48,7 @@ module.exports = {

try {
let response = await Axios.get(
baseUrl + '/parks/' + uuid + '/waiting-times' + buildQuery(config, withAcl)
baseUrl + '/parks/' + uuid + '/waiting-times' + buildQuery(config)
);
result = response.data;
} catch (error) {
Expand All @@ -70,7 +70,7 @@ module.exports = {
}

try {
let response = await Axios.get(url + buildQuery(config, withAcl));
let response = await Axios.get(url + buildQuery(config));
result = response.data;
} catch (error) {
console.error(error)
Expand All @@ -84,7 +84,7 @@ module.exports = {
let result = null;

try {
let response = await Axios.get(baseUrl + '/attractions/' + uuid + buildQuery(config, withAcl));
let response = await Axios.get(baseUrl + '/attractions/' + uuid + buildQuery(config));
result = response.data;
} catch (error) {
console.error(error)
Expand Down
Loading

0 comments on commit db515f8

Please sign in to comment.