Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions nextstep-backend/src/models/comments_model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ const commentSchema: Schema = new mongoose.Schema({
commentSchema.set('toJSON', {
transform: (doc: Document, ret: Record<string, any>) => {
return {
id: ret._id,
postId: ret.postId,
content: ret.content,
owner: ret.owner,
createdAt: ret.createdAt,
updatedAt: ret.updatedAt,
id: ret._id.toString(),
postId: ret.postId.toString(),
content: ret.content as string,
owner: ret.owner.toString(),
createdAt: ret.createdAt ? ret.createdAt.toISOString() : undefined,
updatedAt: ret.updatedAt ? ret.updatedAt.toISOString() : undefined,
};
}
});
Expand Down
8 changes: 4 additions & 4 deletions nextstep-backend/src/models/company_model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ const companySchema: Schema = new mongoose.Schema({
companySchema.set('toJSON', {
transform: (doc: Document, ret: Record<string, any>) => {
return {
id: ret._id,
company: ret.company,
company_he: ret.company_he,
tags: ret.tags,
id: ret._id.toString(),
company: ret.company as string,
company_he: ret.company_he as string,
tags: ret.tags as string[],
quizzes: ret.quizzes,
}
}
Expand Down
7 changes: 3 additions & 4 deletions nextstep-backend/src/models/posts_model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@ const postSchema: Schema = new mongoose.Schema({
postSchema.set('toJSON', {
transform: (doc: Document, ret: Record<string, any>): PostData => {
return {
id: ret._id,
id: ret._id.toString(),
title: ret.title,
content: ret.content,
owner: ret.owner._id.toString(),
createdAt: ret.createdAt,
updatedAt: ret.updatedAt

createdAt: ret.createdAt ? ret.createdAt.toISOString() : undefined,
updatedAt: ret.updatedAt ? ret.updatedAt.toISOString() : undefined
};
}
});
Expand Down
16 changes: 8 additions & 8 deletions nextstep-backend/src/models/user_model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ const userSchema: Schema = new Schema({
}, { timestamps: true, strict: true, versionKey: false });

userSchema.set('toJSON', {
transform: (doc, ret): UserData => {
transform: (doc: mongoose.Document, ret: Record<string, any>): UserData => {
return {
id: ret._id,
username: ret.username,
email: ret.email,
password: ret.password,
imageFilename: ret?.imageFilename,
createdAt: ret.createdAt,
updatedAt: ret.updatedAt
id: ret._id.toString(),
username: ret.username as string,
email: ret.email as string,
password: ret.password as string,
imageFilename: ret?.imageFilename as string | undefined,
createdAt: ret.createdAt ? ret.createdAt.toISOString() : undefined,
updatedAt: ret.updatedAt ? ret.updatedAt.toISOString() : undefined
};
}
});
Expand Down
2 changes: 2 additions & 0 deletions nextstep-frontend/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

VITE_PORT=<VITE_PORT>
VITE_BACKEND_URL=<VITE_BACKEND_URL>
VITE_DOMAIN_NAME=<VITE_DOMAIN_NAME>
VITE_ALLOWED_HOSTS=<demo1.example.com;demo2.example.com;demo3.example.com>
VITE_REACT_APP_FIREBASE_API_KEY=<VITE_REACT_APP_FIREBASE_API_KEY>
VITE_REACT_APP_FIREBASE_AUTH_DOMAIN=<VITE_REACT_APP_FIREBASE_AUTH_DOMAIN>
VITE_REACT_APP_FIREBASE_PROJECT_ID=<VITE_REACT_APP_FIREBASE_PROJECT_ID>
Expand Down
17 changes: 13 additions & 4 deletions nextstep-frontend/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import dotenv from 'dotenv';
import dotenv from 'dotenv'

dotenv.config()

dotenv.config();
const allowedHosts = (process.env.VITE_ALLOWED_HOSTS || '')
.split(';')
.map(host => host.trim())
.filter(Boolean) // remove empty strings

// https://vite.dev/config/
export default defineConfig({
plugins: [react()],
server: {
port: parseInt(process.env.VITE_PORT || '5000')
port: parseInt(process.env.VITE_PORT || '5000'),
host: process.env.VITE_DOMAIN_NAME || 'localhost',
allowedHosts: allowedHosts.length > 0 ? allowedHosts : undefined
},
preview: { port: parseInt(process.env.VITE_PORT || '5000') }
preview: {
port: parseInt(process.env.VITE_PORT || '5000'),
host: process.env.VITE_DOMAIN_NAME || 'localhost'
}
})
Loading