Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: watchout-tw/watchout-common-functions
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.5.0
Choose a base ref
...
head repository: watchout-tw/watchout-common-functions
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.6.0
Choose a head ref
  • 5 commits
  • 3 files changed
  • 1 contributor

Commits on Nov 3, 2023

  1. Verified

    This commit was signed with the committer’s verified signature.
    scala-steward Scala Steward
    Copy the full SHA
    9b62016 View commit details
  2. Merge pull request #173 from watchout-tw/staging

    Make addPromotionEmail more genatic, accepting from as params
    wesley100002001 authored Nov 3, 2023
    Copy the full SHA
    f776595 View commit details

Commits on Apr 2, 2024

  1. Copy the full SHA
    65ccd94 View commit details
  2. Merge pull request #174 from watchout-tw/feature/ghost-5

    Add ghostV5 axios instance
    wesley100002001 authored Apr 2, 2024
    Copy the full SHA
    edcec9f View commit details
  3. Copy the full SHA
    7245331 View commit details
Showing with 52 additions and 7 deletions.
  1. +3 −0 config/config.sample.js
  2. +11 −7 lib/firestore.js
  3. +38 −0 lib/ghostV5.js
3 changes: 3 additions & 0 deletions config/config.sample.js
Original file line number Diff line number Diff line change
@@ -6,7 +6,10 @@ export default {
reCaptchaType: 'invisible',
ghostBaseURL: 'https://sample.watchout.tw',
ghostApiURL: 'https://sample.watchout.tw',
ghostV5ApiURL: 'https://sample.bunko.watchout.tw',
ghostToken: 'ghost-admin-api-key',
ghostV5ContentKey: '',
ghostV5AdminKey: '',
springboardURL: 'spring-board-url',
mapboxAccessToken: 'mapbox-access-token',
googleMapBaseURL: 'google-map-geocode-base-url',
18 changes: 11 additions & 7 deletions lib/firestore.js
Original file line number Diff line number Diff line change
@@ -340,15 +340,16 @@ async function getDocByContent(type, id) {

function makeDoc(type, rawDoc, status = 'inactive') {
let doc = {
status,
reference: null,
content: null,
title: null,
description: null,
ghostVersion: 'v5',
image: null,
imageLicense: null,
description: null,
publishedTo: defaultPubDest.value,
status,
reference: null,
tags: [],
publishedTo: defaultPubDest.value
title: null
}
doc = Object.assign(doc, ...authorTypes.map(type => ({ [type.valuePlural]: [] })))

@@ -1018,8 +1019,11 @@ async function updateNewsletter(newsletterID, newsletter) {
return getNewsletter(newsletterID)
}

async function addPromotionEmails(email) {
const promotionEmail = Object.assign({ email, from: 'life-etiquette-park' })
async function addPromotionEmails(email, from) {
const promotionEmail = {
email,
from
}
let ref = bunkoFS.collection('promotion-emails').doc()
await ref.set(promotionEmail)
}
38 changes: 38 additions & 0 deletions lib/ghostV5.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import axios from 'axios'
import config from 'watchout-common-functions/config/config'

let ghost = axios.create({
// baseURL: `${config.ghostV5ApiURL}/${config.env === 'production' ? 'production' : 'development'}`,
baseURL: config.ghostV5ApiURL,
timeout: 60000,
headers: { 'Authorization': config.ghostV5AdminKey }
})

const defaultInclude = ['authors']

export function getArticles(page = 1, include = defaultInclude) {
const params = {
limit: 100,
page,
order: 'updated_at desc',
include: include.join(','),
key: config.ghostV5ContentKey
}
return ghost.get(`/content/posts`, { params })
}

export function getArticle(id, include = defaultInclude) {
const params = {
include: include.join(','),
key: config.ghostV5contentKey
}
return ghost.get(`/content/posts/${id}`, { params })
}

// export function getArticleBySlug(slug) {
// return ghost.get(`/posts/slug/${slug}`)
// }

// export function getAuthors() {
// return ghost.get('/authors')
// }