Skip to content

Commit

Permalink
fix: adicionando modo standalone e logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Tacio Medeiros committed Sep 24, 2023
1 parent 508f00f commit fdd9b81
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 43 deletions.
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM node:18-alpine

ARG NODE_ENV=production
ENV NODE_ENV=${NODE_ENV}

WORKDIR /usr/src/app
COPY package*.json ./
COPY ./ ./

RUN npm install

RUN npm run build

EXPOSE 3000

CMD [ "npm", "run", "start" ]
1 change: 1 addition & 0 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
output: 'standalone',
reactStrictMode: true,
swcMinify: true,
trailingSlash: true,
Expand Down
17 changes: 11 additions & 6 deletions src/back-features/schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@ const SCHEDULE_COLLECTION = "schedule";
import db from '../utils/db';

const getSchedule = async () => {
const scheduleQuerySnapshot = await db.collection(SCHEDULE_COLLECTION).get();
const schedule: any[] = []; // eslint-disable-line
scheduleQuerySnapshot.forEach(
(doc) => schedule.push({ ...doc.data() })
);
return schedule;
try {

const scheduleQuerySnapshot = await db.collection(SCHEDULE_COLLECTION).get();
const schedule: any[] = []; // eslint-disable-line
scheduleQuerySnapshot.forEach(
(doc) => schedule.push({ ...doc.data() })
);
return schedule;
} catch (error) {
console.error(error);
}
}


Expand Down
28 changes: 15 additions & 13 deletions src/back-features/speakers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ interface SpeakerPayload {
}

const createSpeaker = async ({ key, id, companyTitle, mini_bio, name, photo, tech, title, topic, location }: SpeakerPayload) => {


const data = {
id, companyTitle, mini_bio, name, photo, tech, title, topic, location,
};
Expand Down Expand Up @@ -59,17 +57,21 @@ const createSpeaker = async ({ key, id, companyTitle, mini_bio, name, photo, tec
}

const getSpeaker = async () => {

const speakersQuerySnapshot = await db.collection(SPEAKERS_COLLECTION).get();
const speakers: { key: string }[] = [];
speakersQuerySnapshot.forEach(
(doc) => speakers.push({
...doc.data(),
key: doc.id,
})
);

return speakers;
try {

const speakersQuerySnapshot = await db.collection(SPEAKERS_COLLECTION).get();
const speakers: { key: string }[] = [];
speakersQuerySnapshot.forEach(
(doc) => speakers.push({
...doc.data(),
key: doc.id,
})
);

return speakers;
} catch (error) {
console.error(error)
}

}

Expand Down
16 changes: 10 additions & 6 deletions src/back-features/sponsors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ const SPONSORS_COLLECTION = "sponsors";
import db from '../utils/db';

const getSponsors = async () => {
const sponsorsQuerySnapshot = await db.collection(SPONSORS_COLLECTION).get();
const sponsors: any = {}; // eslint-disable-line
sponsorsQuerySnapshot.forEach(
(doc) => sponsors[doc.id.trim()] = { ...doc.data() }
);
return sponsors;
try {
const sponsorsQuerySnapshot = await db.collection(SPONSORS_COLLECTION).get();
const sponsors: any = {}; // eslint-disable-line
sponsorsQuerySnapshot.forEach(
(doc) => sponsors[doc.id.trim()] = { ...doc.data() }
);
return sponsors;
} catch (error) {
console.error(error);
}
}


Expand Down
15 changes: 9 additions & 6 deletions src/front-features/schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ import { server } from 'helpers/config';
import { Schedule } from 'models/schedule';

export const getSchedule = async (): Promise<Schedule[]> => {
const url = `${server}/api/v1/schedule`;

//console.log(url);
const res = await fetch(url);
const schedule = await res.json();
return schedule;
try {
const url = `${server}/api/v1/schedule`;
const res = await fetch(url);
const schedule = await res.json();
return schedule;
} catch (error) {
console.error(error);
return [];
}
}
15 changes: 9 additions & 6 deletions src/front-features/speakers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ import { server } from 'helpers/config';
import { Speaker } from 'models/speaker';

export const getSpeakers = async (): Promise<Speaker[]> => {
const url = `${server}/api/v1/speakers`;

//console.log(url);
const res = await fetch(url);
const speakers = await res.json();
return speakers;
try {
const url = `${server}/api/v1/speakers`;
const res = await fetch(url);
const speakers = await res.json();
return speakers;
} catch (error) {
console.log(error)
return [];
}
}
14 changes: 9 additions & 5 deletions src/front-features/sponsors.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { server } from 'helpers/config';
import { Sponsor } from 'models/sponsor';
import { SponsorLevel } from 'models/sponsor-level';

export const getSponsors = async (): Promise<{ [key: string]: SponsorLevel }> => {
const res = await fetch(`${server}/api/v1/sponsors`)
const sponsors = await res.json();
return sponsors;
export const getSponsors = async (): Promise<{ [key: string]: SponsorLevel } | null> => {
try {
const res = await fetch(`${server}/api/v1/sponsors`)
const sponsors = await res.json();
return sponsors;
} catch (error) {
console.error(error);
return null;
}
}
3 changes: 2 additions & 1 deletion src/utils/db/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ interface Database extends admin.firestore.Firestore {
}

let db: Database;

if (!admin.apps.length) {


if (!process.env.FIREBASE_SERVICE_ACCOUNT) {
throw new Error('FIREBASE_SERVICE_ACCOUNT is not defined');
}
Expand All @@ -26,5 +28,4 @@ else {
db = admin.firestore();
}


export default db;

0 comments on commit fdd9b81

Please sign in to comment.