{"id":354451,"date":"2024-05-20T22:48:38","date_gmt":"2024-05-20T22:48:38","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=354451"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=354451","title":{"rendered":"<span>\u041a\u0430\u043a \u044f \u043f\u0438\u0441\u0430\u043b \u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0430 NodeJS \u0434\u043b\u044f \u0431\u0430\u0437\u044b Firebird 3.0<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u043f\u0438\u0441\u0430\u043b \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u0434\u043b\u044f \u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0441\u043e \u0441\u0442\u0430\u0440\u043e\u0439 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 Firebird.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/016\/817\/47e\/01681747e81042c48d3b705c9ef54d27.jpg\" width=\"1671\" height=\"851\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/016\/817\/47e\/01681747e81042c48d3b705c9ef54d27.jpg\" data-blurred=\"true\"\/><\/figure>\n<p>\u0421\u0443\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f: \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0441\u0442\u0430\u0440\u0430\u044f \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 Firebird 3.0, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043a\u0440\u0443\u0442\u0438\u0442\u0441\u044f \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435. \u041d\u0443\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c backend, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0449\u0430\u0442\u044c\u0441\u044f \u0441 \u0434\u0430\u043d\u043d\u043e\u0439 \u0431\u0430\u0437\u043e\u0439.<\/p>\n<p> <em>\u041d\u0435 \u0441\u0443\u0434\u0438\u0442\u0435 \u0441\u0442\u0440\u043e\u0433\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e \u043c\u043e\u0439 \u043f\u0435\u0440\u0432\u044b\u0439 \u043e\u043f\u044b\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f backend \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435.<\/em><\/p>\n<p>\u0418\u0442\u0430\u043a, \u0432\u0441\u0451 \u0447\u0442\u043e \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0438\u043c\u0435\u043b\u043e\u0441\u044c \u0443 \u043c\u0435\u043d\u044f, \u044d\u0442\u043e \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445. \u0414\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u044f \u0431\u0443\u0434\u0443 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0442\u044c \u0435\u0435 <code>DB<\/code>.  \u041f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u0448\u0430\u0433\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 NodeJS. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0430\u043f\u043a\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442 <code>npm init<\/code>. \u0414\u0430\u043d\u043d\u044b\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043b\u044e\u0431\u044b\u0435. \u041f\u043e\u0441\u043b\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 <code>\"type\": \"module\"<\/code>  \u0432 \u0444\u0430\u0439\u043b\u0435 <code>package.json.<\/code><\/p>\n<pre><code class=\"json\">{   \"type\": \"module\",   \"name\": \"nodejs-server-firebird\",   \"version\": \"1.0.0\",   \"description\": \"\",   \"main\": \"index.js\",   \"scripts\": {     \"test\": \"echo \\\"Error: no test specified\\\" &amp;&amp; exit 1\"   },   \"author\": \"\",   \"license\": \"ISC\" }<\/code><\/pre>\n<p>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0432 \u044d\u0442\u0443 \u0436\u0435 \u043f\u0430\u043f\u043a\u0443 <code>node-firebird<\/code> \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439:<\/p>\n<pre><code class=\"javascript\">npm install node-firebird <\/code><\/pre>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0430\u043a\u0435\u0442\u0430 \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f \u043a \u0431\u0430\u0437\u0435.<\/p>\n<p>\u0412 \u043a\u043e\u0440\u043d\u0435 \u043f\u0430\u043f\u043a\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0430\u043f\u043a\u0443 <em>src. <\/em>\u0414\u043e\u043b\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0445\u043e\u0436\u0435\u0435:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/163\/5d8\/a7c\/1635d8a7ce5470e43d3a58373411df5b.png\" alt=\"\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\" title=\"\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\" width=\"182\" height=\"99\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/163\/5d8\/a7c\/1635d8a7ce5470e43d3a58373411df5b.png\"\/><\/p>\n<div><figcaption>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/figcaption><\/div>\n<\/figure>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0432 \u043f\u0430\u043f\u043a\u0435 src \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0434\u0432\u0435 \u043f\u0430\u043f\u043a\u0438: <em>config<\/em> \u0438 <em>db. <\/em>\u0410 \u0432 \u043f\u0430\u043f\u043a\u0435 src \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b <em>index.js<\/em><\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d60\/9c0\/8a5\/d609c08a5efcdd1ddb08110d39189e77.png\" width=\"201\" height=\"163\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d60\/9c0\/8a5\/d609c08a5efcdd1ddb08110d39189e77.png\"\/><\/figure>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043f\u0430\u043a\u0435\u0442\u044b: <code>express<\/code> \u0438 <code>cors<\/code><\/p>\n<pre><code class=\"javascript\">npm install express <\/code><\/pre>\n<pre><code class=\"javascript\">npm install cors<\/code><\/pre>\n<p>\u0414\u043e\u043b\u0436\u043d\u0430 \u043f\u043e\u044f\u0432\u0438\u0442\u044c\u0441\u044f \u043f\u0430\u043f\u043a\u0430 <code>node_modules<\/code>   \u0438 \u0444\u0430\u0439\u043b <code>package-lock.json<\/code><\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d3b\/af3\/325\/d3baf3325894b000b082197a4402b988.png\" width=\"208\" height=\"184\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d3b\/af3\/325\/d3baf3325894b000b082197a4402b988.png\"\/><\/figure>\n<p>\u0417\u0430\u043e\u0434\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u043d\u0435 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440 \u0432\u0440\u0443\u0447\u043d\u0443\u044e, \u0430 \u043f\u0440\u0438 \u043b\u044e\u0431\u044b\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u0445 \u043e\u043d \u0441\u043c\u043e\u0433 \u0441\u0430\u043c \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c\u0441\u044f, \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043c \u043f\u0430\u043a\u0435\u0442 <a href=\"https:\/\/www.npmjs.com\/package\/nodemon\" rel=\"noopener noreferrer nofollow\">nodemon<\/a><\/p>\n<pre><code class=\"javascript\">npm install nodemon<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u044e \u043d\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b <strong>database.js<\/strong> \u0432 \u043f\u0430\u043f\u043a\u0435 <em>config. <\/em>\u041e\u043d \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u0437\u0430 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u0431\u0430\u0437\u043e\u0439. \u0417\u0434\u0435\u0441\u044c \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0431\u0430\u0437\u044b. \u0410 \u0442\u0430\u043a\u0436\u0435 \u043f\u0438\u0448\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u0442\u0441\u044f \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445. <\/p>\n<pre><code class=\"javascript\">import firebird from \"node-firebird\";  const dbOptions = {     host: 'localhost',     port: 3050,     database: 'C:\\\\Users\\\\user\\\\Documents\\\\nodejs-server-firebird\\\\DB.DB',         user: 'SYSDBA',     password: 'masterkey',     lowercase_keys: true,      role: null,         pageSize: 4096     };  function executeQuery(ssql, params, callback){      firebird.attach(dbOptions, function(err, db) {                      if (err) {             return callback(err, []);          }           db.query(ssql, params, function(err, result) {                          db.detach();              if (err) {                 return callback(err, []);             } else {                 return callback(undefined, result);             }         });      }); }  export {executeQuery};<\/code><\/pre>\n<hr\/>\n<p>\u0412\u0441\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0431\u0443\u0434\u0443 \u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u0440\u0430\u043d\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 <strong>index.js. <\/strong>\u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u044e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438.<\/p>\n<pre><code class=\"javascript\">import express from \"express\"; import cors from \"cors\"; import { executeQuery } from \".\/config\/database.js\";  const app = express();  app.use(express.json());  app.use(cors());<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043f\u0438\u0448\u0443 \u043f\u0435\u0440\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <strong>GET<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u0417\u0430\u043e\u0434\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044e \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043d\u0430 \u0444\u0438\u043b\u044c\u0442\u0440 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 id.<\/p>\n<pre><code class=\"javascript\">app.get(\"\/products\", (req, res) => {   try {     const { id_prod } = req.query; \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 id_prod \u0438\u0437 \u0437\u0430\u043f\u0440\u043e\u0441\u0430      let ssql = \"SELECT * FROM PRODUCTS WHERE ID_PROD > 0\"; \/\/ \u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c SQL-\u0437\u0430\u043f\u0440\u043e\u0441     const filter = [];      if (id_prod) {       ssql += \" AND ID_PROD LIKE ?\"; \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u043e id_prod       filter.push(`%${id_prod}%`);     }      \/\/ \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c SQL-\u0437\u0430\u043f\u0440\u043e\u0441 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 executeQuery     executeQuery(ssql, filter, (err, result) => {       if (err) {         res.status(500).json({ error: err.message }); \/\/ \u041e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0443 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u043b\u0438\u0435\u043d\u0442\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435       } else if (result.length === 0) {         res.status(404).json({ error: \"\u041d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043e\" }); \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0442\u0430\u0442\u0443\u0441 404, \u0435\u0441\u043b\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u0443\u0441\u0442\u043e\u0439       } else {         res.status(200).json(result); \/\/ \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u043b\u0438\u0435\u043d\u0442\u0443 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0430       }     });   } catch (error) {     res.status(500).json({ error: error.message }); \/\/ \u041e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u043b\u0438\u0435\u043d\u0442\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435   } });<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f02\/375\/3e6\/f023753e6fdd5dccd9164235d1ef848c.png\" alt=\"\u041c\u0435\u0442\u043e\u0434\u043e\u043c GET \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\" title=\"\u041c\u0435\u0442\u043e\u0434\u043e\u043c GET \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\" width=\"1919\" height=\"1041\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f02\/375\/3e6\/f023753e6fdd5dccd9164235d1ef848c.png\"\/><\/p>\n<div><figcaption>\u041c\u0435\u0442\u043e\u0434\u043e\u043c GET \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0444\u0438\u043b\u044c\u0442\u0440\u0430, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/2c2\/9c0\/7bf\/2c29c07bf4f95909407f19f0ae957c52.png\" alt=\"\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0444\u0438\u043b\u044c\u0442\u0440 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 GET\" title=\"\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0444\u0438\u043b\u044c\u0442\u0440 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 GET\" width=\"837\" height=\"499\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2c2\/9c0\/7bf\/2c29c07bf4f95909407f19f0ae957c52.png\"\/><\/p>\n<div><figcaption>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0444\u0438\u043b\u044c\u0442\u0440 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 GET<\/figcaption><\/div>\n<\/figure>\n<hr\/>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0442\u043e\u0436\u0435 <strong>GET<\/strong>, \u043d\u043e \u0438\u043c \u0431\u0443\u0434\u0443 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 &#171;\u043f\u0440\u043e\u0434\u0443\u043a\u0442&#187;. \u0422\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u0443\u044e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u043a\u0430\u0440\u0442\u043e\u0447\u043a\u0443.<\/p>\n<p>\u041e\u0431\u044a\u044f\u0432\u043b\u044f\u044e id  \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0435\u0433\u043e \u0438\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0410 \u043f\u043e\u0442\u043e\u043c \u0432\u044b\u0431\u0438\u0440\u0430\u044e \u043f\u0440\u043e\u0434\u0443\u043a\u0442 \u0441 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c id.<\/p>\n<pre><code class=\"javascript\">\/\/ \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 \u043f\u043e id app.get(\"\/products\/:id\", (req, res) => {   const id = req.params.id; \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c id \u0438\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0430   const ssql = \"SELECT * FROM PRODUCTS WHERE ID_PROD = ?\"; \/\/ \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441    \/\/ \u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 executeQuery   executeQuery(ssql, [id], (err, result) => {     if (err) {       console.error(\"\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430:\", err);       res.status(500).send(\"Internal Server Error\"); \/\/ \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u0430     } else if (result.length === 0) {       res.status(404).send(\"Product not found\"); \/\/ \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d, \u0435\u0441\u043b\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u0443\u0441\u0442\u043e\u0439     } else {       res.send(result[0]); \/\/ \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0435\u0440\u0432\u044b\u0439 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0434\u0443\u043a\u0442 \u0432 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441     }   }); }); <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0432 \u0441\u0441\u044b\u043b\u043a\u0435 id \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <em>\/products\/9.<\/em>  \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e \u0437\u0430\u043f\u0440\u043e\u0441 \u0432 Postman, \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u0432\u043e\u0442 \u0442\u0430\u043a. \u041e\u0442\u043b\u0438\u0447\u043d\u043e.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/2fe\/8cd\/a71\/2fe8cda71b9e2ec71680b6d776d8545d.png\" width=\"841\" height=\"666\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2fe\/8cd\/a71\/2fe8cda71b9e2ec71680b6d776d8545d.png\"\/><\/figure>\n<hr\/>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 <strong>POST<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0432 \u0431\u0430\u0437\u0435.<\/p>\n<pre><code class=\"javascript\">\/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 app.post(\"\/products\/new\", (req, res) => {   const ssql = \"INSERT INTO PRODUCTS(NAME, ABOUT) VALUES (?, ?) RETURNING ID_PROD\"; \/\/ SQL-\u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u043b\u044f \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0435\u0433\u043e ID    \/\/ \u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 executeQuery \u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438\u0437 \u0442\u0435\u043b\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 (req.body)   executeQuery(ssql, [req.body.NAME, req.body.ABOUT], (err, result) => {     if (err) {       if (err.code === \"ER_DUP_ENTRY\") {         res.status(409).json({ error: \"\u0417\u0430\u043f\u0438\u0441\u044c \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442\" }); \/\/ \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0448\u0438\u0431\u043a\u0438 \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u0438       } else if (err.code === \"ECONNREFUSED\") {         res.status(502).json({ error: \"\u0421\u0435\u0440\u0432\u0435\u0440 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445\" }); \/\/ \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0448\u0438\u0431\u043a\u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445       } else {         console.error(\"\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430:\", err);         res.status(500).json({ error: \"\u041f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0430 \u043e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430\" }); \/\/ \u041e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u043e\u0431\u0449\u0435\u0439 \u043e\u0448\u0438\u0431\u043a\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430       }     } else {       res.status(201).json(\"\u041d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0434\u0443\u043a\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d, \u0435\u0433\u043e id \" + result.id_prod); \/\/ \u041e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0433\u043e \u043e\u0442\u0432\u0435\u0442\u0430 \u0441 ID \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430     }   }); }); <\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b29\/ef1\/ad9\/b29ef1ad91b3e28fc68d671ed8bf49fd.png\" alt=\"\u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e \u0437\u0430\u043f\u0440\u043e\u0441 \u0432 POSTMAN\" title=\"\u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e \u0437\u0430\u043f\u0440\u043e\u0441 \u0432 POSTMAN\" width=\"852\" height=\"454\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b29\/ef1\/ad9\/b29ef1ad91b3e28fc68d671ed8bf49fd.png\"\/><\/p>\n<div><figcaption>\u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e \u0437\u0430\u043f\u0440\u043e\u0441 \u0432 POSTMAN<\/figcaption><\/div>\n<\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0e1\/1b9\/9ac\/0e11b99ac97a5aacd425ea4b9e035f76.png\" alt=\"\u0421\u043c\u043e\u0442\u0440\u044e, \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0441\u0442\u0440\u043e\u043a\u0430 \u0432 \u0431\u0430\u0437\u0435\" title=\"\u0421\u043c\u043e\u0442\u0440\u044e, \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0441\u0442\u0440\u043e\u043a\u0430 \u0432 \u0431\u0430\u0437\u0435\" width=\"572\" height=\"325\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0e1\/1b9\/9ac\/0e11b99ac97a5aacd425ea4b9e035f76.png\"\/><\/p>\n<div><figcaption>\u0421\u043c\u043e\u0442\u0440\u044e, \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0441\u0442\u0440\u043e\u043a\u0430 \u0432 \u0431\u0430\u0437\u0435<\/figcaption><\/div>\n<\/figure>\n<hr\/>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043c\u0435\u0442\u043e\u0434 <strong>PUT<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0431\u0443\u0434\u0443 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c.<\/p>\n<pre><code class=\"javascript\">\/\/ \u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0435 \u043f\u043e \u0435\u0433\u043e ID app.put(\"\/products\/:id_prod\/update\", function (req, res) {   const id_prod = req.params.id_prod; \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c ID \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 \u0438\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0430   const { name, about } = req.body; \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u0437 \u0442\u0435\u043b\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430    let ssql = 'UPDATE PRODUCTS SET name = ?, about = ? WHERE ID_PROD = ?'; \/\/ SQL-\u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0435    \/\/ \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c SQL-\u0437\u0430\u043f\u0440\u043e\u0441 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 executeQuery   executeQuery(ssql, [name, about, id_prod], function (err, result) {     if (err) {       console.error(err);       return res.status(500).json({ error: '\u041f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0430 \u043e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438 \u0437\u0430\u043f\u0438\u0441\u0438.' }); \/\/ \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043f\u0440\u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u0438 \u043e\u0448\u0438\u0431\u043a\u0438 SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u0430     } else {       return res.status(200).json({ message: `\u0417\u0430\u043f\u0438\u0441\u044c \u0441 id_prod: ${id_prod} \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0430.` }); \/\/ \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442 \u043f\u043e\u0441\u043b\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0433\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f     }   }); }); <\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/760\/a20\/9bd\/760a209bdebd1f2ec51acbd928bd7a93.png\" alt=\"\u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 21 \u0441\u0442\u0440\u043e\u043a\u0438\" title=\"\u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 21 \u0441\u0442\u0440\u043e\u043a\u0438\" width=\"833\" height=\"418\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/760\/a20\/9bd\/760a209bdebd1f2ec51acbd928bd7a93.png\"\/><\/p>\n<div><figcaption>\u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 21 \u0441\u0442\u0440\u043e\u043a\u0438<\/figcaption><\/div>\n<\/figure>\n<hr\/>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b, \u044d\u0442\u043e <strong>DELETE<\/strong>. \u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e id_prod, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u0435\u0441\u0442\u044c \u043b\u0438 \u0441\u0442\u0440\u043e\u043a\u0430 \u0432 \u0431\u0430\u0437\u0435, \u0435\u0441\u043b\u0438 \u0435\u0435 \u043d\u0435\u0442, \u0442\u043e\u0433\u0434\u0430 \u043f\u0430\u0434\u0430\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0430 \u0447\u0442\u043e \u0435\u0435 \u043d\u0435\u0442. \u0415\u0441\u043b\u0438 \u0441\u0442\u0440\u043e\u043a\u0430 \u0432\u0441\u0435 \u0442\u0430\u043a\u0438 \u0435\u0441\u0442\u044c, \u0442\u043e\u0433\u0434\u0430 \u043e\u043d\u0430 \u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f.<\/p>\n<pre><code class=\"javascript\">\/\/ \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a HTTP DELETE-\u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u043e ID_PROD app.delete(\"\/products\/:id_prod\", function (req, res) {   const id_prod = req.params.id_prod;   const selectQuery = \"SELECT ID_PROD FROM PRODUCTS WHERE ID_PROD = ?\";    \/\/ \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u0435\u0440\u0435\u0434 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435\u043c   executeQuery(selectQuery, [id_prod], function (err, result) {     if (err) {       return res.status(500).send('\u041e\u0448\u0438\u0431\u043a\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0430 \u0432\u044b\u0431\u043e\u0440\u043a\u0443: ' + err.message);     }      \/\/ \u0415\u0441\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u044c \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c ID_PROD \u043d\u0430\u0439\u0434\u0435\u043d\u0430     if (result.length > 0) {       const deleteQuery = \"DELETE FROM PRODUCTS WHERE ID_PROD = ?\";        \/\/ \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438       executeQuery(deleteQuery, [id_prod], function (err, result) {         if (err) {           return res.status(500).send('\u041e\u0448\u0438\u0431\u043a\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f: ' + err.message);         }          \/\/ \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0439 \u0441\u0442\u0430\u0442\u0443\u0441 \u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u043c \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438         return res.send(`\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0441 ID_PROD=${id_prod} \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u043e`);       });     } else {       \/\/ \u0415\u0441\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u044c \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u0430, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0441\u0442\u0430\u0442\u0443\u0441 404 \u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0438 \u0437\u0430\u043f\u0438\u0441\u0438       return res.status(404).send(`\u0417\u0430\u043f\u0438\u0441\u044c \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c ID_PROD ${id_prod} \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043e\u043d\u0430 \u0443\u0436\u0435 \u0431\u044b\u043b\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u0430`);     }   }); });<\/code><\/pre>\n<p>\u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u044d\u0442\u043e \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9aa\/b18\/2f8\/9aab182f87356b4dce5774fe047df09b.png\" alt=\"\u041f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441, \u0441\u0442\u0440\u043e\u043a\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u0437\u043d\u0430\u0447\u0438\u0442 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u043e.\" title=\"\u041f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441, \u0441\u0442\u0440\u043e\u043a\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u0437\u043d\u0430\u0447\u0438\u0442 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u043e.\" width=\"836\" height=\"434\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9aa\/b18\/2f8\/9aab182f87356b4dce5774fe047df09b.png\"\/><\/p>\n<div><figcaption>\u041f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441, \u0441\u0442\u0440\u043e\u043a\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u0437\u043d\u0430\u0447\u0438\u0442 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u043e.<\/figcaption><\/div>\n<\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d87\/4f8\/5aa\/d874f85aac3f2e11d75e8f999417de97.png\" alt=\"\u041f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u044d\u0442\u043e\u0442 \u0436\u0435 \u0437\u0430\u043f\u0440\u043e\u0441. \u041f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 404 \u0441\u0442\u0430\u0442\u0443\u0441.\" title=\"\u041f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u044d\u0442\u043e\u0442 \u0436\u0435 \u0437\u0430\u043f\u0440\u043e\u0441. \u041f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 404 \u0441\u0442\u0430\u0442\u0443\u0441.\" width=\"838\" height=\"441\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d87\/4f8\/5aa\/d874f85aac3f2e11d75e8f999417de97.png\"\/><\/p>\n<div><figcaption>\u041f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u044d\u0442\u043e\u0442 \u0436\u0435 \u0437\u0430\u043f\u0440\u043e\u0441. \u041f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 404 \u0441\u0442\u0430\u0442\u0443\u0441.<\/figcaption><\/div>\n<\/figure>\n<hr\/>\n<p>\u0412 \u0441\u0430\u043c\u043e\u043c \u043a\u043e\u043d\u0446\u0435 \u0444\u0430\u0439\u043b\u0430 <strong>index.js<\/strong> \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u043e\u0441\u043b\u0443\u0448\u0438\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u0440\u0442\u0430 3000 \u0434\u043b\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430.<\/p>\n<pre><code class=\"javascript\">app.listen(3000, function () {   console.log(\"Server is running on port 3000\"); });<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439:<\/p>\n<pre><code class=\"javascript\">nodemon src\/index.js<\/code><\/pre>\n<p>\u0412\u0438\u0434\u0438\u043c \u043b\u043e\u0433 \u0447\u0442\u043e \u0441\u0435\u0440\u0432\u0435\u0440 \u0437\u0430\u043f\u0443\u0449\u0435\u043d:<\/p>\n<pre><code class=\"bash\">$ nodemon src\/index.js [nodemon] 3.0.1 [nodemon] to restart at any time, enter `rs` [nodemon] watching path(s): *.* [nodemon] watching extensions: js,mjs,cjs,json [nodemon] starting `node src\/index.js` Server is running on port 3000<\/code><\/pre>\n<p><strong>\u0411\u041e\u041d\u0423\u0421:<\/strong> \u0412 \u043f\u0430\u043f\u043a\u0443 <strong>db<\/strong> \u0435\u0449\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f \u0411\u0414 Firebird, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0442\u0435\u0441\u0442\u043e\u0432\u0443\u044e \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435. \u041f\u0440\u043e\u0441\u0442\u043e \u0434\u043b\u044f \u0441\u0435\u0431\u044f.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1ae\/e10\/82b\/1aee1082be2803f0903f37270b41fe5e.png\" width=\"865\" height=\"335\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1ae\/e10\/82b\/1aee1082be2803f0903f37270b41fe5e.png\"\/><\/figure>\n<pre><code class=\"sql\">CREATE TABLE PRODUCTS (   ID_PROD INTEGER GENERATED BY DEFAULT AS IDENTITY,   NAME VARCHAR(100),   ABOUT VARCHAR(100),   CONSTRAINT PK_PRODUCTS PRIMARY KEY (ID_PROD) );<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u0432 \u0411\u0414.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/5bd\/7e0\/44a\/5bd7e044a2d4793f97ddec7d3b845171.png\" width=\"862\" height=\"338\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5bd\/7e0\/44a\/5bd7e044a2d4793f97ddec7d3b845171.png\"\/><\/figure>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/760000\/\"> https:\/\/habr.com\/ru\/articles\/760000\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u043f\u0438\u0441\u0430\u043b \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u0434\u043b\u044f \u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0441\u043e \u0441\u0442\u0430\u0440\u043e\u0439 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 Firebird.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0421\u0443\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f: \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0441\u0442\u0430\u0440\u0430\u044f \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 Firebird 3.0, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043a\u0440\u0443\u0442\u0438\u0442\u0441\u044f \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435. \u041d\u0443\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c backend, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0449\u0430\u0442\u044c\u0441\u044f \u0441 \u0434\u0430\u043d\u043d\u043e\u0439 \u0431\u0430\u0437\u043e\u0439.<\/p>\n<p> <em>\u041d\u0435 \u0441\u0443\u0434\u0438\u0442\u0435 \u0441\u0442\u0440\u043e\u0433\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e \u043c\u043e\u0439 \u043f\u0435\u0440\u0432\u044b\u0439 \u043e\u043f\u044b\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f backend \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435.<\/em><\/p>\n<p>\u0418\u0442\u0430\u043a, \u0432\u0441\u0451 \u0447\u0442\u043e \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0438\u043c\u0435\u043b\u043e\u0441\u044c \u0443 \u043c\u0435\u043d\u044f, \u044d\u0442\u043e \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445. \u0414\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u044f \u0431\u0443\u0434\u0443 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0442\u044c \u0435\u0435 <code>DB<\/code>.  \u041f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u0448\u0430\u0433\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 NodeJS. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0430\u043f\u043a\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442 <code>npm init<\/code>. \u0414\u0430\u043d\u043d\u044b\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043b\u044e\u0431\u044b\u0435. \u041f\u043e\u0441\u043b\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 <code>\"type\": \"module\"<\/code>  \u0432 \u0444\u0430\u0439\u043b\u0435 <code>package.json.<\/code><\/p>\n<pre><code class=\"json\">{   \"type\": \"module\",   \"name\": \"nodejs-server-firebird\",   \"version\": \"1.0.0\",   \"description\": \"\",   \"main\": \"index.js\",   \"scripts\": {     \"test\": \"echo \\\"Error: no test specified\\\" &amp;&amp; exit 1\"   },   \"author\": \"\",   \"license\": \"ISC\" }<\/code><\/pre>\n<p>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0432 \u044d\u0442\u0443 \u0436\u0435 \u043f\u0430\u043f\u043a\u0443 <code>node-firebird<\/code> \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439:<\/p>\n<pre><code class=\"javascript\">npm install node-firebird <\/code><\/pre>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0430\u043a\u0435\u0442\u0430 \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f \u043a \u0431\u0430\u0437\u0435.<\/p>\n<p>\u0412 \u043a\u043e\u0440\u043d\u0435 \u043f\u0430\u043f\u043a\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0430\u043f\u043a\u0443 <em>src. <\/em>\u0414\u043e\u043b\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0445\u043e\u0436\u0435\u0435:<\/p>\n<figure class=\"\">\n<div><figcaption>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/figcaption><\/div>\n<\/figure>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0432 \u043f\u0430\u043f\u043a\u0435 src \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0434\u0432\u0435 \u043f\u0430\u043f\u043a\u0438: <em>config<\/em> \u0438 <em>db. <\/em>\u0410 \u0432 \u043f\u0430\u043f\u043a\u0435 src \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b <em>index.js<\/em><\/p>\n<figure class=\"\"><\/figure>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043f\u0430\u043a\u0435\u0442\u044b: <code>express<\/code> \u0438 <code>cors<\/code><\/p>\n<pre><code class=\"javascript\">npm install express <\/code><\/pre>\n<pre><code class=\"javascript\">npm install cors<\/code><\/pre>\n<p>\u0414\u043e\u043b\u0436\u043d\u0430 \u043f\u043e\u044f\u0432\u0438\u0442\u044c\u0441\u044f \u043f\u0430\u043f\u043a\u0430 <code>node_modules<\/code>   \u0438 \u0444\u0430\u0439\u043b <code>package-lock.json<\/code><\/p>\n<figure class=\"\"><\/figure>\n<p>\u0417\u0430\u043e\u0434\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u043d\u0435 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440 \u0432\u0440\u0443\u0447\u043d\u0443\u044e, \u0430 \u043f\u0440\u0438 \u043b\u044e\u0431\u044b\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u0445 \u043e\u043d \u0441\u043c\u043e\u0433 \u0441\u0430\u043c \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c\u0441\u044f, \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043c \u043f\u0430\u043a\u0435\u0442 <a href=\"https:\/\/www.npmjs.com\/package\/nodemon\" rel=\"noopener noreferrer nofollow\">nodemon<\/a><\/p>\n<pre><code class=\"javascript\">npm install nodemon<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u044e \u043d\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b <strong>database.js<\/strong> \u0432 \u043f\u0430\u043f\u043a\u0435 <em>config. <\/em>\u041e\u043d \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u0437\u0430 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u0431\u0430\u0437\u043e\u0439. \u0417\u0434\u0435\u0441\u044c \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0431\u0430\u0437\u044b. \u0410 \u0442\u0430\u043a\u0436\u0435 \u043f\u0438\u0448\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u0442\u0441\u044f \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445. <\/p>\n<pre><code class=\"javascript\">import firebird from \"node-firebird\";  const dbOptions = {     host: 'localhost',     port: 3050,     database: 'C:\\\\Users\\\\user\\\\Documents\\\\nodejs-server-firebird\\\\DB.DB',         user: 'SYSDBA',     password: 'masterkey',     lowercase_keys: true,      role: null,         pageSize: 4096     };  function executeQuery(ssql, params, callback){      firebird.attach(dbOptions, function(err, db) {                      if (err) {             return callback(err, []);          }           db.query(ssql, params, function(err, result) {                          db.detach();              if (err) {                 return callback(err, []);             } else {                 return callback(undefined, result);             }         });      }); }  export {executeQuery};<\/code><\/pre>\n<hr\/>\n<p>\u0412\u0441\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0431\u0443\u0434\u0443 \u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u0440\u0430\u043d\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 <strong>index.js. <\/strong>\u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u044e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438.<\/p>\n<pre><code class=\"javascript\">import express from \"express\"; import cors from \"cors\"; import { executeQuery } from \".\/config\/database.js\";  const app = express();  app.use(express.json());  app.use(cors());<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043f\u0438\u0448\u0443 \u043f\u0435\u0440\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <strong>GET<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u0417\u0430\u043e\u0434\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044e \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043d\u0430 \u0444\u0438\u043b\u044c\u0442\u0440 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 id.<\/p>\n<pre><code class=\"javascript\">app.get(\"\/products\", (req, res) => {   try {     const { id_prod } = req.query; \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 id_prod \u0438\u0437 \u0437\u0430\u043f\u0440\u043e\u0441\u0430      let ssql = \"SELECT * FROM PRODUCTS WHERE ID_PROD > 0\"; \/\/ \u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c SQL-\u0437\u0430\u043f\u0440\u043e\u0441     const filter = [];      if (id_prod) {       ssql += \" AND ID_PROD LIKE ?\"; \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u043e id_prod       filter.push(`%${id_prod}%`);     }      \/\/ \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c SQL-\u0437\u0430\u043f\u0440\u043e\u0441 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 executeQuery     executeQuery(ssql, filter, (err, result) => {       if (err) {         res.status(500).json({ error: err.message }); \/\/ \u041e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0443 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u043b\u0438\u0435\u043d\u0442\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435       } else if (result.length === 0) {         res.status(404).json({ error: \"\u041d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043e\" }); \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0442\u0430\u0442\u0443\u0441 404, \u0435\u0441\u043b\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u0443\u0441\u0442\u043e\u0439       } else {         res.status(200).json(result); \/\/ \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u043b\u0438\u0435\u043d\u0442\u0443 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0430       }     });   } catch (error) {     res.status(500).json({ error: error.message }); \/\/ \u041e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u043b\u0438\u0435\u043d\u0442\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435   } });<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u041c\u0435\u0442\u043e\u0434\u043e\u043c GET \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0444\u0438\u043b\u044c\u0442\u0440\u0430, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442:<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0444\u0438\u043b\u044c\u0442\u0440 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 GET<\/figcaption><\/div>\n<\/figure>\n<hr\/>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0442\u043e\u0436\u0435 <strong>GET<\/strong>, \u043d\u043e \u0438\u043c \u0431\u0443\u0434\u0443 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 &#171;\u043f\u0440\u043e\u0434\u0443\u043a\u0442&#187;. \u0422\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u0443\u044e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u043a\u0430\u0440\u0442\u043e\u0447\u043a\u0443.<\/p>\n<p>\u041e\u0431\u044a\u044f\u0432\u043b\u044f\u044e id  \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0435\u0433\u043e \u0438\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0410 \u043f\u043e\u0442\u043e\u043c \u0432\u044b\u0431\u0438\u0440\u0430\u044e \u043f\u0440\u043e\u0434\u0443\u043a\u0442 \u0441 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c id.<\/p>\n<pre><code class=\"javascript\">\/\/ \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 \u043f\u043e id app.get(\"\/products\/:id\", (req, res) => {   const id = req.params.id; \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c id \u0438\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0430   const ssql = \"SELECT * FROM PRODUCTS WHERE ID_PROD = ?\"; \/\/ \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441    \/\/ \u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 executeQuery   executeQuery(ssql, [id], (err, result) => {     if (err) {       console.error(\"\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430:\", err);       res.status(500).send(\"Internal Server Error\"); \/\/ \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u0430     } else if (result.length === 0) {       res.status(404).send(\"Product not found\"); \/\/ \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d, \u0435\u0441\u043b\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u0443\u0441\u0442\u043e\u0439     } else {       res.send(result[0]); \/\/ \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0435\u0440\u0432\u044b\u0439 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0434\u0443\u043a\u0442 \u0432 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441     }   }); }); <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0432 \u0441\u0441\u044b\u043b\u043a\u0435 id \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <em>\/products\/9.<\/em>  \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e \u0437\u0430\u043f\u0440\u043e\u0441 \u0432 Postman, \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u0432\u043e\u0442 \u0442\u0430\u043a. \u041e\u0442\u043b\u0438\u0447\u043d\u043e.<\/p>\n<figure class=\"full-width\"><\/figure>\n<hr\/>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 <strong>POST<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0432 \u0431\u0430\u0437\u0435.<\/p>\n<pre><code class=\"javascript\">\/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 app.post(\"\/products\/new\", (req, res) => {   const ssql = \"INSERT INTO PRODUCTS(NAME, ABOUT) VALUES (?, ?) RETURNING ID_PROD\"; \/\/ SQL-\u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u043b\u044f \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0435\u0433\u043e ID    \/\/ \u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 executeQuery \u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438\u0437 \u0442\u0435\u043b\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 (req.body)   executeQuery(ssql, [req.body.NAME, req.body.ABOUT], (err, result) => {     if (err) {       if (err.code === \"ER_DUP_ENTRY\") {         res.status(409).json({ error: \"\u0417\u0430\u043f\u0438\u0441\u044c \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442\" }); \/\/ \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0448\u0438\u0431\u043a\u0438 \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u0438       } else if (err.code === \"ECONNREFUSED\") {         res.status(502).json({ error: \"\u0421\u0435\u0440\u0432\u0435\u0440 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445\" }); \/\/ \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0448\u0438\u0431\u043a\u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445       } else {         console.error(\"\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430:\", err);         res.status(500).json({ error: \"\u041f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0430 \u043e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430\" }); \/\/ \u041e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u043e\u0431\u0449\u0435\u0439 \u043e\u0448\u0438\u0431\u043a\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430       }     } else {       res.status(201).json(\"\u041d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0434\u0443\u043a\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d, \u0435\u0433\u043e id \" + result.id_prod); \/\/ \u041e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0433\u043e \u043e\u0442\u0432\u0435\u0442\u0430 \u0441 ID \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430     }   }); }); <\/code><\/pre>\n<figure class=\"full-width\">\n<div><figcaption>\u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e \u0437\u0430\u043f\u0440\u043e\u0441 \u0432 POSTMAN<\/figcaption><\/div>\n<\/figure>\n<figure class=\"full-width\">\n<div><figcaption>\u0421\u043c\u043e\u0442\u0440\u044e, \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0441\u0442\u0440\u043e\u043a\u0430 \u0432 \u0431\u0430\u0437\u0435<\/figcaption><\/div>\n<\/figure>\n<hr\/>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043c\u0435\u0442\u043e\u0434 <strong>PUT<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0431\u0443\u0434\u0443 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c.<\/p>\n<pre><code class=\"javascript\">\/\/ \u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0435 \u043f\u043e \u0435\u0433\u043e ID app.put(\"\/products\/:id_prod\/update\", function (req, res) {   const id_prod = req.params.id_prod; \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c ID \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 \u0438\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0430   const { name, about } = req.body; \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u0437 \u0442\u0435\u043b\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430    let ssql = 'UPDATE PRODUCTS SET name = ?, about = ? WHERE ID_PROD = ?'; \/\/ SQL-\u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0435    \/\/ \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c SQL-\u0437\u0430\u043f\u0440\u043e\u0441 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 executeQuery   executeQuery(ssql, [name, about, id_prod], function (err, result) {     if (err) {       console.error(err);       return res.status(500).json({ error: '\u041f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0430 \u043e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438 \u0437\u0430\u043f\u0438\u0441\u0438.' }); \/\/ \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043f\u0440\u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u0438 \u043e\u0448\u0438\u0431\u043a\u0438 SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u0430     } else {       return res.status(200).json({ message: `\u0417\u0430\u043f\u0438\u0441\u044c \u0441 id_prod: ${id_prod} \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0430.` }); \/\/ \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442 \u043f\u043e\u0441\u043b\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0433\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f     }   }); }); <\/code><\/pre>\n<figure class=\"full-width\">\n<div><figcaption>\u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 21 \u0441\u0442\u0440\u043e\u043a\u0438<\/figcaption><\/div>\n<\/figure>\n<hr\/>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b, \u044d\u0442\u043e <strong>DELETE<\/strong>. \u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e id_prod, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u0435\u0441\u0442\u044c \u043b\u0438 \u0441\u0442\u0440\u043e\u043a\u0430 \u0432 \u0431\u0430\u0437\u0435, \u0435\u0441\u043b\u0438 \u0435\u0435 \u043d\u0435\u0442, \u0442\u043e\u0433\u0434\u0430 \u043f\u0430\u0434\u0430\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0430 \u0447\u0442\u043e \u0435\u0435 \u043d\u0435\u0442. \u0415\u0441\u043b\u0438 \u0441\u0442\u0440\u043e\u043a\u0430 \u0432\u0441\u0435 \u0442\u0430\u043a\u0438 \u0435\u0441\u0442\u044c, \u0442\u043e\u0433\u0434\u0430 \u043e\u043d\u0430 \u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f.<\/p>\n<pre><code class=\"javascript\">\/\/ \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a HTTP DELETE-\u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u043e ID_PROD app.delete(\"\/products\/:id_prod\", function (req, res) {   const id_prod = req.params.id_prod;   const selectQuery = \"SELECT ID_PROD FROM PRODUCTS WHERE ID_PROD = ?\";    \/\/ \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u0435\u0440\u0435\u0434 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435\u043c   executeQuery(selectQuery, [id_prod], function (err, result) {     if (err) {       return res.status(500).send('\u041e\u0448\u0438\u0431\u043a\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0430 \u0432\u044b\u0431\u043e\u0440\u043a\u0443: ' + err.message);     }      \/\/ \u0415\u0441\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u044c \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c ID_PROD \u043d\u0430\u0439\u0434\u0435\u043d\u0430     if (result.length > 0) {       const deleteQuery = \"DELETE FROM PRODUCTS WHERE ID_PROD = ?\";        \/\/ \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438       executeQuery(deleteQuery, [id_prod], function (err, result) {         if (err) {           return res.status(500).send('\u041e\u0448\u0438\u0431\u043a\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f: ' + err.message);         }          \/\/ \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0439 \u0441\u0442\u0430\u0442\u0443\u0441 \u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u043c \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438         return res.send(`\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0441 ID_PROD=${id_prod} \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u043e`);       });     } else {       \/\/ \u0415\u0441\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u044c \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u0430, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0441\u0442\u0430\u0442\u0443\u0441 404 \u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0438 \u0437\u0430\u043f\u0438\u0441\u0438       return res.status(404).send(`\u0417\u0430\u043f\u0438\u0441\u044c \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c ID_PROD ${id_prod} \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043e\u043d\u0430 \u0443\u0436\u0435 \u0431\u044b\u043b\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u0430`);     }   }); });<\/code><\/pre>\n<p>\u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u044d\u0442\u043e \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u041f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441, \u0441\u0442\u0440\u043e\u043a\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u0437\u043d\u0430\u0447\u0438\u0442 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u043e.<\/figcaption><\/div>\n<\/figure>\n<figure class=\"full-width\">\n<div><figcaption>\u041f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u044d\u0442\u043e\u0442 \u0436\u0435 \u0437\u0430\u043f\u0440\u043e\u0441. \u041f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 404 \u0441\u0442\u0430\u0442\u0443\u0441.<\/figcaption><\/div>\n<\/figure>\n<hr\/>\n<p>\u0412 \u0441\u0430\u043c\u043e\u043c \u043a\u043e\u043d\u0446\u0435 \u0444\u0430\u0439\u043b\u0430 <strong>index.js<\/strong> \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u043e\u0441\u043b\u0443\u0448\u0438\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u0440\u0442\u0430 3000 \u0434\u043b\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430.<\/p>\n<pre><code class=\"javascript\">app.listen(3000, function () {   console.log(\"Server is running on port 3000\"); });<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439:<\/p>\n<pre><code class=\"javascript\">nodemon src\/index.js<\/code><\/pre>\n<p>\u0412\u0438\u0434\u0438\u043c \u043b\u043e\u0433 \u0447\u0442\u043e \u0441\u0435\u0440\u0432\u0435\u0440 \u0437\u0430\u043f\u0443\u0449\u0435\u043d:<\/p>\n<pre><code class=\"bash\">$ nodemon src\/index.js [nodemon] 3.0.1 [nodemon] to restart at any time, enter `rs` [nodemon] watching path(s): *.* [nodemon] watching extensions: js,mjs,cjs,json [nodemon] starting `node src\/index.js` Server is running on port 3000<\/code><\/pre>\n<p><strong>\u0411\u041e\u041d\u0423\u0421:<\/strong> \u0412 \u043f\u0430\u043f\u043a\u0443 <strong>db<\/strong> \u0435\u0449\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f \u0411\u0414 Firebird, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0442\u0435\u0441\u0442\u043e\u0432\u0443\u044e \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435. \u041f\u0440\u043e\u0441\u0442\u043e \u0434\u043b\u044f \u0441\u0435\u0431\u044f.<\/p>\n<figure class=\"full-width\"><\/figure>\n<pre><code class=\"sql\">CREATE TABLE PRODUCTS (   ID_PROD INTEGER GENERATED BY DEFAULT AS IDENTITY,   NAME VARCHAR(100),   ABOUT VARCHAR(100),   CONSTRAINT PK_PRODUCTS PRIMARY KEY (ID_PROD) );<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u0432 \u0411\u0414.<\/p>\n<figure class=\"full-width\"><\/figure>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/760000\/\"> https:\/\/habr.com\/ru\/articles\/760000\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-354451","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/354451","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=354451"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/354451\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=354451"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=354451"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=354451"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}