This project was bootstrapped with Create React App.
Used styled-components and React Map GL as wrapper for Mapbox GL JS.
This application depends on some environment variables. Once you have cloned the
repository
github.com/jherax/mapbox-demo, go to
the root directory and create a .env file with the following keys:
EXPRESS_PORT=9000
# dev | prod | qa
NODE_ENV=dev# Graphql resource location
REACT_APP_GRAPHQL_RENTALSCAPE=https://fxjney46mbeijjyti3ysri6afi.appsync-api.us-west-2.amazonaws.com/graphql
REACT_APP_GRAPHQL_CITIES=http://localhost:9000/graphql
# Authorization Header
REACT_APP_AUTH_RENTALSCAPE=___Authorization_Key___
REACT_APP_MAPBOX_ACCESS_TOKEN=___React_Mapbox_Access_Token___Whitout those values, the app can't start properly.
Just run the command
npm install
npm run dev:serverThe Express backend is started by running npm run dev:server. The server is
listening by default in http://localhost:9000. You can
change the default port by setting the key EXPRESS_PORT in the .env file.
The following paths are part of the Express router:
The front-end application is started by running npm run start, then the
browser opens http://localhost:3000 with the default
view.
The following paths are part of the React router:
/Cities Autocomplete (default)/mapboxReact Map GL demo./playground/:sourceApollo GraphQL sandbox.:sourceGraphQL datasource:rentalscape | cities
The path that resolves Apollo queries is: /graphql.
đź’ˇ When running in non-production environment, the
/graphqland/sandboxpaths are enabled to run an Apollo Sandbox environment where we can now execute GraphQL our queries on our own server.
- Default path: localhost:9000/sandbox
- Online Sandbox: studio.apollographql.com/sandbox
This App suggest installing some VS Code extensions to ease the development experience. One of those extensions is the REST Client which allows you to send HTTP request and view the response in Visual Studio Code directly. This extension comes with a build-in support for making GraphQL requests.
You can find the file containing the graphql queries here:
- getCities.http
- getCitiesByName.http
- getCitiesByCountry.http
- getCitiesByLanguage.http
- getRegionDetails.http
- getRegionHouses.http
- getRegionNames.http
In the root directory, the following scripts are available:
-
npm run dev:serverRuns the Express server at http://localhost:9000. -
npm run test:beStart the test suite for the code in the/backenddirectory. -
npm run build:serverBuilds the app for production to thebackend/distfolder. -
npm run gendocsGenerates the publicREADME.htmlfile from markdown.
-
npm startRuns the app in the development mode. Open http://localhost:3000 to view it in the browser. The page will reload if you make edits. You will also see any lint errors in the console. -
npm testLaunches the test runner in the interactive watch mode. See the section about running tests for more information. -
npm run buildBuilds the app for production to thebuildfolder. It correctly bundles React in production mode and optimizes the build for best performance. The build is minified and the filenames include the hashes and Your app is ready to be deployed! (See the deployment section for more information). -
npm run ejectNote: this is a one-way operation. Once you
eject, you can’t go back!If you aren’t satisfied with the build tool and configuration choices, you can
ejectat any time. This command will remove the single build dependency from your project.Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except
ejectwill still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.You don’t have to ever use
eject. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
You can learn more in the Create React App documentation.
To learn React, check out the React documentation.