From b9847571f318787122535ab15fea1ee7c4cf5cf8 Mon Sep 17 00:00:00 2001 From: lesion Date: Fri, 21 Jan 2022 11:40:58 +0100 Subject: [PATCH] verso prod --- components/Cohort.vue | 2 +- components/TextCohort.vue | 2 +- components/components/Cohort.vue | 2 +- nuxt.config.js | 10 +++++++++- pages/add.vue | 2 +- pages/embed.vue | 4 ++-- pages/groups.vue | 5 ++--- pages/index.vue | 2 +- server/chew.js | 3 +-- 9 files changed, 19 insertions(+), 13 deletions(-) diff --git a/components/Cohort.vue b/components/Cohort.vue index e0ab7ca..5bc2610 100644 --- a/components/Cohort.vue +++ b/components/Cohort.vue @@ -44,7 +44,7 @@ export default { async fetch() { console.error('dentro fetch') console.error(this.cohort) - this.posts = await this.$http.$get(`http://localhost:3000/api/cohort/${this.cohort.id}`, + this.posts = await this.$http.$get(`/api/cohort/${this.cohort.id}`, { params: { maxPosts: this.maxPosts }}) // console.error(res) // .then(res => res.json()) diff --git a/components/TextCohort.vue b/components/TextCohort.vue index 2838dfc..caa292e 100644 --- a/components/TextCohort.vue +++ b/components/TextCohort.vue @@ -16,7 +16,7 @@ export default { cohort: Object }, async fetch(props) { - const res = await fetch(`http://localhost:3000/api/cohort/${props.cohort.id}`).then(res => res.json()) + const res = await fetch(`/api/cohort/${props.cohort.id}`).then(res => res.json()) return { cohort: res.cohort, posts: res.posts } }, } diff --git a/components/components/Cohort.vue b/components/components/Cohort.vue index 0003052..2266b7a 100644 --- a/components/components/Cohort.vue +++ b/components/components/Cohort.vue @@ -45,7 +45,7 @@ export default ({ // cohort: }), async fetch () { - const res = await $fetch(`http://localhost:3000/api/cohort/${props.cohort.id}`, + const res = await $fetch(`/api/cohort/${props.cohort.id}`, { params: { maxPosts: props.maxPosts }}) // .then(res => res.json()) return res diff --git a/nuxt.config.js b/nuxt.config.js index ab7e2a3..d839e19 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -24,12 +24,16 @@ export default { css: [ ], + server: { + host: '0' + }, + render: { static: { // Add CORS header to static files. setHeaders(res) { res.setHeader('Access-Control-Allow-Origin', '*'); - res.setHeader('Access-Control-Allow-Methods', 'GET'); + res.setHeader('Access-Control-Allow-Methods', 'GET, OPTIONS'); res.setHeader( 'Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept' @@ -42,6 +46,10 @@ export default { plugins: [ ], + env: { + baseUrl: process.env.BASE_URL || 'http://localhost:3000' + }, + // Auto import components: https://go.nuxtjs.dev/config-components components: true, diff --git a/pages/add.vue b/pages/add.vue index f417876..960492a 100644 --- a/pages/add.vue +++ b/pages/add.vue @@ -48,7 +48,7 @@ export default { methods: { copy (ev, item) { console.error('dentro copy') - const str = `` + const str = `` try { navigator.clipboard.writeText(str) } catch (e) { diff --git a/pages/embed.vue b/pages/embed.vue index 1ec5810..2245530 100644 --- a/pages/embed.vue +++ b/pages/embed.vue @@ -49,11 +49,11 @@ export default { }, computed: { code () { - return `` + return `` }, feed () { if (this.source && this.source.id) { - return `http://localhost:3000/api/source/${this.source.id}` + return `${process.baseUrl}/api/source/${this.source.id}` } else { return '' } diff --git a/pages/groups.vue b/pages/groups.vue index acc55a5..e21c0e7 100644 --- a/pages/groups.vue +++ b/pages/groups.vue @@ -92,7 +92,7 @@ export default { }), async fetch() { // const lastPosts = await fetch('http://localhost:3000/api/posts').then(res => res.json()) - this.cohorts = await this.$http.$get('http://localhost:3000/api/cohorts') + this.cohorts = await this.$http.$get('/api/cohorts') }, watch: { async search (value) { @@ -117,8 +117,7 @@ export default { this.sources = [] }, copy (ev, item) { - console.error('dentro copy') - const str = `` + const str = `` try { navigator.clipboard.writeText(str) } catch (e) { diff --git a/pages/index.vue b/pages/index.vue index f205be3..a557d8c 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -27,7 +27,7 @@ export default { // components: { AddCohort, Cohort, TextCohort, Post }, data: () => ({ lastPosts: [], cohorts: [] }), async fetch() { - this.lastPosts = await this.$http.$get('http://localhost:3000/api/posts') + this.lastPosts = await this.$http.$get(`${process.env.baseUrl}/api/posts`) // this.cohorts = await this.$http.$get('http://localhost:3000/api/cohorts') // const cohorts = [] }, diff --git a/server/chew.js b/server/chew.js index 24f0cda..dcb67e1 100644 --- a/server/chew.js +++ b/server/chew.js @@ -129,18 +129,17 @@ let queue export async function add (s) { queue.add(s, { jobId: s.id, repeat: { every: 10000 } }) + manager.get(s) } async function main () { queue = new Queue('foo6', { limiter: { max : 10, duration: 20000 } }) - console.error('dentro main') queue.clean(1000) await queue.obliterate({ force: true }); queue.process(job => manager.get(job.data)) const sources = await prisma.source.findMany() - console.error(sources) // sources.forEach(manager.get) // manager.get() // console.error(sources.map(s => s.URL))