Skip to content

Commit

Permalink
Merge pull request #143 from jordanopensource/patch/update_listmonk-i…
Browse files Browse the repository at this point in the history
…ntegration

Update listmonk integration
  • Loading branch information
thamudi authored Nov 27, 2024
2 parents d03832c + 1e8ef7a commit 3c6efa2
Show file tree
Hide file tree
Showing 9 changed files with 2,005 additions and 2,046 deletions.
4 changes: 2 additions & 2 deletions .sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ NUXT_SMTP_PASSWORD=somepass
NUXT_LIST_MONK_API_URL="https://monk.josa.ngo/api"
#samplr#NUXT_LIST_MONK_USER=monkusername
NUXT_LIST_MONK_USER=monkusername
#samplr#NUXT_LIST_MONK_PASSWORD=somepass
NUXT_LIST_MONK_PASSWORD=somepass
#samplr#NUXT_LIST_MONK_TOKEN=somepass
NUXT_LIST_MONK_TOKEN=somepass
NUXT_LIST_MONK_EN_TEMPLATE_ID="13"
NUXT_LIST_MONK_AR_TEMPLATE_ID="14"
NUXT_PUBLIC_MATOMO_HOST=""
Expand Down
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ ARG USER=node DRONE_COMMIT_SHA=${DRONE_COMMIT_SHA} DRONE_BUILD_NUMBER=${DRONE_BU
###########
# BUILDER #
###########
FROM node:18.14.0 AS builder

FROM node:22.11.0 AS builder

# copy build context and install dependencinpm res
WORKDIR /workspace
Expand All @@ -18,7 +17,7 @@ RUN yarn build
###########
# PROJECT #
###########
FROM node:18-slim
FROM node:22-slim

# pass the global args
ARG USER
Expand Down
6 changes: 2 additions & 4 deletions Dockerfile.local
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
FROM node:18 AS builder

FROM node:22.11.0

# copy build context and install dependencinpm res
WORKDIR /app
COPY . .
# Or try the below command since we are mapping the volumns
# COPY ./package.json .

RUN yarn install

# expose port
Expand Down
2 changes: 0 additions & 2 deletions docker-compose.yml → compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.8'

services:
nuha-web:
container_name: nuha-web
Expand Down
6 changes: 5 additions & 1 deletion nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default defineNuxtConfig({
include: ['~/types/*.ts'],
},
},

plugins: [
{ src: '~/plugins/use-scroll.ts', ssr: false, mode: 'client' },
{
Expand Down Expand Up @@ -76,6 +77,7 @@ export default defineNuxtConfig({
baseUrl: 'http://localhost:3000/',
debug: false,
},

runtimeConfig: {
public: {
targetEnv: '',
Expand Down Expand Up @@ -103,10 +105,12 @@ export default defineNuxtConfig({
listMonk: {
apiUrl: '',
user: '',
password: '',
token: '',
enTemplateId: '',
arTemplateId: '',
listId: '',
},
},

compatibilityDate: '2024-11-26',
})
30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,26 @@
},
"devDependencies": {
"@nuxtjs/i18n": "^8.5.2",
"@nuxtjs/tailwindcss": "^6.12.1",
"@sidebase/nuxt-auth": "^0.6.7",
"@nuxtjs/tailwindcss": "^6.12.2",
"@sidebase/nuxt-auth": "^0.9.4",
"@types/d3": "^7.4.3",
"nuxt": "^3.13.1"
"nuxt": "^3.11.2"
},
"dependencies": {
"@auth/mongodb-adapter": "^3.4.2",
"@element-plus/nuxt": "^1.0.10",
"@auth/mongodb-adapter": "^3.7.4",
"@element-plus/nuxt": "^1.1.0",
"@josango/nuxt3-build-banner": "^3.0.2",
"@nuxt/content": "^2.13.2",
"@nuxtjs/robots": "^4.1.6",
"@types/nodemailer": "^6.4.15",
"@vueuse/core": "^11.0.3",
"csv-parse": "^5.5.6",
"@nuxt/content": "^2.13.4",
"@nuxtjs/robots": "^4.1.11",
"@types/nodemailer": "^6.4.17",
"@vueuse/core": "^11.3.0",
"csv-parse": "^5.6.0",
"d3": "^7.9.0",
"element-plus": "^2.8.2",
"mongodb": "^6.8.1",
"next-auth": "4.24.7",
"element-plus": "^2.8.8",
"mongodb": "^6.10.0",
"next-auth": "4.21.1",
"node-xlsx": "^0.24.0",
"nodemailer": "^6.9.15",
"nodemailer": "^6.9.16",
"vue-matomo": "^4.2.0"
}
}
}
3 changes: 1 addition & 2 deletions server/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { resolve, reject } from './promise-handlers'
import { FileParser, getFileParser, FileType, getFileType } from './file-parser'
import { getFileParser, FileType, getFileType } from './file-parser'
import { predictCommentsResults } from './nuha-api-request'

export {
resolve,
reject,
FileParser,
getFileParser,
FileType,
getFileType,
Expand Down
18 changes: 9 additions & 9 deletions server/utils/listmonk-requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ enum ListmonkEndpoint {
export async function sendLoginEmail(
targetEmail: string,
locale: string,
loginUrl: string,
loginUrl: string
): Promise<void> {
await makeListmonkRequest(
ListmonkEndpoint.SEND_TRANSACTIONAL_EMAIL,
Expand All @@ -19,13 +19,13 @@ export async function sendLoginEmail(
template_id: parseInt(
locale === 'en'
? runtimeConfig.listMonk.enTemplateId
: runtimeConfig.listMonk.arTemplateId,
: runtimeConfig.listMonk.arTemplateId
),
data: {
link: loginUrl,
},
content_type: 'html',
}),
})
)
}

Expand All @@ -37,24 +37,24 @@ export async function subscribeEmail(email: string): Promise<void> {
name: email.substring(0, email.indexOf('@')),
status: 'enabled',
lists: [runtimeConfig.listMonk.listId].map(parseInt),
}),
})
)
}

async function makeListmonkRequest(
path: ListmonkEndpoint,
body: BodyInit,
body: BodyInit
): Promise<void | Response> {
return await fetch(`${runtimeConfig.listMonk.apiUrl}/${path}`, {
method: 'POST',
mode: 'cors',
headers: new Headers({
'Content-Type': 'application/json',
Authorization:
'Basic ' +
btoa(
runtimeConfig.listMonk.user + ':' + runtimeConfig.listMonk.password,
),
'token ' +
runtimeConfig.listMonk.user +
':' +
runtimeConfig.listMonk.token,
}),
body,
})
Expand Down
Loading

0 comments on commit 3c6efa2

Please sign in to comment.