Skip to content

Commit

Permalink
feat: deprecate stack domain and base url
Browse files Browse the repository at this point in the history
  • Loading branch information
dargmuesli committed Oct 5, 2022
1 parent 1b1e692 commit a570a87
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 30 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ FROM node:18.8.0-slim@sha256:12b15efcc41e137ca24d9a13acade91f67c8da3729be8af48dd

ARG CI=false
ENV CI ${CI}
ARG NUXT_ENV_STACK_DOMAIN=maev.si
ENV NUXT_ENV_STACK_DOMAIN=${NUXT_ENV_STACK_DOMAIN}
ARG NUXT_PUBLIC_STACK_DOMAIN=maev.si
ENV NUXT_PUBLIC_STACK_DOMAIN=${NUXT_PUBLIC_STACK_DOMAIN}
ENV NODE_OPTIONS=--openssl-legacy-provider

WORKDIR /srv/app/
Expand Down
5 changes: 4 additions & 1 deletion nuxt/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import graphqlPlugin from '@rollup/plugin-graphql'
import localeDe from './locales/de.json'
import localeEn from './locales/en.json'
import {
BASE_URL,
SITEMAP_EXCLUSIONS,
SITEMAP_EXCLUSIONS_LOCALIZED,
LOCALES,
Expand All @@ -19,6 +18,10 @@ for (const exclusion of SITEMAP_EXCLUSIONS) {
}
}

const BASE_URL =
'https://' + process.env.NUXT_PUBLIC_STACK_DOMAIN ||
`${process.env.HOST || 'localhost'}:3000` // TODO: deprecated

export default defineNuxtConfig({
cookies: {
necessary: [
Expand Down
5 changes: 2 additions & 3 deletions nuxt/plugins/urql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { useMaevsiStore } from '~/store'
// const ssrKey = '__URQL_DATA__'

export default defineNuxtPlugin(async (nuxtApp) => {
const host = useHost()
const ssr = ssrExchange({
isClient: process.client,
})
Expand Down Expand Up @@ -86,9 +87,7 @@ export default defineNuxtPlugin(async (nuxtApp) => {
},
url: process.server
? 'http://postgraphile:5000/graphql'
: 'https://postgraphile.' +
(process.env.NUXT_ENV_STACK_DOMAIN || 'maevsi.test') +
'/graphql',
: 'https://postgraphile.' + host + '/graphql',
exchanges: [
...(config.public.isInDevelopment ? [devtoolsExchange] : []),
dedupExchange,
Expand Down
7 changes: 0 additions & 7 deletions nuxt/plugins/util/constants.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import { LocaleObject } from '@nuxtjs/i18n/dist/runtime/composables'

export const STACK_DOMAIN =
process.env.NUXT_ENV_STACK_DOMAIN || 'localhost:3000'
export const BASE_URL =
(process.env.NUXT_ENV_STACK_DOMAIN === undefined ? 'http' : 'https') +
'://' +
STACK_DOMAIN

export const LOCALES: LocaleObject[] = [
{
code: 'en',
Expand Down
4 changes: 0 additions & 4 deletions nuxt/plugins/util/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ export const REGEX_UPPERCASE_NONE = /^[^A-Z]+$/
export const REGEX_URL_HTTPS = /^https:\/\//
export const REGEX_UUID =
/^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$/
export const TUSD_FILES_URL =
'https://tusd.' +
(process.env.NUXT_ENV_STACK_DOMAIN || 'maevsi.test') +
'/files/'
export const VALIDATION_ADDRESS_LENGTH_MAXIMUM = 300
export const VALIDATION_EMAIL_ADDRESS_LENGTH_MAXIMUM = 320
export const VALIDATION_EVENT_DESCRIPTION_LENGTH_MAXIMUM = 10000
Expand Down
15 changes: 5 additions & 10 deletions nuxt/server/api/ical.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { Invitation } from '~/types/invitation'
export default async function (compatibilityEvent: CompatibilityEvent) {
const { req, res } = compatibilityEvent
const body = await readBody(req)
const host = useHost()

const contact: Contact = body.contact
const event: MaevsiEvent = body.event
Expand All @@ -22,20 +23,17 @@ export default async function (compatibilityEvent: CompatibilityEvent) {
'Content-Disposition',
'attachment; filename="' + event.authorUsername + '_' + event.slug + '.ics"'
)
res.end(getIcalString(event, contact, invitation))
res.end(getIcalString(host, event, contact, invitation))
}

export function getIcalString(
host: string,
event: MaevsiEvent,
contact?: Contact,
invitation?: Invitation
): string {
const userEventPath = event.authorUsername + '/' + event.slug
const eventUrl =
'https://' +
(process.env.NUXT_ENV_STACK_DOMAIN || 'maevsi.test') +
'/event/' +
userEventPath
const eventUrl = 'https://' + host + '/event/' + userEventPath
const eventDescriptionHtml = mustache.render(
event.description ? `${eventUrl}\n${event.description}` : '',
{
Expand Down Expand Up @@ -88,10 +86,7 @@ export function getIcalString(
...(event.location && { location: event.location }),
organizer: {
name: event.authorUsername,
email:
event.authorUsername +
'@' +
(process.env.NUXT_ENV_STACK_DOMAIN || 'maevsi.test'),
email: event.authorUsername + '@' + host,
// mailto: 'explicit@mailto.com'
},
// attendees: [{
Expand Down
4 changes: 1 addition & 3 deletions nuxt/test/ical.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ afterAll(() => {
})

test('gets ical string', () => {
process.env.NUXT_ENV_STACK_DOMAIN = undefined

expect(
getIcalString({
getIcalString('maevsi.test', {
id: '1',
authorUsername: 'authorUsername',
description: '<p>description</p>',
Expand Down

0 comments on commit a570a87

Please sign in to comment.