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