Fix mock schema and move mock injections out of index.js

This commit is contained in:
Andrew Trieu
2023-07-16 22:02:11 +03:00
parent 350517623a
commit bab2bfad0b
4 changed files with 20 additions and 14 deletions

View File

@@ -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 |

View File

@@ -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",

View File

@@ -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;

View File

@@ -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));