Skip to content

Commit

Permalink
refactor: fetch template version from config (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
aahna-ashina committed Sep 6, 2022
1 parent 80a62c0 commit 7a28c59
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion server/pages/api/downloadPass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
console.log('ensName:', ensName)

// Populate the pass template
const templateVersion: number = 2
const templateVersion: number = config.appleTemplateVersion
const filePath: string = Passes.downloadPass(
Platform.Apple,
templateVersion,
Expand Down
7 changes: 4 additions & 3 deletions server/pages/api/pushUpdate.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { NextApiRequest, NextApiResponse } from 'next'
import { config } from '../../utils/Config'
import { Passes } from '../../utils/Passes'

// req = HTTP incoming message, res = HTTP server response
Expand All @@ -8,13 +9,13 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
// Push update of new template
console.log('Pushing template update...')

const templateFormatVersion: number = 2
const updateSent: boolean = Passes.pushUpdate(templateFormatVersion)
const templateVersion: number = config.appleTemplateVersion
const updateSent: boolean = Passes.pushUpdate(templateVersion)

res
.status(200)
.json({
updateSent: updateSent,
templateFormatVersion: templateFormatVersion,
templateVersion: templateVersion,
})
}
1 change: 1 addition & 0 deletions server/utils/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const config = {
dbSupabaseUrl: getEnvironmentVariable('DB_SUPABASE_URL'),
dbSupabaseAnonKey: getEnvironmentVariable('DB_SUPABASE_ANON_KEY'),

appleTemplateVersion: 2,
appleAuthTokenHmacSeed: getEnvironmentVariable('APPLE_AUTH_TOKEN_HMAC_SEED'),
appleWebServiceUrl: getEnvironmentVariable('APPLE_WEB_SERVICE_URL'),
appleCACertificatePEM: getEnvironmentVariable('APPLE_CA_CERTIFICATE_PEM'),
Expand Down

0 comments on commit 7a28c59

Please sign in to comment.