Skip to content

Commit

Permalink
Add visualization (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
PierrickP authored Jun 26, 2023
1 parent de7dd82 commit 22d1b07
Show file tree
Hide file tree
Showing 24 changed files with 2,071 additions and 101 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ yarn-error.log*
coverage

# Netlify build folders and files
.netlify/plugins
.netlify

functions/*.zip

.env
13 changes: 10 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
We welcome contributions to the project!

# How to contribute to the project?

All contributions to this project are welcome. To propose changes, we encourage contributors to:

1. Fork this project on GitHub
2. Create a new branch
3. Propose changes by opening a new pull request.
If you're looking for somewhere to start, check out the issues labeled "Good first issue" or Community.
3. Propose changes by opening a new pull request.
If you're looking for somewhere to start, check out the issues labeled "Good first issue" or Community.

# Issue and PR templates

We encourage contributors to format pull request titles following the [Conventional Commit Specification](https://www.conventionalcommits.org/en/v1.0.0/).

# Folder organization

- gbfs-validator

This is the heart of the validator. This folder contains a NodeJs package to validate GBFS Feeds.
Expand All @@ -21,7 +25,7 @@ Contains JSON schemas

- website

Contains the frontend, currently hosted by Netlify on https://gbfs-validator.netlify.app/
Contains the frontend, currently hosted by Netlify on https://gbfs-validator.mobilitydata.org/
It’s a tiny Vue SPA.

- functions
Expand All @@ -35,10 +39,13 @@ The function is only compatible with Netlify Function (https://www.netlify.com/p
Check-systems is a CLI tool to validate the whole “systems.csv” from https://github.com/NABSA/gbfs locally

# Code convention

"Sticking to a single consistent and documented coding style for this project is important to ensure that code reviewers dedicate their attention to the functionality of the validation, as opposed to disagreements about the coding style (and avoid bike-shedding https://en.wikipedia.org/wiki/Law_of_triviality )." This project uses the Eslint + Prettier to ensure lint (See .eslintrc.js and .prettierrc)

# Adding a new version

For adding a new version:

- Create a new folder under “gbfs-validator/schema” with the version as name (Eg: “vX.Y”).
- Add an “index.js” file. This file will define the possible JSON-schema to call for validation and the mandatory ones. See [master/gbfs-validator/schema/v2.2/index.js](https://github.com/fluctuo/gbfs-validator/blob/master/gbfs-validator/schema/v2.2/index.js) for an exemple.
- Fill the folder with all JSON-schemas for this version.
Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Questions? Please open an issue or reach out to MobilityData on the GBFS slack c

The validator is developed to be used “online” (hosted with a lambda function).

1. Open gbfs-validator.netlify.com/
1. Open gbfs-validator.mobilitydata.org/
2. Enter the feed’s auto-discovery URL
3. If needed, select the version. If not specified, the validator will pick the version mentioned in the `gbfs.json` file
4. Select file requirement options (free-floating or docked)
Expand Down Expand Up @@ -54,13 +54,18 @@ git clone https://github.com/fluctuo/gbfs-validator.git
cd gbfs-validator
```

### Set Environment variables

Copy `./website/.env.exemple` to `./website/.env`
And set values

### Run dev environment

With Node.js

```shell
yarn
yarn start
yarn run dev
```

Open `localhost:8080` on your browser
Expand All @@ -83,6 +88,7 @@ Open `localhost:8080` on your browser
This project follows the [all-contributors](https://allcontributors.org/docs/en/overview) specification, find the [emoji key here](https://allcontributors.org/docs/en/emoji-key). Contributions of any kind welcome! Please check out our [Contribution guidelines](/CONTRIBUTING.md) for details.

:warning: for contributions on schemas, please see [Versions README](gbfs-validator/versions/README.md)

## Acknowledgements

This project was originally created by Pierrick Paul at [fluctuo](https://fluctuo.com/) - MobilityData started maintaining the project in September 2021.
8 changes: 8 additions & 0 deletions functions/doc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const openapiSchema = require('./openapi')

exports.handler = function (event, context, callback) {
callback(null, {
statusCode: 200,
body: JSON.stringify(openapiSchema)
})
}
31 changes: 31 additions & 0 deletions functions/feed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const GBFS = require('gbfs-validator')

exports.handler = function (event, context, callback) {
let body

try {
body = JSON.parse(event.body)
} catch (err) {
callback(err, {
statusCode: 500,
body: JSON.stringify(err)
})
}

const gbfs = new GBFS(body.url)

gbfs
.getFiles()
.then((result) => {
callback(null, {
statusCode: 200,
body: JSON.stringify(result)
})
})
.catch((err) => {
callback(null, {
statusCode: 500,
body: JSON.stringify(err.message)
})
})
}
Loading

0 comments on commit 22d1b07

Please sign in to comment.