Skip to content

Commit c443cf2

Browse files
authored
Launch Maplibre and fully excise Mapbox (#1276)
Bye bye Mapbox
1 parent 26669bc commit c443cf2

File tree

25 files changed

+86
-825
lines changed

25 files changed

+86
-825
lines changed

backend/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ npm start
3030

3131
## Environments
3232

33-
There are three backend environments (stages), two database environments, unlimited frontend environments, and one Mapbox map.
33+
There are three backend environments (stages), two database environments, unlimited frontend environments, and one Maplibre map.
3434

3535
On the backend, there's production, staging, and your local development environment. Production uses the `fourtiesnyc` database, while other environments use `fourtiesnyc_staging`. This means your local server uses a shared database with staging. This is not ideal and came about because originally the app had only static photo data; it should be improved.
3636

3737
On the frontend, there are ephemeral environments created for each pull request, these all share `staging` as the backend.
3838

39-
There is one Mapbox map that is shared. This means you may see story labels on the map that are not in the staging database and can't be read.
39+
There is one Maplibre map that is shared. This means you may see story labels on the map that are not in the staging database and can't be read.
4040

4141
## Deployment
4242

@@ -138,13 +138,13 @@ There's currently no sign-up form for the mailing list. Addresses are just added
138138

139139
### Map sync
140140

141-
Every night, a cron job refreshes the materialized views, regenerates a set of geojson, pushes it to Mapbox, and triggers Mapbox's regeneration of the map tiles. Note that regenerating map tiles costs money, which is why it's not done continuously.
141+
Every night, a cron job refreshes the materialized views, regenerates a set of geojson, and generates PMTiles.
142142

143143
This important process supports geocode corrections and user story labels.
144144

145145
## Third party services
146146

147-
- Mapbox - For the map
147+
- Maplibre - For the map using self-hosted PMTiles
148148
- AWS SSM - For secrets
149149
- Postmark - For transactional and campaign emails
150150
- Netlify Identity - For admin users

backend/serverless.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ provider:
3333
JWT_SECRET: ${ssm:/${self:service}-${sls:stage}-jwt-secret}
3434
MODERATORS_TO_EMAIL: ${ssm:/${self:service}-${sls:stage}-moderators-to-email}
3535
MERCH_REVIEWER_EMAILS: ${ssm:/${self:service}-${sls:stage}-merch-reviewer-emails}
36-
MAPBOX_SK: ${ssm:/${self:service}-${sls:stage}-mapbox-sk}
3736
OPENAI_SK: ${ssm:/${self:service}-${sls:stage}-openai-sk}
3837
RAPIDAPI_API_KEY: ${ssm:/${self:service}-${sls:stage}-rapidapi-api-key}
3938
PRINTFUL_SK: ${ssm:/${self:service}-${sls:stage}-printful-sk}
@@ -90,17 +89,11 @@ functions:
9089
handler: checkMerchQueue.handler
9190
events:
9291
- schedule: cron(30 11 * * ? *)
93-
syncMap:
94-
enabled: '"${sls:stage}" == "production"'
95-
handler: syncMap.handler
96-
events:
97-
- schedule: cron(0 12 * * ? *)
98-
timeout: 900
9992
syncMapSelfHosted:
10093
enabled: '"${sls:stage}" == "production" || "${sls:stage}" == "staging"'
10194
handler: syncMapSelfHosted.handler
10295
events:
103-
- schedule: cron(10 12 * * ? *)
96+
- schedule: cron(0 12 * * ? *)
10497
timeout: 900
10598
memorySize: 4096
10699
layers:

backend/src/business/geodata/TilesetService.ts

Lines changed: 0 additions & 88 deletions
This file was deleted.

backend/src/business/stories/StoryUserEmailService.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
StoryEmailTemplateData,
1313
} from '../email/templates/StoryUserEmailTemplateData';
1414
import StoryUserRemovedTemplate from '../email/templates/StoryUserRemovedTemplate';
15-
import forgeStaticMapUrl from '../utils/forgeStaticMapUrl';
1615
import required from '../utils/required';
1716
import { createStoryToken } from './StoryTokenService';
1817

@@ -71,26 +70,15 @@ function forgeImageThumbnailUrl(photo: Story['photo']): string {
7170
return `https://photos.1940s.nyc/420-jpg/${photo.identifier}.jpg`;
7271
}
7372

74-
function forgeMapImageUrl(
75-
photo: Story['photo'],
76-
lngLat: Story['lngLat'],
77-
retina = false
78-
): string | null {
79-
if (!lngLat) {
80-
return null;
81-
}
82-
return forgeStaticMapUrl(photo.identifier, lngLat, 315, 315, 16, retina);
83-
}
84-
8573
function forgeStoryTemplateContext(story: Story): StoryEmailTemplateData {
8674
return {
8775
storytellerName: required(story.storytellerName, 'storytellerName'),
8876
photoDescription: describePhoto(story.photo),
8977
storyEditUrl: forgeStoryEditUrl(story),
9078
viewPhotoUrl: forgePhotoUrl(story.photo, story.lngLat),
9179
photoThumbnailUrl: forgeImageThumbnailUrl(story.photo),
92-
mapImageUrl: forgeMapImageUrl(story.photo, story.lngLat, false),
93-
mapImageUrlRetina: forgeMapImageUrl(story.photo, story.lngLat, true),
80+
mapImageUrl: null,
81+
mapImageUrlRetina: null,
9482
};
9583
}
9684

backend/src/business/utils/forgeStaticMapUrl.ts

Lines changed: 0 additions & 39 deletions
This file was deleted.

backend/src/business/utils/mapboxApi.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

backend/src/cron/syncMap.ts

Lines changed: 0 additions & 40 deletions
This file was deleted.

backend/syncMap.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

backend/webpack.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module.exports = {
1414
convertImage: './convertImage.ts',
1515
checkStaleStories: './checkStaleStories.ts',
1616
checkMerchQueue: './checkMerchQueue.ts',
17-
syncMap: './syncMap.ts',
1817
syncMapSelfHosted: './syncMapSelfHosted.ts',
1918
generateStoryTitles: './generateStoryTitles.ts',
2019
sendEmailCampaigns: './sendEmailCampaigns.ts',

0 commit comments

Comments
 (0)