diff --git a/README.md b/README.md index 3ae2f1f..8366388 100644 --- a/README.md +++ b/README.md @@ -18,3 +18,4 @@ Table: | 13.07.2023 | Theme and styling | 10 | | 14.07.2023 | Navbar | 10 | | 16.07.2023 | Login and register page | 20 | +| 16.07.2023 | Fix mock schema and move mock injections out of index.js | 1 | diff --git a/server/data/mock.js b/server/data/mock.js index a3db474..25ef5c9 100644 --- a/server/data/mock.js +++ b/server/data/mock.js @@ -205,7 +205,7 @@ export const mockPosts = [ firstName: "Aake", lastName: "Haahpala", location: "Helsinki, Finland", - description: "Just moved!", + content: "Just moved!", contentPicturePath: "post1.jpeg", profilePicturePath: "p1.jpeg", likes: new Map([ @@ -222,7 +222,7 @@ export const mockPosts = [ firstName: "Eevert", lastName: "Kotilainen", location: "Kainuu, Finland", - description: + content: "Summer is coming! I am so excited to go to the cottage and enjoy the nature.", contentPicturePath: "post2.jpeg", profilePicturePath: "p3.jpeg", @@ -245,7 +245,7 @@ export const mockPosts = [ firstName: "Taina", lastName: "Ruotsalainen", location: "Berlin, Germany", - description: + content: "International conference in Berlin! I am so excited to meet new people and learn new things.", contentPicturePath: "post3.jpeg", profilePicturePath: "p5.jpeg", @@ -268,7 +268,7 @@ export const mockPosts = [ firstName: "Elisa", lastName: "Järvelä", location: "Riihimäki, Finland", - description: + content: "Taking care of my garden. I am so excited to see the flowers bloom!", contentPicturePath: "post4.jpeg", profilePicturePath: "p7.jpeg", @@ -291,7 +291,7 @@ export const mockPosts = [ firstName: "Johanna", lastName: "Mäkinen", location: "Haparanda, Sweden", - description: + content: "A trip to neighboring Sweden! I am so excited to try some meatballs!", contentPicturePath: "post5.jpeg", profilePicturePath: "p9.jpeg", @@ -314,7 +314,7 @@ export const mockPosts = [ firstName: "Mikko", lastName: "Koivu", location: "Mikkeli, Finland", - description: + content: "Student excursion to Mikkeli! I am so excited to make new friends and drink some beer!", contentPicturePath: "post6.jpeg", profilePicturePath: "p11.jpeg", diff --git a/server/debug/injectMockData.js b/server/debug/injectMockData.js new file mode 100644 index 0000000..60c8a82 --- /dev/null +++ b/server/debug/injectMockData.js @@ -0,0 +1,11 @@ +import User from "../models/User.js"; +import Post from "../models/Post.js"; +import { mockUsers, mockPosts } from "../data/mock.js"; + +const injectMockData = async () => { + /* Inject mock data - DO NOT USE IN PRODUCTION */ + User.insertMany(mockUsers).then(() => console.log("Mock users injected")); + Post.insertMany(mockPosts).then(() => console.log("Mock posts injected")); +}; + +export default injectMockData; diff --git a/server/index.js b/server/index.js index f76eebe..43706b7 100644 --- a/server/index.js +++ b/server/index.js @@ -17,10 +17,8 @@ import { register } from "./controllers/auth.js"; import { createPost } from "./controllers/posts.js"; /* Middlewares */ import { verifyToken } from "./middlewares/auth.js"; -/* Models */ -import User from "./models/User.js"; -import Post from "./models/Post.js"; -import { mockUsers, mockPosts } from "./data/mock.js"; + +import injectMockData from "./debug/injectMockData.js"; /** * Config @@ -71,9 +69,5 @@ mongoose }) .then(() => { app.listen(PORT, () => console.log(`Server running on port: ${PORT}`)); - - /* Inject mock data - DO NOT USE IN PRODUCTION */ - // User.insertMany(mockUsers).then(() => console.log("Mock users injected")); - // Post.insertMany(mockPosts).then(() => console.log("Mock posts injected")); }) .catch((error) => console.log(error.message));