diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..b512c09 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/Dockerfile.template b/Dockerfile.template index 0c70008..aa577b7 100644 --- a/Dockerfile.template +++ b/Dockerfile.template @@ -8,12 +8,12 @@ ENV FSXA_NAVIGATION_SERVICE=... ENV FSXA_MODE=... ENV FSXA_TENANT_ID=... COPY package*.json ./ -RUN npm ci +RUN npm ci --no-optional COPY . . RUN npx nuxt build --config-file nuxt.config.ts --standalone \ && rm -rf node_modules && \ - NODE_ENV=production npm ci --production --silent \ - && NODE_ENV=production npm install nuxt-start@2.15.7 + NODE_ENV=production npm ci --production --silent --no-optional \ + && NODE_ENV=production npm install --no-optional nuxt-start@2.15.7 FROM node:14.17.1-alpine3.13 AS runtime diff --git a/customRoutes/download.ts b/customRoutes/download.ts index eb12e63..e8f0e19 100644 --- a/customRoutes/download.ts +++ b/customRoutes/download.ts @@ -15,17 +15,23 @@ export default { error: 'No identifier was specified' }) } - const media = await context.fsxaAPI.fetchElement({ - id: req.params.identifier, - locale: req.query.locale as string - }) - if (media.resolutions && media.resolutions.ORIGINAL) { - return res.redirect(media.resolutions.ORIGINAL.url) + try { + const media = await context.fsxaAPI.fetchElement({ + id: req.params.identifier, + locale: req.query.locale as string + }) + if (media.resolutions && media.resolutions.ORIGINAL) { + return res.redirect(media.resolutions.ORIGINAL.url) + } + res.send({ + error: 'Unknown media type', + media + }) + } catch (e) { + res.status(500).json({ + error: (e as Error).message + }) } - res.send({ - error: 'Unknown media type', - media - }) }, route: '/download/:identifier' } diff --git a/nuxt.config.ts b/nuxt.config.ts index bc47081..8e139ad 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -66,14 +66,7 @@ const config: NuxtConfig = { modules: [ // Doc: https://axios.nuxtjs.org/usage '@nuxtjs/axios', - [ - 'fsxa-nuxt-module', - { - NUXT_HOST: process.env.NUXT_HOST, - NUXT_PORT: process.env.NUXT_PORT, - FSXA_MODE: process.env.FSXA_MODE - } - ] + 'fsxa-nuxt-module' ], /* ** Axios module configuration diff --git a/tsconfig.json b/tsconfig.json index 3eb2ad6..e51526c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -19,5 +19,5 @@ }, "types": ["@types/node"] }, - "exclude": ["**/node_modules"] + "exclude": ["**/node_modules", "cypress/**"] }