Going to follow this tutorial from MDN for getting the express app started and then add some additional features for our leaflet map and postgis routes.
We are going to add the app as a Heroku app following these instructions
- Install Heroku CLI and get Heroku account
- Go into express app directory and
heroku login
from commandline
- Environment
- Code editor
- sql client
- heroku account
- Setup Backend
- Setup new heroku node app, add postrgres DB
- Connect to postgres in sql client
- Run the db_setup.sql script to populate the schema (do this one block at a time)
- Import the streetcar dump file to populate with data
- Setup Frontend
- Install node and npm on your machine
- Create a new node github repo,
git clone
it locally, andcd
into it - Install Express Generator
npm install -g express-generator
, we will use this to generate the skeleton app. - Build the Express skeleton app using the
pug
view engine. The second variable is your app name.express leaflet-express-tutorial --view=pug
, and follow instructions to install and run - Install nodemon
npm install -g nodemon
- add
devstart
to package.json underscripts
with your app name"devstart": "SET DEBUG=leaflet-express-tutorial:* & nodemon ./bin/www"
- load and test app by running
npm run devstart
- ...
- ...
- make a new route for
streetcars
- create your
.env
file - connect to your Heroku DB with
DATABASE_URL
- add a map (http://duspviz.mit.edu/web-map-workshop/leaflet_nodejs_postgis/)
- connect map to API and draw features!