{"id":258428,"date":"2015-06-01T20:08:02","date_gmt":"2015-06-01T16:08:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=258428"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=258428","title":{"rendered":"Node.JS \u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u043f\u043e \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044e"},"content":{"rendered":"<p>             \u0418\u043d\u043e\u0433\u0434\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445, \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u0430 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0438 \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043e\u0431\u0449\u0435\u0433\u043e \u0437\u0430\u0442\u0440\u0430\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0440\u0430\u0431\u043e\u0442\u044b, \u043d\u0430\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u043a\u0443\u0440\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u043e\u0434\u043d\u043e\u0442\u0438\u043f\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430\u0434 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438.<\/p>\n<p>  \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u043c\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0430\u043a\u0435\u0442 \u0434\u043b\u044f <em>npm<\/em>. \u041d\u0430\u0437\u043e\u0432\u0451\u043c \u0435\u0433\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>storage<\/code> (\u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435). \u0417\u0430\u0440\u0430\u043d\u0435\u0435 \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0442\u0438\u043f\u043e\u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>FsStorage<\/code> (\u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435), <code>MysqlStorage<\/code> (MySQL-\u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435), <code>MongoStorage<\/code> (Mongo-\u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435).<br \/>  <a name=\"habracut\"><\/a><br \/>  \u041d\u0430\u043a\u0438\u0434\u0430\u0435\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u043a\u043e\u0434\u043e\u0432 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0430\u043a\u0435\u0442\u0430 (\u043f\u043e\u0434 \u0441\u043f\u043e\u0439\u043b\u0435\u0440\u043e\u043c):<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u0438\u043c\u0435\u0440\u043d\u044b\u0439 \u043d\u0430\u0431\u0440\u043e\u0441\u043e\u043a \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<ul>\n<li><code>package.json<\/code>:\n<pre><code class=\"javascript\">{     &quot;name&quot;: &quot;storage&quot;,     &quot;version&quot;: &quot;0.1.0&quot;,     &quot;main&quot;: &quot;.\/lib\/index.js&quot;,     &quot;dependencies&quot;: {         &quot;mysql&quot;: &quot;*&quot;,         &quot;mongoose&quot;: &quot;*&quot;     } }<\/code><\/pre>\n<\/li>\n<li><code>lib\/index.js<\/code>:\n<pre><code class=\"javascript\">module.exports = {     FsStorage: require('.\/fs-storage.jsx'),     MysqlStorage: require('.\/mysql-storage.jsx'),     MongoStorage: require('.\/mongo-storage.jsx') }; <\/code><\/pre>\n<\/li>\n<li><code>lib\/fs-storage.js<\/code>:\n<pre><code class=\"javascript\">var fs = require('fs');  module.exports = FsStorage;  function FsStorage() {     \/\/ init code... } <\/code><\/pre>\n<\/li>\n<li><code>lib\/mysql-storage.js<\/code>:\n<pre><code class=\"javascript\">var mysql = require('mysql');  module.exports = MysqlStorage;  function MysqlStorage() {     \/\/ init code... } <\/code><\/pre>\n<\/li>\n<li><code>lib\/mongo-storage.js<\/code>:\n<pre><code class=\"javascript\">var mongoose = require('mongoose');  module.exports = MongoStorage;  function MongoStorage() {     \/\/ init code... } <\/code><\/pre>\n<\/li>\n<\/ul>\n<p>  <\/div>\n<\/div>\n<p>  \u041d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 <code>mysql<\/code> \u0438 <code>mongoose<\/code> \u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u0435\u043d. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u043c \u0432\u043c\u0435\u0441\u0442\u043e \u043a\u043e\u0434\u0430 <code>mysql<\/code> \u0438 <code>mongoose<\/code> \u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0438 (\u043f\u043e\u0434 \u0441\u043f\u043e\u0439\u043b\u0435\u0440\u043e\u043c):<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u0437\u0430\u0433\u043b\u0443\u0448\u0435\u043a \u043c\u043e\u0434\u0443\u043b\u0435\u0439 mysql \u0438 mongoose<\/b><\/p>\n<div class=\"spoiler_text\">\n<ul>\n<li><code>node_modules\/mysql\/index.js<\/code>:<br \/> \n<pre><code class=\"javascript\">console.log('MySQL module loaded'); <\/code><\/pre>\n<\/li>\n<li><code>node_modules\/mongoose\/index.js<\/code>:<br \/> \n<pre><code class=\"javascript\">console.log('Mongoose module loaded'); <\/code><\/pre>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<p>  \u0422\u043e\u0433\u0434\u0430 \u0444\u0430\u0439\u043b\u043e\u0432\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0430\u043a\u0435\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c (\u043f\u043e\u0434 \u0441\u043f\u043e\u0439\u043b\u0435\u0440\u043e\u043c):<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041c\u0430\u043a\u0435\u0442 \u0434\u0435\u0440\u0435\u0432\u0430 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">storage\/     &#9500; lib\/     &#9474;    &#9500; index.js     &#9474;    &#9500; fs-storage.js     &#9474;    &#9500; mongo-storage.js     &#9474;    &#9492; mysql-storage.js     &#9500; node_modules\/     &#9474;    &#9500; mongoose\/     &#9474;    &#9474;    &#9492; index.js     &#9474;    &#9492; mysql\/     &#9474;         &#9492; index.js     &#9492; package.json <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043c\u0435\u0433\u0430-\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432, \u0438 \u043f\u043e \u0445\u043e\u0434\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0432 \u0432\u0438\u0434\u0435 \u0444\u0430\u0439\u043b\u043e\u0432.<\/p>\n<pre><code class=\"javascript\">var storage = require('storage'); var fsStorage = new storage.FsStorage(); <\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0438 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c: \u043a\u0430\u0436\u0434\u044b\u0439 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u0430 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u043e\u0436\u0438\u0434\u0430\u043b\u043e\u0441\u044c. \u0410 \u0435\u0441\u043b\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043e\u043d\u043a\u0443\u0440\u0438\u0440\u0443\u044e\u0449\u0438\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u043f\u0435\u0440\u0435\u0432\u0430\u043b\u0438\u0442 \u0437\u0430 \u0441\u043e\u0442\u043d\u044e, \u0438 \u044d\u0442\u043e \u043d\u0435 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438?!<\/p>\n<p>  \u0422\u0443\u0442 \u043c\u044b \u0438 \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u043c, \u0447\u0442\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0433\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430, \u043d\u0435\u0437\u0430\u0447\u0435\u043c \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u043a\u0430\u043a \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u043f\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044e \u0431\u0430\u0437\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 <i>MySQL<\/i>, \u0442\u0430\u043a \u0438 ODM-\u043a\u043b\u0438\u0435\u043d\u0442 <i>Mongo<\/i>.<\/p>\n<p>  \u0421\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 <code>require('storage')<\/code> \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0432\u044b\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"javascript\">MySQL module loaded Mongoose module loaded <\/code><\/pre>\n<p>  \u041f\u043e\u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0432 \u0441 \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>Object.defineProperty()<\/code>, \u044f \u0434\u043e\u0431\u0438\u043b\u0441\u044f \u0443\u0434\u0438\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0444\u043e\u0440\u043c\u0438\u043b \u0432 \u0432\u0438\u0434\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>demandProperty()<\/code>:<\/p>\n<pre><code class=\"javascript\">function demandProperty(obj, name, modPath) {     Object.defineProperty(obj, name, {         configurable: true,         enumerable: true,         get: function() {             var mod = require(modPath);             Object.defineProperty(obj, name, {                 configurable: false,                 enumerable: true,                 value: mod             });             return mod         }     }) } <\/code><\/pre>\n<p>  \u041f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u043e\u0441\u0442: \u0412\u043c\u0435\u0441\u0442\u043e \u043f\u0440\u044f\u043c\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430 <code>MysqlStorage()<\/code>, \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0430\u043a\u0446\u0435\u0441\u0441\u043e\u0440 (<em>\u0433\u0435\u0442\u0442\u0435\u0440<\/em>). \u041f\u0440\u0438 \u043b\u044e\u0431\u043e\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u043a \u0430\u043a\u0446\u0435\u0441\u0441\u043e\u0440\u0443, \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 <code>require()<\/code>, \u0430 \u0441\u0430\u043c \u0430\u043a\u0446\u0435\u0441\u0441\u043e\u0440 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 <code>require()<\/code>. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u043e\u0433\u043e \u0436\u0435 <code>Object.defineProperty()<\/code> \u043c\u044b \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u043f\u0440\u044f\u043c\u0443\u044e \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0442\u043e\u0442 \u0436\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 <code>require()<\/code> \u0432\u043c\u0435\u0441\u0442\u043e \u0430\u043a\u0446\u0435\u0441\u0441\u043e\u0440\u0430 (\u0442\u043e \u0435\u0441\u0442\u044c, \u043d\u0430 <code>MysqlStorage()<\/code>). \u0422\u0430\u043a \u0432\u0441\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b (\u0440\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u043a\u0440\u043e\u043c\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e) \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0442\u043e\u0439 \u0436\u0435 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c\u044e \u0438 \u043d\u0430\u0434\u0435\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u043e\u0442 \u0443\u0442\u0435\u0447\u0435\u043a, \u043a\u0430\u043a \u0435\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0438 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 <code>require()<\/code>.<\/p>\n<p>  \u0418\u0437\u043c\u0435\u043d\u0438\u043c <code>lib\/index.js<\/code>. \u0417\u0430\u043c\u0435\u043d\u0438\u043c:<\/p>\n<pre><code class=\"javascript\">module.exports = {     FsStorage: require('.\/fs-storage.jsx'),     MysqlStorage: require('.\/mysql-storage.jsx'),     MongoStorage: require('.\/mongo-storage.jsx'), }; <\/code><\/pre>\n<p>\u043d\u0430:<\/p>\n<pre><code class=\"javascript\">demandProperty(module.exports, 'FsStorage', '.\/fs-storage.jsx');     demandProperty(module.exports, 'MysqlStorage', '.\/mysql-storage.jsx');     demandProperty(module.exports, 'MongoStorage', '.\/mongo-storage.jsx'); <\/code><\/pre>\n<p>  \u0418 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c:<\/p>\n<pre><code class=\"javascript\">var storage = require('storage');  console.log(util.inspect(storage)); \/* =&gt;     { FsStorage: [Getter],     MysqlStorage: [Getter],     MongoStorage: [Getter] } *\/  console.log(util.inspect(storage.FsStorage.name)); \/\/ =&gt;  'FsStorage'  console.log(util.inspect(storage)); \/* =&gt;     { FsStorage: [Function: FsStorage],     MysqlStorage: [Getter],     MongoStorage: [Getter] } *\/  var mysql = new storage.MysqlStorage(); \/\/ =&gt;  MySQL module loaded console.log(util.inspect(mysql)); \/\/ =&gt;  '{}'  console.log(util.inspect(storage)); \/* =&gt;     { FsStorage: [Function: FsStorage],     MysqlStorage: [Function: MysqlStorage],     MongoStorage: [Getter] } *\/ <\/code><\/pre>\n<p>  \u0415\u0441\u0442\u044c \u0435\u0449\u0451 \u043e\u0434\u043d\u0430 \u0442\u043e\u043d\u043a\u043e\u0441\u0442\u044c. \u0415\u0441\u043b\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>demandProperty()<\/code> \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u044b \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0432 \u043f\u0430\u043f\u043a\u0435 <code>lib<\/code>, \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u0434\u043e \u043c\u043e\u0434\u0443\u043b\u044f, \u0438\u043d\u0430\u0447\u0435 <code>require()<\/code> \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043a\u0430\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c \u0432 \u0442\u043e\u0439 \u043f\u0430\u043f\u043a\u0435, \u0433\u0434\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d <code>demandProperty()<\/code>:<\/p>\n<pre><code class=\"javascript\">demandProperty(module.exports, 'FsStorage', path.resolve(__dirname, '.\/fs-storage.jsx')); demandProperty(module.exports, 'MysqlStorage', path.resolve(__dirname, '.\/mysql-storage.jsx')); demandProperty(module.exports, 'MongoStorage', path.resolve(__dirname, '.\/mongo-storage.jsx')); <\/code><\/pre>\n<p>  \u0412\u0441\u0435\u043c \u0443\u0434\u0430\u0447\u043d\u044b\u0445 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u043e\u0432!             <\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/259281\/\"> http:\/\/habrahabr.ru\/post\/259281\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>             \u0418\u043d\u043e\u0433\u0434\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445, \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u0430 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0438 \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043e\u0431\u0449\u0435\u0433\u043e \u0437\u0430\u0442\u0440\u0430\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0440\u0430\u0431\u043e\u0442\u044b, \u043d\u0430\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u043a\u0443\u0440\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u043e\u0434\u043d\u043e\u0442\u0438\u043f\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430\u0434 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438.<\/p>\n<p>  \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u043c\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0430\u043a\u0435\u0442 \u0434\u043b\u044f <em>npm<\/em>. \u041d\u0430\u0437\u043e\u0432\u0451\u043c \u0435\u0433\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>storage<\/code> (\u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435). \u0417\u0430\u0440\u0430\u043d\u0435\u0435 \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0442\u0438\u043f\u043e\u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>FsStorage<\/code> (\u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435), <code>MysqlStorage<\/code> (MySQL-\u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435), <code>MongoStorage<\/code> (Mongo-\u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435).  <\/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-258428","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/258428","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=258428"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/258428\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=258428"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=258428"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=258428"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}