Skip to content

Commit

Permalink
Linting (#89)
Browse files Browse the repository at this point in the history
* adding prettier

* prettier remediation

* audit remediation

* adding c8 for coverage
  • Loading branch information
eebbesen authored Oct 8, 2024
1 parent 9616450 commit 5b34d87
Show file tree
Hide file tree
Showing 15 changed files with 1,529 additions and 376 deletions.
48 changes: 18 additions & 30 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,20 @@
module.exports = {
"env": {
"browser": true,
"es6": true,
"node": true
env: {
browser: true,
es6: true,
node: true,
},
extends: 'eslint:recommended',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"sourceType": "module"
},
"rules": {
"indent": [
"error",
2
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"never"
]
}
};
sourceType: 'module',
},
rules: {
indent: ['error', 2],
'linebreak-style': ['error', 'unix'],
quotes: ['error', 'single'],
semi: ['error', 'never'],
},
};
16 changes: 8 additions & 8 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- run: npm ci
- run: npm test
- uses: actions/checkout@v4
- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- run: npm ci
- run: npm test
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": true
}
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,65 +1,88 @@
# ineedagyro-js

Gyros near you!

https://www.ineedagyro.com

## How?

Uses browser's `navigation.geolocation.getCurrentPosition()` to query [Yelp's Fusion API](https://www.yelp.com/developers/documentation/v3/business_search) using [yelp-fusion](https://github.com/Yelp/yelp-fusion).

## Run

1. Get API ID and secret from [Yelp](https://www.yelp.com/developers/v3/manage_app)
1. Set those values in your environment
See https://www.yelp.com/developers/v3/manage_app
See https://www.yelp.com/developers/v3/manage_app

```bash
export YELP_API_KEY=<your_yelp_API_ID>
```

### Using npm directly

```bash
npm install
npm start
```

### Using Docker

#### Build

To ensure you're not using an out-of-date image

```bash
docker compose build
```

#### Run

```bash
docker compose up -d
```

Then browse to http://localhost:8080/

#### Other options

If you want to view logs, omit `-d` from the previous command _or_

```bash
docker compose logs -f
```

## Test

Make sure karma-chrome-launcher is installed. This may cause problems with CI.

```bash
npm install karma-chrome-launcher --save-dev --link
```

```bash
Run tests
```

```bash
npm test
```

will run mocha for the server-side JavaScript and karma for the client-side tests

## Helpy things

### cURL

#### Call with token

Export the Yelp token you received (see above)
`export YELP_API_KEY=<see_get_token_section>`
then execute the request

```bash
curl -H "Authorization: Bearer $YELP_API_KEY" https://api.yelp.com/v3/businesses/search?location=48226&term=gyro
```

### Chrome location permissions reset

https://support.google.com/chrome/answer/114662?co=GENIE.Platform%3DDesktop&hl=en
24 changes: 12 additions & 12 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import express from 'express'
import bodyParser from 'body-parser'
import express from 'express';
import bodyParser from 'body-parser';

let app = express()
let app = express();

import indexRoutes from './routes/index.js'
app.use(indexRoutes)
import indexRoutes from './routes/index.js';
app.use(indexRoutes);

app.set('view engine', 'ejs')
app.use(bodyParser.urlencoded({extended: true}))
app.use(express.static('./public'))
app.set('view engine', 'ejs');
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static('./public'));

const port = process.env.PORT || 8080
export default app.listen(port, function(){
console.log('listening at ' + port)
})
const port = process.env.PORT || 8080;
export default app.listen(port, function () {
console.log('listening at ' + port);
});
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ services:
web:
build: .
ports:
- "8080:8080"
- '8080:8080'
volumes:
- ./:/usr/src/ineedagyro
environment:
Expand Down
Loading

0 comments on commit 5b34d87

Please sign in to comment.