{"id":81144,"date":"2024-10-23T03:34:59","date_gmt":"2024-10-23T00:04:59","guid":{"rendered":"https:\/\/nabfollower.com\/blog\/nodejs-docker-yt-updated-code-3peo\/"},"modified":"2024-10-23T03:34:59","modified_gmt":"2024-10-23T00:04:59","slug":"nodejs-docker-yt-updated-code-3peo","status":"publish","type":"post","link":"https:\/\/nabfollower.com\/blog\/nodejs-docker-yt-updated-code-3peo\/","title":{"rendered":"\u06a9\u062f \u0622\u0645\u0648\u0632\u0634\u06cc Nodejs-Docker YT \u0628\u0647 \u0631\u0648\u0632 \u0634\u062f"},"content":{"rendered":"<p>Summarize this content to 400 words in Persian Lang <\/p>\n<p>  \u06a9\u062f \u06a9\u0627\u0631\u0628\u0631\u062f \u062e\u0627\u0645<\/p>\n<p>index.js \u06a9\u062f \u0641\u0627\u06cc\u0644<\/p>\n<p>const express = require(&#8220;express&#8221;);<br \/>\nconst mongoose = require(&#8216;mongoose&#8217;);<\/p>\n<p>const {<br \/>\n  MONGO_USER,<br \/>\n  MONGO_PASSWORD,<br \/>\n  MONGO_IP,<br \/>\n  MONGO_PORT,<br \/>\n} = require(&#8220;.\/Config\/config&#8221;);<\/p>\n<p>const postRouter = require(&#8220;.\/routes\/postRoutes&#8221;);<\/p>\n<p>const app = express();<\/p>\n<p>\/\/ Add middleware to parse JSON bodies<br \/>\napp.use(express.json());<br \/>\napp.use(express.urlencoded({ extended: true }));<\/p>\n<p>\/\/ Construct MongoDB URL with error handling<br \/>\nconst mongoURL = `mongodb:\/\/${MONGO_USER || &#8216;root&#8217;}:${MONGO_PASSWORD || &#8216;example&#8217;}@${MONGO_IP || &#8216;localhost&#8217;}:${MONGO_PORT || 27017}\/?authSource=admin`;<\/p>\n<p>const connectWithRetry = () =&gt; {<br \/>\n  mongoose<br \/>\n    .connect(mongoURL)<br \/>\n    .then(() =&gt; console.log(&#8220;Successfully connected to Database&#8221;))<br \/>\n    .catch((e) =&gt; {<br \/>\n      console.log(&#8220;Error connecting to DB:&#8221;, e);<br \/>\n      setTimeout(connectWithRetry, 5000);  \/\/ Retry after 5 seconds<br \/>\n    });<br \/>\n};<\/p>\n<p>connectWithRetry();<\/p>\n<p>app.get(&#8220;\/&#8221;, (req, res) =&gt; {<br \/>\n  res.send(&#8220;&lt;h1&gt;Hello World&lt;\/h1&gt;&#8221;);<br \/>\n});<\/p>\n<p>app.use(&#8220;\/api\/v1\/posts&#8221;, postRouter);<\/p>\n<p>const port = process.env.PORT || 3000;<\/p>\n<p>app.listen(port, () =&gt; console.log(`Listening on port ${port}`));<\/p>\n<p>postController.js \u06a9\u062f \u0641\u0627\u06cc\u0644<\/p>\n<p>const Post = require(&#8220;..\/models\/postModel&#8221;);<\/p>\n<p>\/\/ Get all posts<br \/>\nexports.getAllPosts = async (req, res, next) =&gt; {<br \/>\n  try {<br \/>\n    const posts = await Post.find();<\/p>\n<p>    res.status(200).json({<br \/>\n      status: &#8220;success&#8221;,<br \/>\n      results: posts.length,<br \/>\n      data: {<br \/>\n        posts,<br \/>\n      },<br \/>\n    });<br \/>\n  } catch (error) {<br \/>\n    console.error(error);<br \/>\n    res.status(500).json({<br \/>\n      status: &#8220;fail&#8221;,<br \/>\n      message: &#8220;Server Error&#8221;,<br \/>\n    });<br \/>\n  }<br \/>\n};<\/p>\n<p>\/\/ Get a single post by ID<br \/>\nexports.getOnePost = async (req, res, next) =&gt; {<br \/>\n  try {<br \/>\n    const post = await Post.findById(req.params.id);<\/p>\n<p>    if (!post) {<br \/>\n      return res.status(404).json({<br \/>\n        status: &#8220;fail&#8221;,<br \/>\n        message: &#8220;Post not found&#8221;,<br \/>\n      });<br \/>\n    }<\/p>\n<p>    res.status(200).json({<br \/>\n      status: &#8220;success&#8221;,<br \/>\n      data: {<br \/>\n        post,<br \/>\n      },<br \/>\n    });<br \/>\n  } catch (error) {<br \/>\n    console.error(error);<br \/>\n    if (error.name === &#8216;CastError&#8217;) {<br \/>\n      return res.status(400).json({<br \/>\n        status: &#8220;fail&#8221;,<br \/>\n        message: &#8220;Invalid post ID format&#8221;,<br \/>\n      });<br \/>\n    }<br \/>\n    res.status(500).json({<br \/>\n      status: &#8220;fail&#8221;,<br \/>\n      message: &#8220;Server Error&#8221;,<br \/>\n    });<br \/>\n  }<br \/>\n};<\/p>\n<p>\/\/ Create a new post<br \/>\nexports.createPost = async (req, res, next) =&gt; {<br \/>\n  try {<br \/>\n    \/\/ Check if required fields are present<br \/>\n    if (!req.body.title || !req.body.body) {<br \/>\n      return res.status(400).json({<br \/>\n        status: &#8220;fail&#8221;,<br \/>\n        message: &#8220;Missing required fields: title and body are required&#8221;,<br \/>\n      });<br \/>\n    }<\/p>\n<p>    const post = await Post.create(req.body);<\/p>\n<p>    res.status(201).json({<br \/>\n      status: &#8220;success&#8221;,<br \/>\n      data: {<br \/>\n        post,<br \/>\n      },<br \/>\n    });<br \/>\n  } catch (error) {<br \/>\n    console.error(error);<br \/>\n    if (error.name === &#8216;ValidationError&#8217;) {<br \/>\n      return res.status(400).json({<br \/>\n        status: &#8220;fail&#8221;,<br \/>\n        message: &#8220;Validation Error&#8221;,<br \/>\n        errors: Object.values(error.errors).map(err =&gt; ({<br \/>\n          field: err.path,<br \/>\n          message: err.message<br \/>\n        }))<br \/>\n      });<br \/>\n    }<br \/>\n    res.status(500).json({<br \/>\n      status: &#8220;fail&#8221;,<br \/>\n      message: &#8220;Server Error&#8221;,<br \/>\n    });<br \/>\n  }<br \/>\n};<\/p>\n<p>\/\/ Update an existing post by ID<br \/>\nexports.updatePost = async (req, res, next) =&gt; {<br \/>\n  try {<br \/>\n    const updatedPost = await Post.findByIdAndUpdate(<br \/>\n      req.params.id,<br \/>\n      req.body,<br \/>\n      { new: true, runValidators: true }<br \/>\n    );<\/p>\n<p>    if (!updatedPost) {<br \/>\n      return res.status(404).json({<br \/>\n        status: &#8220;fail&#8221;,<br \/>\n        message: &#8220;Post not found&#8221;,<br \/>\n      });<br \/>\n    }<\/p>\n<p>    res.status(200).json({<br \/>\n      status: &#8220;success&#8221;,<br \/>\n      data: {<br \/>\n        post: updatedPost,<br \/>\n      },<br \/>\n    });<br \/>\n  } catch (error) {<br \/>\n    console.error(error);<br \/>\n    if (error.name === &#8216;ValidationError&#8217;) {<br \/>\n      return res.status(400).json({<br \/>\n        status: &#8220;fail&#8221;,<br \/>\n        message: &#8220;Validation Error&#8221;,<br \/>\n        errors: Object.values(error.errors).map(err =&gt; ({<br \/>\n          field: err.path,<br \/>\n          message: err.message<br \/>\n        }))<br \/>\n      });<br \/>\n    }<br \/>\n    if (error.name === &#8216;CastError&#8217;) {<br \/>\n      return res.status(400).json({<br \/>\n        status: &#8220;fail&#8221;,<br \/>\n        message: &#8220;Invalid post ID format&#8221;,<br \/>\n      });<br \/>\n    }<br \/>\n    res.status(500).json({<br \/>\n      status: &#8220;fail&#8221;,<br \/>\n      message: &#8220;Server Error&#8221;,<br \/>\n    });<br \/>\n  }<br \/>\n};<\/p>\n<p>\/\/ Delete a post by ID<br \/>\nexports.deletePost = async (req, res, next) =&gt; {<br \/>\n  try {<br \/>\n    const post = await Post.findByIdAndDelete(req.params.id);<\/p>\n<p>    if (!post) {<br \/>\n      return res.status(404).json({<br \/>\n        status: &#8220;fail&#8221;,<br \/>\n        message: &#8220;Post not found&#8221;,<br \/>\n      });<br \/>\n    }<\/p>\n<p>    res.status(204).json({<br \/>\n      status: &#8220;success&#8221;,<br \/>\n      data: null,<br \/>\n    });<br \/>\n  } catch (error) {<br \/>\n    console.error(error);<br \/>\n    if (error.name === &#8216;CastError&#8217;) {<br \/>\n      return res.status(400).json({<br \/>\n        status: &#8220;fail&#8221;,<br \/>\n        message: &#8220;Invalid post ID format&#8221;,<br \/>\n      });<br \/>\n    }<br \/>\n    res.status(500).json({<br \/>\n      status: &#8220;fail&#8221;,<br \/>\n      message: &#8220;Server Error&#8221;,<br \/>\n    });<br \/>\n  }<br \/>\n};<\/p>\n<p>postModel.js \u06a9\u062f \u0641\u0627\u06cc\u0644<\/p>\n<p>const mongoose = require(&#8220;mongoose&#8221;);<\/p>\n<p>const postSchema = new mongoose.Schema({<br \/>\n  title: {<br \/>\n    type: String,<br \/>\n    required: [true, &#8220;Post must have title&#8221;],  \/\/ Changed from &#8216;require&#8217; to &#8216;required&#8217;<br \/>\n  },<br \/>\n  body: {<br \/>\n    type: String,<br \/>\n    required: [true, &#8220;post must have body&#8221;],<br \/>\n  },<br \/>\n});<\/p>\n<p>const Post = mongoose.model(&#8220;Post&#8221;, postSchema);<br \/>\nmodule.exports = Post;<\/p>\n<p>postRoutes.js \u06a9\u062f \u0641\u0627\u06cc\u0644<\/p>\n<p>const express = require(&#8220;express&#8221;);<br \/>\nconst postController = require(&#8220;..\/controllers\/postController&#8221;);<\/p>\n<p>const router = express.Router();<\/p>\n<p>router<br \/>\n  .route(&#8220;\/&#8221;)<br \/>\n  .get(postController.getAllPosts)<br \/>\n  .post(postController.createPost);<\/p>\n<p>router<br \/>\n  .route(&#8220;\/:id&#8221;)<br \/>\n  .get(postController.getOnePost)<br \/>\n  .patch(postController.updatePost)<br \/>\n  .delete(postController.deletePost);<\/p>\n<p>module.exports = router;<\/p>\n<p>\u067e\u0633\u062a\u0686\u06cc \u0631\u0627 \u0646\u0635\u0628 \u06a9\u0646\u06cc\u062f \u0645\u06cc \u062a\u0648\u0627\u0646\u06cc\u062f \u0648\u06cc\u062f\u06cc\u0648\u06cc \u0632\u06cc\u0631 \u0631\u0627 \u0646\u06cc\u0632 \u062a\u0645\u0627\u0634\u0627 \u06a9\u0646\u06cc\u062f..<br \/>\nhttps:\/\/youtu.be\/Hmn5XeZv-GE?si=WCYtlVSuIclqzEkT<\/p>\n<p>\u062f\u0631 \u067e\u0633\u062a\u0686\u06cc:<br \/>\n\u062f\u0648\u0628\u0627\u0631\u0647 \u062f\u0631\u062e\u0648\u0627\u0633\u062a POST \u0631\u0627 \u0628\u0627 \u0627\u06cc\u0646 \u0642\u0627\u0644\u0628 \u062f\u0631 Postman \u0627\u0631\u0633\u0627\u0644 \u06a9\u0646\u06cc\u062f:<\/p>\n<p>\u0622\u062f\u0631\u0633 \u0627\u06cc\u0646\u062a\u0631\u0646\u062a\u06cc: http:\/\/localhost:3000\/api\/v1\/posts<br \/>\n\u0631\u0648\u0634: POST<br \/>\n\u0647\u062f\u0631\u0647\u0627: \u0646\u0648\u0639 \u0645\u062d\u062a\u0648\u0627: application\/json<br \/>\n\u0628\u062f\u0646:<\/p>\n<p>\u0628\u0631\u06af\u0647 &#8220;\u0628\u062f\u0646&#8221; \u0631\u0627 \u0627\u0646\u062a\u062e\u0627\u0628 \u06a9\u0646\u06cc\u062f<br \/>\n&#8220;raw&#8221; \u0631\u0627 \u0627\u0646\u062a\u062e\u0627\u0628 \u06a9\u0631\u062f\u0647 \u0648 \u0627\u0632 \u0645\u0646\u0648\u06cc \u0628\u0627\u0632\u0634\u0648 &#8220;JSON&#8221; \u0631\u0627 \u0627\u0646\u062a\u062e\u0627\u0628 \u06a9\u0646\u06cc\u062f<br \/>\n\u062f\u0627\u062f\u0647 \u0647\u0627 \u0631\u0627 \u062f\u0631 \u0627\u06cc\u0646 \u0641\u0631\u0645\u062a \u0648\u0627\u0631\u062f \u06a9\u0646\u06cc\u062f:<\/p>\n<p>{<br \/>\n    &#8220;title&#8221;: &#8220;Your Post Title&#8221;,<br \/>\n    &#8220;body&#8221;: &#8220;Your Post Content&#8221;<br \/>\n}<\/p>\n<p>\u0627\u06a9\u0646\u0648\u0646 \u0645\u06cc \u062a\u0648\u0627\u0646\u06cc\u062f \u0628\u0647 \u0631\u0627\u062d\u062a\u06cc \u0648 \u0628\u062f\u0648\u0646 \u0645\u0648\u0627\u062c\u0647\u0647 \u0628\u0627 \u0647\u06cc\u0686 \u062e\u0637\u0627\u06cc\u06cc \u0628\u0647 \u0622\u0645\u0648\u0632\u0634 \u0627\u062f\u0627\u0645\u0647 \u062f\u0647\u06cc\u062f.<\/p>\n<h2>\n<p>  \u06a9\u062f \u06a9\u0627\u0631\u0628\u0631\u062f \u062e\u0627\u0645<br \/>\n<\/h2>\n<p><strong>index.js<\/strong> \u06a9\u062f \u0641\u0627\u06cc\u0644\n<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>const express = require(\"express\");\nconst mongoose = require('mongoose');\n\nconst {\n  MONGO_USER,\n  MONGO_PASSWORD,\n  MONGO_IP,\n  MONGO_PORT,\n} = require(\".\/Config\/config\");\n\nconst postRouter = require(\".\/routes\/postRoutes\");\n\nconst app = express();\n\n\/\/ Add middleware to parse JSON bodies\napp.use(express.json());\napp.use(express.urlencoded({ extended: true }));\n\n\/\/ Construct MongoDB URL with error handling\nconst mongoURL = `mongodb:\/\/${MONGO_USER || 'root'}:${MONGO_PASSWORD || 'example'}@${MONGO_IP || 'localhost'}:${MONGO_PORT || 27017}\/?authSource=admin`;\n\nconst connectWithRetry = () =&gt; {\n  mongoose\n    .connect(mongoURL)\n    .then(() =&gt; console.log(\"Successfully connected to Database\"))\n    .catch((e) =&gt; {\n      console.log(\"Error connecting to DB:\", e);\n      setTimeout(connectWithRetry, 5000);  \/\/ Retry after 5 seconds\n    });\n};\n\nconnectWithRetry();\n\napp.get(\"\/\", (req, res) =&gt; {\n  res.send(\"&lt;h1&gt;Hello World&lt;\/h1&gt;\");\n});\n\napp.use(\"\/api\/v1\/posts\", postRouter);\n\nconst port = process.env.PORT || 3000;\n\napp.listen(port, () =&gt; console.log(`Listening on port ${port}`));\n<\/code><\/pre>\n<\/div>\n<p><strong>postController.js<\/strong> \u06a9\u062f \u0641\u0627\u06cc\u0644\n<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>const Post = require(\"..\/models\/postModel\");\n\n\/\/ Get all posts\nexports.getAllPosts = async (req, res, next) =&gt; {\n  try {\n    const posts = await Post.find();\n\n    res.status(200).json({\n      status: \"success\",\n      results: posts.length,\n      data: {\n        posts,\n      },\n    });\n  } catch (error) {\n    console.error(error);\n    res.status(500).json({\n      status: \"fail\",\n      message: \"Server Error\",\n    });\n  }\n};\n\n\/\/ Get a single post by ID\nexports.getOnePost = async (req, res, next) =&gt; {\n  try {\n    const post = await Post.findById(req.params.id);\n\n    if (!post) {\n      return res.status(404).json({\n        status: \"fail\",\n        message: \"Post not found\",\n      });\n    }\n\n    res.status(200).json({\n      status: \"success\",\n      data: {\n        post,\n      },\n    });\n  } catch (error) {\n    console.error(error);\n    if (error.name === 'CastError') {\n      return res.status(400).json({\n        status: \"fail\",\n        message: \"Invalid post ID format\",\n      });\n    }\n    res.status(500).json({\n      status: \"fail\",\n      message: \"Server Error\",\n    });\n  }\n};\n\n\/\/ Create a new post\nexports.createPost = async (req, res, next) =&gt; {\n  try {\n    \/\/ Check if required fields are present\n    if (!req.body.title || !req.body.body) {\n      return res.status(400).json({\n        status: \"fail\",\n        message: \"Missing required fields: title and body are required\",\n      });\n    }\n\n    const post = await Post.create(req.body);\n\n    res.status(201).json({\n      status: \"success\",\n      data: {\n        post,\n      },\n    });\n  } catch (error) {\n    console.error(error);\n    if (error.name === 'ValidationError') {\n      return res.status(400).json({\n        status: \"fail\",\n        message: \"Validation Error\",\n        errors: Object.values(error.errors).map(err =&gt; ({\n          field: err.path,\n          message: err.message\n        }))\n      });\n    }\n    res.status(500).json({\n      status: \"fail\",\n      message: \"Server Error\",\n    });\n  }\n};\n\n\/\/ Update an existing post by ID\nexports.updatePost = async (req, res, next) =&gt; {\n  try {\n    const updatedPost = await Post.findByIdAndUpdate(\n      req.params.id,\n      req.body,\n      { new: true, runValidators: true }\n    );\n\n    if (!updatedPost) {\n      return res.status(404).json({\n        status: \"fail\",\n        message: \"Post not found\",\n      });\n    }\n\n    res.status(200).json({\n      status: \"success\",\n      data: {\n        post: updatedPost,\n      },\n    });\n  } catch (error) {\n    console.error(error);\n    if (error.name === 'ValidationError') {\n      return res.status(400).json({\n        status: \"fail\",\n        message: \"Validation Error\",\n        errors: Object.values(error.errors).map(err =&gt; ({\n          field: err.path,\n          message: err.message\n        }))\n      });\n    }\n    if (error.name === 'CastError') {\n      return res.status(400).json({\n        status: \"fail\",\n        message: \"Invalid post ID format\",\n      });\n    }\n    res.status(500).json({\n      status: \"fail\",\n      message: \"Server Error\",\n    });\n  }\n};\n\n\/\/ Delete a post by ID\nexports.deletePost = async (req, res, next) =&gt; {\n  try {\n    const post = await Post.findByIdAndDelete(req.params.id);\n\n    if (!post) {\n      return res.status(404).json({\n        status: \"fail\",\n        message: \"Post not found\",\n      });\n    }\n\n    res.status(204).json({\n      status: \"success\",\n      data: null,\n    });\n  } catch (error) {\n    console.error(error);\n    if (error.name === 'CastError') {\n      return res.status(400).json({\n        status: \"fail\",\n        message: \"Invalid post ID format\",\n      });\n    }\n    res.status(500).json({\n      status: \"fail\",\n      message: \"Server Error\",\n    });\n  }\n};\n<\/code><\/pre>\n<\/div>\n<p><strong>postModel.js<\/strong> \u06a9\u062f \u0641\u0627\u06cc\u0644\n<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>const mongoose = require(\"mongoose\");\n\nconst postSchema = new mongoose.Schema({\n  title: {\n    type: String,\n    required: [true, \"Post must have title\"],  \/\/ Changed from 'require' to 'required'\n  },\n  body: {\n    type: String,\n    required: [true, \"post must have body\"],\n  },\n});\n\nconst Post = mongoose.model(\"Post\", postSchema);\nmodule.exports = Post;\n<\/code><\/pre>\n<\/div>\n<p><strong>postRoutes.js<\/strong> \u06a9\u062f \u0641\u0627\u06cc\u0644\n<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>const express = require(\"express\");\nconst postController = require(\"..\/controllers\/postController\");\n\nconst router = express.Router();\n\nrouter\n  .route(\"\/\")\n  .get(postController.getAllPosts)\n  .post(postController.createPost);\n\nrouter\n  .route(\"\/:id\")\n  .get(postController.getOnePost)\n  .patch(postController.updatePost)\n  .delete(postController.deletePost);\n\nmodule.exports = router;\n<\/code><\/pre>\n<\/div>\n<p>\u067e\u0633\u062a\u0686\u06cc \u0631\u0627 \u0646\u0635\u0628 \u06a9\u0646\u06cc\u062f \u0645\u06cc \u062a\u0648\u0627\u0646\u06cc\u062f \u0648\u06cc\u062f\u06cc\u0648\u06cc \u0632\u06cc\u0631 \u0631\u0627 \u0646\u06cc\u0632 \u062a\u0645\u0627\u0634\u0627 \u06a9\u0646\u06cc\u062f..<br \/>\nhttps:\/\/youtu.be\/Hmn5XeZv-GE?si=WCYtlVSuIclqzEkT<\/p>\n<p>\u062f\u0631 \u067e\u0633\u062a\u0686\u06cc:<br \/>\n\u062f\u0648\u0628\u0627\u0631\u0647 \u062f\u0631\u062e\u0648\u0627\u0633\u062a POST \u0631\u0627 \u0628\u0627 \u0627\u06cc\u0646 \u0642\u0627\u0644\u0628 \u062f\u0631 Postman \u0627\u0631\u0633\u0627\u0644 \u06a9\u0646\u06cc\u062f:<\/p>\n<p>\u0622\u062f\u0631\u0633 \u0627\u06cc\u0646\u062a\u0631\u0646\u062a\u06cc: http:\/\/localhost:3000\/api\/v1\/posts<br \/>\n\u0631\u0648\u0634: POST<br \/>\n\u0647\u062f\u0631\u0647\u0627: \u0646\u0648\u0639 \u0645\u062d\u062a\u0648\u0627: application\/json<br \/>\n\u0628\u062f\u0646:<\/p>\n<ul>\n<li>\u0628\u0631\u06af\u0647 &#8220;\u0628\u062f\u0646&#8221; \u0631\u0627 \u0627\u0646\u062a\u062e\u0627\u0628 \u06a9\u0646\u06cc\u062f<\/li>\n<li>&#8220;raw&#8221; \u0631\u0627 \u0627\u0646\u062a\u062e\u0627\u0628 \u06a9\u0631\u062f\u0647 \u0648 \u0627\u0632 \u0645\u0646\u0648\u06cc \u0628\u0627\u0632\u0634\u0648 &#8220;JSON&#8221; \u0631\u0627 \u0627\u0646\u062a\u062e\u0627\u0628 \u06a9\u0646\u06cc\u062f<\/li>\n<li>\u062f\u0627\u062f\u0647 \u0647\u0627 \u0631\u0627 \u062f\u0631 \u0627\u06cc\u0646 \u0641\u0631\u0645\u062a \u0648\u0627\u0631\u062f \u06a9\u0646\u06cc\u062f:\n<\/li>\n<\/ul>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>{\n    \"title\": \"Your Post Title\",\n    \"body\": \"Your Post Content\"\n}\n<\/code><\/pre>\n<\/div>\n<p>\u0627\u06a9\u0646\u0648\u0646 \u0645\u06cc \u062a\u0648\u0627\u0646\u06cc\u062f \u0628\u0647 \u0631\u0627\u062d\u062a\u06cc \u0648 \u0628\u062f\u0648\u0646 \u0645\u0648\u0627\u062c\u0647\u0647 \u0628\u0627 \u0647\u06cc\u0686 \u062e\u0637\u0627\u06cc\u06cc \u0628\u0647 \u0622\u0645\u0648\u0632\u0634 \u0627\u062f\u0627\u0645\u0647 \u062f\u0647\u06cc\u062f.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summarize this content to 400 words in Persian Lang \u06a9\u062f \u06a9\u0627\u0631\u0628\u0631\u062f \u062e\u0627\u0645 index.js \u06a9\u062f \u0641\u0627\u06cc\u0644 const express = require(&#8220;express&#8221;); const mongoose = require(&#8216;mongoose&#8217;); const { MONGO_USER, MONGO_PASSWORD, MONGO_IP, MONGO_PORT, } = require(&#8220;.\/Config\/config&#8221;); const postRouter = require(&#8220;.\/routes\/postRoutes&#8221;); const app = express(); \/\/ Add middleware to parse JSON bodies app.use(express.json()); app.use(express.urlencoded({ extended: true })); \/\/ Construct MongoDB &hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"","fifu_image_alt":"","footnotes":""},"categories":[339],"tags":[],"class_list":["post-81144","post","type-post","status-publish","format-standard","hentry","category-dev"],"_links":{"self":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts\/81144","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/comments?post=81144"}],"version-history":[{"count":0,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts\/81144\/revisions"}],"wp:attachment":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/media?parent=81144"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/categories?post=81144"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/tags?post=81144"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}