{"id":214,"date":"2016-06-09T07:33:26","date_gmt":"2016-06-09T04:33:26","guid":{"rendered":"http:\/\/ahmadmagdy.me\/blog\/?p=214"},"modified":"2016-06-28T17:06:47","modified_gmt":"2016-06-28T14:06:47","slug":"%d9%83%d9%8a%d9%81%d9%8a%d8%a9-%d8%a8%d9%86%d8%a7%d8%a1-restful-api-%d8%a8%d8%a7%d8%b3%d8%aa%d8%ae%d8%af%d8%a7%d9%85-node-js-%d9%88-express-js-%d8%a7%d9%84%d8%ac%d8%b2%d8%a1-%d8%a7%d9%84%d8%ab%d8%a7","status":"publish","type":"post","link":"https:\/\/magdy.dk\/arblog\/?p=214","title":{"rendered":"\u0643\u064a\u0641\u064a\u0629 \u0628\u0646\u0627\u0621 RESTful API \u0628\u0627\u0633\u062a\u062e\u062f\u0627\u0645 Node.js \u0648 Express.js \u0627\u0644\u062c\u0632\u0621 \u0627\u0644\u062b\u0627\u0646\u064a"},"content":{"rendered":"<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u0641\u064a \u0627\u0644\u0645\u0631\u0629 \u0627\u0644\u0633\u0627\u0628\u0642\u0629 \u062a\u062d\u062f\u062b\u0646\u0627 \u0639\u0646 \u0643\u064a\u0641\u064a\u0629 \u0627\u0639\u062f\u0627\u062f \u0628\u064a\u0626\u0629 \u0627\u0644\u0639\u0645\u0644 \u0648\u062a\u0637\u0631\u0642\u0646\u0627 \u0627\u0644\u0649 \u062c\u0632\u0621 \u0628\u0633\u064a\u0637 \u0645\u0646 \u0627\u0639\u062f\u0627\u062f \u0627\u0644\u0640 API \u0627\u0644\u062e\u0627\u0635\u0629 \u0628\u0646\u0627.<\/span><\/p>\n<header class=\"post-header\">\n<blockquote>\n<p style=\"text-align: center;\"><a href=\"http:\/\/ahmadmagdy.me\/blog\/?p=191\"><span style=\"font-size: 14pt;\">\u0643\u064a\u0641\u064a\u0629 \u0628\u0646\u0627\u0621 RESTful API \u0628\u0627\u0633\u062a\u062e\u062f\u0627\u0645 Node.js \u0648 Express.js \u0627\u0644\u062c\u0632\u0621 \u0627\u0644\u0623\u0648\u0644<\/span><\/a><\/p>\n<\/blockquote>\n<\/header>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u0641\u064a \u0647\u0630\u0647 \u0627\u0644\u0645\u0631\u0629 \u0628\u0627\u0630\u0646 \u0627\u0644\u0644\u0647 \u0633\u0646\u0643\u0645\u0644 \u0645\u0627\u0628\u062f\u0623\u0646\u0627\u0647.<\/span><\/p>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u0623\u0648\u0644\u0627\u064b \u0644\u062a\u0646\u0638\u064a\u0645 \u0627\u0644\u0639\u0645\u0644 \u0646\u0646\u0634\u0626 \u0645\u0644\u0641 \u062c\u062f\u064a\u062f \u064a\u062d\u062a\u0648\u064a \u0639\u0644\u0649 \u0627\u0644\u0627\u0639\u062f\u0627\u062f\u0627\u062a \u0627\u0644\u0631\u0626\u064a\u0633\u064a\u0629 \u0648\u0646\u0633\u0645\u064a\u0647 &#8220;config.js&#8221;<\/span><\/p>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u0633\u064a\u062d\u062a\u0648\u064a \u0639\u0644\u0649 \u0631\u0627\u0628\u0637 \u0642\u0627\u0639\u062f\u0629 \u0627\u0644\u0628\u064a\u0627\u0646\u0627\u062a \u0648 \u0631\u0642\u0645 \u0627\u0644\u0640 &#8220;Port&#8221;<\/span><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nmodule.exports = {\r\n 'database':'your mongodbLink',\r\n 'port': process.env.PORT || 3000,\r\n};\r\n\r\n<\/pre>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u0633\u0646\u062d\u062a\u0627\u062c \u0627\u0644\u0627\u0646 \u0627\u0644\u0649 \u0627\u0644\u0627\u062a\u0635\u0627\u0644 \u0628\u0642\u0627\u0639\u062f\u0629 \u0627\u0644\u0628\u064a\u0627\u0646\u0627\u062a MongoDB \u064a\u0645\u0643\u0646\u0643 \u062a\u0646\u0635\u064a\u0628\u0647\u0627 \u0639\u0644\u0649 \u062c\u0647\u0627\u0632\u0643 \u0645\u0646 <a href=\"https:\/\/www.mongodb.com\/download-center#community\">\u0627\u0644\u0645\u0648\u0642\u0639 \u0627\u0644\u0631\u0633\u0645\u064a<\/a>\u00a0\u0623\u0648 \u0639\u0644\u0649 <a href=\"https:\/\/mlab.com\/\">mLab <\/a>\u0648\u0647\u064a \u062e\u062f\u0645\u0629 \u062a\u0645\u0643\u0646\u0643 \u0645\u0646 \u0627\u0646\u0634\u0627\u0621 \u0648\u0627\u0633\u062a\u062e\u062f\u0627\u0645 \u0642\u0627\u0639\u062f\u0629 \u0628\u064a\u0627\u0646\u0627\u062a \u0628\u0645\u0633\u0627\u062d\u0629 500 \u0645\u064a\u062c\u0627 \u0645\u062c\u0627\u0646\u0627\u064b<\/span><\/p>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u0628\u0639\u062f \u062a\u0646\u0635\u064a\u0628\u0647\u0627 \u0627\u0648 \u0627\u0633\u062a\u062e\u062f\u0627\u0645\u0643 \u0644\u0640 mLab \u0633\u062a\u062d\u0635\u0644 \u0639\u0644\u0649 \u0631\u0627\u0628\u0637 \u0644\u0642\u0627\u0639\u062f\u0629 \u0627\u0644\u0628\u064a\u0627\u0646\u0627\u062a \u0642\u0645 \u0628\u0627\u0636\u0627\u0641\u062a\u0647 \u0641\u064a \u0645\u0644\u0641 \u0627\u0644 config \u0648\u0646\u0633\u062a\u062f\u0639\u064a \u0627\u0644\u0645\u0644\u0641 \u0641\u064a index.js<\/span><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">var config = require('.\/config');<\/pre>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u0648\u0646\u062a\u0635\u0644 \u0628\u0642\u0627\u0639\u062f\u0629 \u0627\u0644\u0628\u064a\u0627\u0646\u0627\u062a \u0628\u0647\u0630\u0627 \u0627\u0644\u0623\u0645\u0631\u00a0<\/span><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">mongoose.connect(config.database,function(err){\r\n if(err){\r\n console.log(err);\r\n return;\r\n }\r\n console.log('Connected to database');\r\n});\r\n<\/pre>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u0648\u0646\u0639\u062f\u0644 \u0627\u064a\u0636\u0627\u00a0<\/span><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">var PORT = config.port;<\/pre>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u0648\u0646\u062c\u0631\u0628 \u0627\u0644\u0627\u062a\u0635\u0627\u0644<\/span><\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" id=\"__wp-temp-img-id\" title=\"\" src=\"http:\/\/s01.arab.sh\/i\/00078\/qvdy42521uh4.png\" alt=\"\" width=\"706\" height=\"408\" \/><\/p>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u0646\u0631\u064a\u062f \u0627\u0644\u0627\u0646 \u0627\u0646 \u0646\u0635\u064a\u063a \u0634\u0643\u0644\u00a0\u0627\u0644\u0628\u064a\u0627\u0646\u0627\u062a \u0627\u0644\u062a\u064a\u00a0\u0646\u0631\u064a\u062f \u062a\u062e\u0632\u064a\u0646\u0647\u0627\u00a0<\/span><\/p>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u0646\u0646\u0634\u0626 \u0645\u0644\u0641 \u062c\u062f\u064a\u062f \u0648\u0646\u0633\u0645\u064a\u0647 company.js<\/span><\/p>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u0648\u0633\u062a\u0643\u0648\u0646 \u0645\u062d\u062a\u0648\u064a\u0627\u062a\u0647\u00a0<\/span><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">var mongoose = require('mongoose');\r\n\/\/\u0627\u0644 model \u064a\u0646\u0634\u0649 \u0645\u0646 \u062e\u0644\u0627\u0644 \u062a\u0639\u0631\u064a\u0641 \u0627\u0644 schema \u0627\u0648\u0644\u0627\u064b\r\nvar Schema = mongoose.Schema;\r\n\r\n\/\/\u0627\u0646\u0634\u0627\u0621 \u0627\u0644schema \u0627\u0648 \u0627\u0644\u0634\u0643\u0644 \u0627\u0644\u062e\u0627\u0635 \u0628\u0628\u064a\u0627\u0646\u0627\u062a \u0627\u0644\u0634\u0631\u0643\u0629\r\nvar companySchema = new Schema({\r\n name: {\r\n type: String,\r\n unique: true,\r\n required: true\r\n },\r\n description: String,\r\n Phone: {\r\n type: Number,\r\n unique: true\r\n required: true\r\n }\r\n});\r\n\/\/\u062a\u0635\u062f\u064a\u0631 \u0627\u0644\u0628\u064a\u0627\u0646\u0627\u062a \u0644\u0627\u0633\u062a\u0639\u0645\u0627\u0644\u0647\u0627\r\nmodule.exports = mongoose.model('Company',companySchema);\r\n<\/pre>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u0645\u0627\u0642\u0645\u0646\u0627 \u0628\u0639\u0645\u0644\u0647 \u0647\u0648 \u0627\u0633\u062a\u062f\u0639\u0627\u0621 Mongoose \u0648 \u0627\u0633\u062a\u062f\u0639\u0627\u0621 Schema \u0645\u0646\u0647\u0627 \u0644\u0643\u064a \u0646\u0634\u0643\u0644 \u0627\u0644\u0628\u064a\u0627\u0646\u0627\u062a \u0648\u0627\u0646\u0634\u0627\u0621 \u0634\u0643\u0644 \u0627\u0644\u0628\u064a\u0627\u0646\u0627\u062a \u0627\u0644\u0630\u064a \u0646\u0631\u064a\u062f\u0647<\/span><\/p>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u0648\u0627\u0644\u0630\u064a \u064a\u062d\u062a\u0648\u064a \u0639\u0644\u0649 \u0627\u0633\u0645 \u0627\u0644\u0634\u0631\u0643\u0629 \u0645\u0646 \u0627\u0644\u0646\u0648\u0639 String \u0648\u0645\u0637\u0644\u0648\u0628\u064c \u0625\u062f\u062e\u0627\u0644\u0647 \u0648\u0644\u0627\u0628\u062f \u0627\u0646 \u064a\u0643\u0648\u0646 \u0641\u0631\u064a\u062f\u0627\u064b<\/span><\/p>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u0648\u0628\u064a\u0627\u0646\u0627\u062a \u0627\u0644\u0634\u0631\u0643\u0629 \u0645\u0646 \u0627\u0644\u0646\u0648\u0639 String \u0627\u062e\u062a\u064a\u0627\u0631\u064a\u0647<\/span><\/p>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u0648\u0631\u0642\u0645 \u0627\u0644\u0647\u0627\u062a\u0641 \u0644\u0644\u0634\u0631\u0643\u0629 \u0645\u0646 \u0627\u0644\u0646\u0648\u0639 Number\u00a0\u0648\u0645\u0637\u0644\u0648\u0628\u064c \u0625\u062f\u062e\u0627\u0644\u0647 \u0648\u0644\u0627\u0628\u062f \u0627\u0646 \u064a\u0643\u0648\u0646 \u0641\u0631\u064a\u062f\u0627\u064b.<\/span><\/p>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u0646\u062d\u0646 \u0627\u0644\u0627\u0646 \u0627\u0639\u062f\u062f\u0646\u0627 \u062a\u0642\u0631\u064a\u0628\u0627 \u0643\u0644 \u0645\u0627\u0646\u0631\u064a\u062f\u0647 \u0644\u0639\u0645\u0644 \u0627\u0644\u0640 API.<\/span><\/p>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u0646\u0630\u0647\u0628 \u0644\u0644\u0645\u0644\u0641 \u0627\u0644\u0631\u0626\u064a\u0633\u064a index.js\u00a0<\/span><\/p>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u0648\u0646\u0633\u062a\u062e\u062f\u0645 \u0627\u0644API\u00a0<\/span><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n\/\/\u0646\u0633\u062a\u062e\u062f\u0645 \u0627\u0644 API \r\nvar api = require('.\/api')(express);\r\napp.use('\/api',api);\r\n<\/pre>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u0633\u064a\u0643\u0648\u0646 \u0627\u0644\u0631\u0627\u0628\u0637 \u0627\u0644\u0630\u064a \u0633\u0646\u0633\u062a\u062e\u062f\u0645\u0647 \u0628\u0647\u0630\u0627 \u0627\u0644\u0634\u0643\u0644\u00a0<\/span><\/p>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\"><strong>localhost:3000\/api\/xxxxx<\/strong><\/span><\/p>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u0646\u0646\u0634\u0626 \u0645\u0644\u0641 \u062c\u062f\u064a\u062f \u0648\u0646\u0633\u0645\u064a\u0647 api.js<\/span><\/p>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u0648\u0646\u0628\u062f\u0623 \u0628\u0627\u0644\u0645\u062d\u062a\u0648\u0649\u00a0<\/span><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">var Company = require('.\/company');\r\n\r\n\/\/\u0644\u062a\u0635\u062f\u064a\u0631 \u0627\u0644\u062f\u0627\u0644\u0629 \u0627\u0644\u062a\u064a \u0633\u062a\u062d\u062a\u0648\u064a \u0639\u0644\u0649 \u0645\u062d\u062a\u0648\u064a\u0627\u062a \u0627\u0644 API \u0643\u064a \u0646\u0633\u062a\u064a\u0637\u0639 \u0627\u0633\u062a\u062e\u062f\u0627\u0645\u0647\u0627 \u0641\u064a\u0645\u0627 \u0628\u0639\u062f\r\nmodule.exports = function(express){\r\n \/*\u0627\u0646\u0634\u0627\u0621 \u0627\u0644 router \u0627\u0644\u062e\u0627\u0635 \u0628\u0646\u0627 \r\n \u0627\u0644\u0630\u064a \u0633\u064a\u062d\u062a\u0648\u064a \u0639\u0644\u0649 \u0627\u0644\u0645\u0633\u0627\u0631\u0627\u062a \u0627\u0644\u062e\u0627\u0635\u0629 \u0628\u0627\u0644api *\/\r\n var api = express.Router();\r\n return api;\r\n};<\/pre>\n<blockquote><p><span style=\"font-size: 14pt;\">\u0645\u0644\u0627\u062d\u0638\u0629 \u0628\u0633\u064a\u0637\u0629:<\/span><\/p>\n<p><span style=\"font-size: 14pt;\">\u0639\u0646\u062f \u062a\u0639\u0627\u0645\u0644\u0646\u0627 \u0645\u0639 \u0627\u0644\u0640 API \u0644\u0646 \u0646\u062a\u0639\u0627\u0645\u0644 \u0645\u0639 \u0627\u0644\u0645\u062a\u0635\u0641\u062d \u0645\u0628\u0627\u0634\u0631\u0629 \u00a0\u0628\u0644 \u0633\u0646\u062a\u0639\u0627\u0645\u0644 \u0645\u0639 \u0627\u0636\u0627\u0641\u0629 <a href=\"https:\/\/chrome.google.com\/webstore\/detail\/postman\/fhbjgbiflinjbdggehcddcbncdddomop\">Postman <\/a>\u0648\u0647\u064a \u062a\u0645\u0643\u0646\u0627 \u0645\u0646 \u0627\u0631\u0633\u0627\u0644 \u0627\u0644 Requests \u0628\u0627\u0644\u0637\u0631\u0642\u00a0\u0627\u0644\u0645\u062e\u062a\u0644\u0641\u0629 POST ,GET , etc &#8230;. \u0648\u0645\u0634\u0627\u0647\u062f\u0629 \u0627\u0644Response.<\/span><\/p><\/blockquote>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u0633\u0646\u062a\u0639\u0627\u0645\u0644 \u0627\u0644\u0627\u0646 \u0645\u0639 \u0627\u0648\u0644 \u0645\u0633\u0627\u0631 \u0644\u0646\u0627 \u0648\u0647\u0648 \/api\/company<\/span><\/p>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u0648\u0633\u064a\u0643\u0648\u0646 \u0644\u0647 \u0646\u0648\u0639\u064a\u0646 \u0627\u0645\u0627 GET \u0627\u0648 POST<\/span><\/p>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u0627\u0630\u0627 \u0643\u0627\u0646 \u0646\u0648\u0639 \u0627\u0644\u0627\u0633\u062a\u062f\u0639\u0627\u0621 GET \u0641\u0633\u0646\u0639\u064a\u062f \u0643\u0644 \u0627\u0644\u0634\u0631\u0643\u0627\u062a \u0627\u0644\u0645\u062e\u0632\u0646\u0629 \u0641\u064a \u0635\u064a\u063a\u0629 JSON.<\/span><\/p>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u0648\u0644\u0648 \u0643\u0627\u0646 POST \u0641\u0647\u0630\u0627 \u064a\u0639\u0646\u064a \u0627\u0646\u0647 \u0633\u064a\u0636\u064a\u0641 \u0634\u0631\u0643\u0629 \u062c\u062f\u064a\u062f\u0629 \u0648\u0633\u0646\u0633\u062a\u0642\u0628\u0644 \u0627\u0644\u0628\u064a\u0627\u0646\u0627\u062a \u0648\u0646\u062e\u0632\u0646\u0647\u0627.<\/span><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n\r\napi.route('\/company')\r\n .get(function(req,res){\r\n Company.find({},function(err,data){\r\n if(err){\r\n res.sendStatus(400);\r\n return;\r\n }\r\n res.json(data);\r\n });\r\n }).post(function(req,res){\r\n var company = new Company({\r\n name: req.body.name,\r\n description : req.body.description,\r\n Phone: req.body.Phone\r\n });\r\n company.save(function(err){\r\n if(err){\r\n res.sendStatus(406);\r\n return;\r\n }\r\n res.status(200).json({message: 'company has been created'});\r\n });\r\n });\r\n<\/pre>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u0648\u0644\u0646\u062c\u0631\u0628 \u0633\u0648\u064a\u0627\u064b \u0639\u0646 \u0637\u0631\u064a\u0642 Postmen<\/span><\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" id=\"__wp-temp-img-id\" class=\"alignnone\" src=\"http:\/\/s02.arab.sh\/i\/00078\/bnrzixtp9ja1.png\" width=\"1352\" height=\"721\" \/><\/p>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u0646\u062e\u062a\u0627\u0631 \u0646\u0648\u0639 POST \u0644\u0646\u062c\u0631\u0628 \u0627\u0631\u0633\u0627\u0644 \u0628\u064a\u0627\u0646\u0627\u062a<\/span><\/p>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u0648\u0646\u062e\u062a\u0627\u0631 Body \u0648 formurlencoded<\/span><\/p>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u0648\u0646\u0639\u0628\u0626 \u0627\u0644\u062d\u0642\u0648\u0644 \u0628\u0627\u0644\u0627\u0633\u0645\u0627\u0621 \u0627\u0644\u062e\u0627\u0635\u0629 \u0628\u0628\u064a\u0627\u0646\u0627\u062a \u0627\u0644\u0634\u0631\u0643\u0629 \u0648\u0646\u0631\u0633\u0644\u0647\u0627 Send<\/span><\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" id=\"__wp-temp-img-id\" title=\"\" src=\"http:\/\/s01.arab.sh\/i\/00078\/8pbwq7zzikfz.png\" alt=\"\" \/><\/p>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u0645\u0645\u062a\u0627\u0632 \ud83d\ude00 \u0646\u0631\u0649 \u0647\u0646\u0627 \u0631\u0633\u0627\u0644\u0629 \u0627\u0646\u0647 \u062a\u0645 \u0627\u0646\u0634\u0627\u0621 \u0628\u064a\u0627\u0646\u0627\u062a \u0627\u0644\u0634\u0631\u0643\u0629 \u0628\u0646\u062c\u0627\u062d.<\/span><\/p>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u064a\u0645\u0643\u0646\u0646\u0627 \u0627\u0644\u062a\u062d\u0642\u0642 \u0645\u0646 \u062c\u0645\u064a\u0639 \u0627\u0644\u0628\u064a\u0627\u0646\u0627\u062a \u0627\u0644\u0645\u062e\u0632\u0646\u0629 \u0639\u0646 \u0637\u0631\u064a\u0642 \u0627\u0633\u062a\u062e\u062f\u0627\u0645 GET<\/span><\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" id=\"__wp-temp-img-id\" title=\"\" src=\"http:\/\/s02.arab.sh\/i\/00078\/1kywirmgafme.png\" alt=\"\" \/><\/p>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u0648\u0633\u064a\u0643\u0648\u0646 \u0627\u0644\u0631\u062f \u0628\u062c\u0645\u064a\u0639 \u0627\u0644\u0628\u064a\u0627\u0646\u0627\u062a \u0627\u0644\u0645\u062e\u0632\u0646\u0629 \u0643\u0627\u0644\u062a\u0627\u0644\u064a:<\/span><\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" id=\"__wp-temp-img-id\" title=\"\" src=\"http:\/\/s02.arab.sh\/i\/00078\/4yxv3lu9xytx.png\" alt=\"\" \/><\/p>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u0648\u0643\u0645\u0627 \u062a\u0644\u0627\u062d\u0638 \u0641\u0627\u0646 Morgn \u064a\u0642\u0648\u0645 \u0628\u062a\u062a\u0628\u0639 \u0643\u0644 \u0627\u0644requests \u0648 \u0627\u0644 responses:<\/span><\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" id=\"__wp-temp-img-id\" title=\"\" src=\"http:\/\/s01.arab.sh\/i\/00078\/1enftzwilsm0.png\" alt=\"\" \/><\/p>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u0648\u0644\u0643\u064a \u0646\u0642\u0648\u0645 \u0628\u062d\u0630\u0641 \u0634\u0631\u0643\u0629 \u0645\u0639\u064a\u0646\u0629 \u0627\u0648 \u062a\u062d\u062f\u064a\u062b \u0628\u064a\u0627\u0646\u0627\u062a\u0647\u0627 \u0646\u0642\u0648\u0645 \u0628\u0643\u062a\u0627\u0628\u0629 \u0627\u0644\u0643\u0648\u062f \u0627\u0644\u062a\u0627\u0644\u064a:<\/span><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\napi.route('\/company\/:name')\r\n .delete(function(req,res){\r\n Company.findOneAndRemove({name: req.params.name},function(err){\r\n if(err){\r\n res.status(404).json({message: &quot;user not found&quot;});\r\n return;\r\n }\r\n res.status(200).json({message:&quot;Comapny removed&quot;});\r\n });\r\n }).put(function(req,res){\r\n Company.findOneAndUpdate({name: req.params.name},\r\n {$set:{name: req.body.name,description:req.body.description,Phone: req.body.Phone}},\r\n function(err){\r\n if(err){\r\n res.status(400).json({message:err});\r\n return;\r\n }\r\n res.status(200).json({message: &quot;Updated&quot;});\r\n });\r\n });\r\n<\/pre>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u0633\u0646\u0642\u0648\u0645 \u0628\u0627\u0636\u0627\u0641\u0629 \u0627\u0633\u0645 \u0627\u0644\u0634\u0631\u0643\u0629 \u0641\u064a \u0627\u0644\u0631\u0627\u0628\u0637 \u0648\u0646\u0628\u062d\u062b \u0639\u0646\u0647 \u0648\u0646\u0642\u0648\u0645 \u0628\u062d\u0630\u0641\u0647 \u064a\u0645\u0643\u0646\u0643 \u062c\u0639\u0644\u0647\u0627 \u0628\u0627\u0644 ID \u0627\u0648 \u0628\u0631\u0642\u0645 \u0627\u0644\u0647\u0627\u062a\u0641.<\/span><\/p>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u0639\u0646\u062f \u0638\u0647\u0648\u0631 \u0627\u064a \u0627\u062e\u0637\u0627\u0621 \u0633\u064a\u0637\u0628\u0639 \u0644\u0647 \u0631\u0633\u0627\u0644\u0629 user not found \u0645\u0639 \u062d\u0627\u0644\u0629 404<\/span><\/p>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u0627\u0646\u0645\u0627 \u0641\u064a \u062d\u0627\u0644 \u062d\u0630\u0641 \u0627\u0644\u0645\u0633\u062a\u062e\u062f\u0645 \u0633\u0646\u062e\u0628\u0631\u0647 \u0628\u0627\u0646\u0647 \u062a\u0645 \u0627\u0644\u0645\u0633\u062d \u0645\u0639 \u062d\u0627\u0644\u0629 200 OK . <\/span><\/p>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u0648\u0641\u064a \u062d\u0627\u0644\u0629 \u0627\u0644\u062a\u062d\u062f\u064a\u062b &#8220;PUT&#8221; \u0633\u064a\u0642\u0648\u0645 \u0628\u062c\u0644\u0628 \u0628\u064a\u0627\u0646\u0627\u062a \u0627\u0644\u0645\u0633\u062a\u062e\u062f\u0645 \u0648\u062a\u0639\u062f\u064a\u0644\u0647\u0627 \u062d\u0633\u0628 \u0645\u0627\u0633\u064a\u062a\u0645 \u0627\u0631\u0633\u0627\u0644\u0647 \u0645\u0646 \u0627\u0644 Form .<\/span><\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" id=\"__wp-temp-img-id\" title=\"\" src=\"http:\/\/s01.arab.sh\/i\/00078\/roh3swdsvm9q.png\" alt=\"\" \/><\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" id=\"__wp-temp-img-id\" title=\"\" src=\"http:\/\/s01.arab.sh\/i\/00078\/21q3t03lg1hw.png\" alt=\"\" \/><\/p>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u0641\u064a \u0646\u0647\u0627\u064a\u0629 \u0627\u0644\u0623\u0645\u0631 \u0633\u064a\u0643\u0648\u0646 \u0645\u0644\u0641 \u0627\u0644\u0640 API \u0628\u0647\u0630\u0627 \u0627\u0644\u0634\u0643\u0644 :<\/span><\/p>\n<p><script src=\"https:\/\/gist.github.com\/Ahmad-Magdy\/3b11ac3d25c2ded109a7fc2d92ac31fa.js\"><\/script><\/p>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u0623\u0631\u062c\u0648 \u0627\u0646 \u064a\u0643\u0648\u0646 \u0627\u0644\u0634\u0631\u062d \u0648\u0627\u0636\u062d \u0648\u0627\u0646 \u0643\u0627\u0646 \u0647\u0646\u0627\u0643 \u0627\u064a \u0627\u0633\u062a\u0641\u0633\u0627\u0631 \u0641\u0636\u0644\u0627\u064b \u0627\u062a\u0631\u0643\u0647 \u0641\u064a \u062a\u0639\u0644\u064a\u0642 \u0648\u0633\u0627\u0642\u0648\u0645 \u0628\u0627\u0644\u0627\u062c\u0627\u0628\u0629 \u0639\u0644\u064a\u0647.<\/span><\/p>\n<blockquote>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\">\u064a\u0645\u0643\u0646\u0643 \u062a\u062d\u0645\u064a\u0644 \u0627\u0644\u0645\u0634\u0631\u0648\u0639 \u0643\u0627\u0645\u0644\u0627\u064b \u0645\u0646 GitHub \u0639\u0644\u0649 \u0627\u0644\u0631\u0627\u0628\u0637 \u0627\u0644\u062a\u0627\u0644\u064a<br \/>\n<a href=\"https:\/\/github.com\/Ahmad-Magdy\/Company-API-Project\" target=\"_blank\"><img decoding=\"async\" id=\"__wp-temp-img-id\" title=\"\" src=\"http:\/\/alvarotrigo.com\/img\/githubLink.png\" alt=\"\" \/><\/a><br \/>\n<\/span><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>\u0641\u064a \u0627\u0644\u0645\u0631\u0629 \u0627\u0644\u0633\u0627\u0628\u0642\u0629 \u062a\u062d\u062f\u062b\u0646\u0627 \u0639\u0646 \u0643\u064a\u0641\u064a\u0629 \u0627\u0639\u062f\u0627\u062f \u0628\u064a\u0626\u0629 \u0627\u0644\u0639\u0645\u0644 \u0648\u062a\u0637\u0631\u0642\u0646\u0627 \u0627\u0644\u0649 \u062c\u0632\u0621 \u0628\u0633\u064a\u0637 \u0645\u0646 \u0627\u0639\u062f\u0627\u062f \u0627\u0644\u0640 API \u0627\u0644\u062e\u0627\u0635\u0629 \u0628\u0646\u0627. \u0643\u064a\u0641\u064a\u0629 \u0628\u0646\u0627\u0621 RESTful API \u0628\u0627\u0633\u062a\u062e\u062f\u0627\u0645 Node.js \u0648 Express.js \u0627\u0644\u062c\u0632\u0621 \u0627\u0644\u0623\u0648\u0644 \u0641\u064a \u0647\u0630\u0647 \u0627\u0644\u0645\u0631\u0629 \u0628\u0627\u0630\u0646 \u0627\u0644\u0644\u0647 \u0633\u0646\u0643\u0645\u0644 \u0645\u0627\u0628\u062f\u0623\u0646\u0627\u0647. \u0623\u0648\u0644\u0627\u064b \u0644\u062a\u0646\u0638\u064a\u0645 \u0627\u0644\u0639\u0645\u0644 \u0646\u0646\u0634\u0626 \u0645\u0644\u0641 \u062c\u062f\u064a\u062f \u064a\u062d\u062a\u0648\u064a \u0639\u0644\u0649 \u0627\u0644\u0627\u0639\u062f\u0627\u062f\u0627\u062a \u0627\u0644\u0631\u0626\u064a\u0633\u064a\u0629 \u0648\u0646\u0633\u0645\u064a\u0647 &#8220;config.js&#8221; \u0633\u064a\u062d\u062a\u0648\u064a \u0639\u0644\u0649 \u0631\u0627\u0628\u0637 \u0642\u0627\u0639\u062f\u0629 \u0627\u0644\u0628\u064a\u0627\u0646\u0627\u062a \u0648 \u0631\u0642\u0645 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[2,11],"tags":[13,16,14],"class_list":["post-214","post","type-post","status-publish","format-standard","hentry","category-2","category-11","tag-api","tag-express","tag-node"],"aioseo_notices":[],"views":1760,"_links":{"self":[{"href":"https:\/\/magdy.dk\/arblog\/index.php?rest_route=\/wp\/v2\/posts\/214","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/magdy.dk\/arblog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/magdy.dk\/arblog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/magdy.dk\/arblog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/magdy.dk\/arblog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=214"}],"version-history":[{"count":17,"href":"https:\/\/magdy.dk\/arblog\/index.php?rest_route=\/wp\/v2\/posts\/214\/revisions"}],"predecessor-version":[{"id":257,"href":"https:\/\/magdy.dk\/arblog\/index.php?rest_route=\/wp\/v2\/posts\/214\/revisions\/257"}],"wp:attachment":[{"href":"https:\/\/magdy.dk\/arblog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=214"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/magdy.dk\/arblog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=214"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/magdy.dk\/arblog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=214"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}