Mercurial > hg > nginx-site
annotate xml/ru/docs/njs/node_modules.xml @ 2906:4eb241b57f83
Linux packages: added Ubuntu 22.10 "kinetic".
author | Konstantin Pavlov <thresh@nginx.com> |
---|---|
date | Tue, 25 Oct 2022 15:26:00 +0400 |
parents | 5cd72684e5b8 |
children |
rev | line source |
---|---|
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1 <?xml version="1.0"?> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
2 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
3 <!-- |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
4 Copyright (C) Nginx, Inc. |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
5 --> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
6 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
7 <!DOCTYPE article SYSTEM "../../../../dtd/article.dtd"> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
8 |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
9 <article name="Использование модулей Node.js в njs" |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
10 link="/ru/docs/njs/node_modules.html" |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
11 lang="en" |
2629
5cd72684e5b8
Fixed typo and updated description in Using node modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2592
diff
changeset
|
12 rev="6"> |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
13 |
2576
4c8d0b37932d
Corrected syntax and style of "Using node modules with njs".
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2489
diff
changeset
|
14 <section id="intro"> |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
15 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
16 <para> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
17 Часто разработчику приходится использовать сторонний код и, |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
18 как правило, такой код доступен в виде библиотеки. |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
19 В JavaScript концепция модулей является новой и |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
20 до недавнего времени не была стандартизированa. |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
21 До сих пор множество платформ или браузеров не поддерживают модули, |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
22 по этой причине практически невозможно повторно использовать код. |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
23 В данной статье приводятся способы повторного использования |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
24 кода в njs при помощи <link url="https://nodejs.org/">Node.js</link>. |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
25 </para> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
26 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
27 <note> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
28 В примерах статьи используется функциональность |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
29 <link doc="index.xml">njs</link> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
30 <link doc="changes.xml" id="njs0.3.8">0.3.8</link> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
31 </note> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
32 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
33 <para> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
34 При добавлении стороннего кода в njs |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
35 может возникнуть несколько проблем: |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
36 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
37 <list type="bullet"> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
38 |
2576
4c8d0b37932d
Corrected syntax and style of "Using node modules with njs".
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2489
diff
changeset
|
39 <listitem> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
40 большое количество файлов, ссылающихся друг на друга, и их зависимости |
2576
4c8d0b37932d
Corrected syntax and style of "Using node modules with njs".
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2489
diff
changeset
|
41 </listitem> |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
42 |
2576
4c8d0b37932d
Corrected syntax and style of "Using node modules with njs".
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2489
diff
changeset
|
43 <listitem> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
44 платформозависимые API |
2576
4c8d0b37932d
Corrected syntax and style of "Using node modules with njs".
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2489
diff
changeset
|
45 </listitem> |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
46 |
2576
4c8d0b37932d
Corrected syntax and style of "Using node modules with njs".
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2489
diff
changeset
|
47 <listitem> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
48 языковые конструкции нового стандарта |
2576
4c8d0b37932d
Corrected syntax and style of "Using node modules with njs".
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2489
diff
changeset
|
49 </listitem> |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
50 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
51 </list> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
52 </para> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
53 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
54 <para> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
55 Однако это не является чем-то новым или специфичным для njs. |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
56 Разработчикам JavaScript приходится часто иметь дело с подобными случаями, |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
57 например при поддержке нескольких несхожих платформ |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
58 с разными свойствами. |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
59 Данные проблемы можно разрешить при помощи следующих инструментов: |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
60 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
61 <list type="bullet"> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
62 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
63 <listitem> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
64 Большое количество файлов, ссылающихся друг на друга, и их зависимости |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
65 <para> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
66 Решение: слияние всего независимого кода в один файл. |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
67 Для этих целей могут использоваться утилиты |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
68 <link url="http://browserify.org/">browserify</link> или |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
69 <link url="https://webpack.js.org/">webpack</link>, |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
70 позволяющие преобразовать проект в один файл, содержащий |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
71 код и все зависимости. |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
72 </para> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
73 </listitem> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
74 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
75 <listitem> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
76 Платформозависимые API |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
77 <para> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
78 Решение: использование библиотек, реализующих подобные API |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
79 в платформонезависимом режиме, однако в ущерб производительности. |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
80 Определённая функциональность может быть также реализована при помощи |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
81 <link url="https://polyfill.io/v3/">polyfill</link>. |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
82 </para> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
83 </listitem> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
84 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
85 <listitem> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
86 Языковые конструкции нового стандарта |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
87 <para> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
88 Решение: трансплирование кода— |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
89 ряд преобразований, |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
90 заменяющих новые функции языка в соответствии со старым стандартом. |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
91 Для этих целей может использоваться |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
92 <link url="https://babeljs.io/"> babel</link>. |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
93 </para> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
94 </listitem> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
95 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
96 </list> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
97 </para> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
98 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
99 <para> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
100 В статье также используются две относительно большие |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
101 библиотеки на основе npm: |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
102 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
103 <list type="bullet"> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
104 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
105 <listitem> |
2576
4c8d0b37932d
Corrected syntax and style of "Using node modules with njs".
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2489
diff
changeset
|
106 <link url="https://www.npmjs.com/package/protobufjs">protobufjs</link>— |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
107 библиотека для создания и парсинга protobuf-сообщений, используемая |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
108 протоколом <link url="https://grpc.io/">gRPC</link> |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
109 </listitem> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
110 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
111 <listitem> |
2576
4c8d0b37932d
Corrected syntax and style of "Using node modules with njs".
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2489
diff
changeset
|
112 <link url="https://www.npmjs.com/package/dns-packet">dns-packet</link>— |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
113 библиотека для обработки пакетов протокола DNS |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
114 </listitem> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
115 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
116 </list> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
117 </para> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
118 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
119 </section> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
120 |
2576
4c8d0b37932d
Corrected syntax and style of "Using node modules with njs".
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2489
diff
changeset
|
121 |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
122 <section id="environment" name="Окружение"> |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
123 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
124 <para> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
125 <note> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
126 В статье описываются общие принципы работы |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
127 и не ставится цель описания подробных сценариев работы с Node.js |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
128 и JavaScript. |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
129 Перед выполнением команд |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
130 необходимо ознакомиться с документацией соответствующих пакетов. |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
131 </note> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
132 Сначала, предварительно установив и запустив Node.js, необходимо создать |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
133 пустой проект и установить зависимости; |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
134 для выполнения нижеперечисленных команд необходимо |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
135 находиться в рабочем каталоге: |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
136 <example> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
137 $ mkdir my_project && cd my_project |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
138 $ npx license choose_your_license_here > LICENSE |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
139 $ npx gitignore node |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
140 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
141 $ cat > package.json <<EOF |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
142 { |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
143 "name": "foobar", |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
144 "version": "0.0.1", |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
145 "description": "", |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
146 "main": "index.js", |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
147 "keywords": [], |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
148 "author": "somename <some.email@example.com> (https://example.com)", |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
149 "license": "some_license_here", |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
150 "private": true, |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
151 "scripts": { |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
152 "test": "echo \"Error: no test specified\" && exit 1" |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
153 } |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
154 } |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
155 EOF |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
156 $ npm init -y |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
157 $ npm install browserify |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
158 </example> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
159 </para> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
160 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
161 </section> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
162 |
2576
4c8d0b37932d
Corrected syntax and style of "Using node modules with njs".
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2489
diff
changeset
|
163 |
2481 | 164 <section id="protobuf" name="Protobufjs"> |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
165 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
166 <para> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
167 Библиотека предоставляет парсер |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
168 для определения интерфейса <literal>.proto</literal>, |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
169 а также генератор кода для парсинга и генерации сообщений. |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
170 </para> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
171 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
172 <para> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
173 В данном примере используется |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
174 файл |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
175 <link url="https://github.com/grpc/grpc/blob/master/examples/protos/helloworld.proto">helloworld.proto</link> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
176 из примеров gRPC. |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
177 Целью является создание двух сообщений: |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
178 <literal>HelloRequest</literal> и |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
179 <literal>HelloResponse</literal>. |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
180 Также используется |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
181 <link url="https://github.com/protobufjs/protobuf.js/blob/master/README.md#reflection-vs-static-code">статический</link> |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
182 режим protobufjs вместо динамически генерируемых классов, так как |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
183 njs не поддерживает динамическое добавление новых функций |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
184 из соображений безопасности. |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
185 </para> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
186 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
187 <para> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
188 Затем устанавливается библиотека, |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
189 из определения протокола генерируется код JavaScript, |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
190 реализующий маршалинг сообщений: |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
191 <example> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
192 $ npm install protobufjs |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
193 $ npx pbjs -t static-module helloworld.proto > static.js |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
194 </example> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
195 </para> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
196 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
197 <para> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
198 Таким образом файл <literal>static.js</literal> становится новой зависимостью, |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
199 хранящей необходимый код для реализации обработки сообщений. |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
200 Функция <literal>set_buffer()</literal> содержит код, использующий |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
201 библиотеку для создания буфера с сериализованным |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
202 сообщением <literal>HelloRequest</literal>. |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
203 Код находится в файле <literal>code.js</literal>: |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
204 <example> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
205 var pb = require('./static.js'); |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
206 |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
207 // Пример использования библиотеки protobuf: подготовка буфера к отправке |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
208 function set_buffer(pb) |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
209 { |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
210 // назначение полей gRPC payload |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
211 var payload = { name: "TestString" }; |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
212 |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
213 // создание объекта |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
214 var message = pb.helloworld.HelloRequest.create(payload); |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
215 |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
216 // сериализация объекта в буфер |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
217 var buffer = pb.helloworld.HelloRequest.encode(message).finish(); |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
218 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
219 var n = buffer.length; |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
220 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
221 var frame = new Uint8Array(5 + buffer.length); |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
222 |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
223 frame[0] = 0; // флаг 'compressed' |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
224 frame[1] = (n & 0xFF000000) >>> 24; // длина: uint32 в сетевом порядке байт |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
225 frame[2] = (n & 0x00FF0000) >>> 16; |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
226 frame[3] = (n & 0x0000FF00) >>> 8; |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
227 frame[4] = (n & 0x000000FF) >>> 0; |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
228 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
229 frame.set(buffer, 5); |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
230 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
231 return frame; |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
232 } |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
233 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
234 var frame = set_buffer(pb); |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
235 </example> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
236 </para> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
237 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
238 <para> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
239 Для проверки работоспособности необходимо выполнить код при помощи node: |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
240 <example> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
241 $ node ./code.js |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
242 Uint8Array [ |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
243 0, 0, 0, 0, 12, 10, |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
244 10, 84, 101, 115, 116, 83, |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
245 116, 114, 105, 110, 103 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
246 ] |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
247 </example> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
248 Результатом является закодированный фрейм <literal>gRPC</literal>. |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
249 Теперь фрейм можно запустить с njs: |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
250 <example> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
251 $ njs ./code.js |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
252 Thrown: |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
253 Error: Cannot find module "./static.js" |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
254 at require (native) |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
255 at main (native) |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
256 </example> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
257 </para> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
258 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
259 <para> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
260 Так как модули не поддерживаются, то операция завершается получением исключения. |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
261 В этом случае можно использовать утилиту <literal>browserify</literal> |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
262 или другую подобную утилиту. |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
263 </para> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
264 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
265 <para> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
266 Попытка обработки файла <literal>code.js</literal> завершится |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
267 большим количеством JS-кода, который предполагается запускать в браузере, |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
268 то есть сразу после загрузки. |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
269 Однако необходимо получить другой результат— |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
270 экспортируемую функцию, на которую |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
271 можно сослаться из конфигурации nginx. |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
272 Для этого потребуется создание кода-обёртки. |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
273 <note> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
274 В целях упрощения в примерах данной статьи |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
275 используется <link doc="cli.xml">интерфейс комадной строки</link> njs. |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
276 На практике для запуска кода обычно используется njs-модуль для nginx. |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
277 </note> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
278 </para> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
279 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
280 <para> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
281 Файл <literal>load.js</literal> содержит код, загружающий библиотеку, |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
282 храняющую дескриптор в глобальном пространстве имён: |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
283 <example> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
284 global.hello = require('./static.js'); |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
285 </example> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
286 Данный код будет заменён объединённым содержимым. |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
287 Код будет использовать дескриптор "<literal>global.hello</literal>" для доступа |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
288 к библиотеке. |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
289 </para> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
290 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
291 <para> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
292 Затем для получения всех зависимостей в один файл |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
293 код обрабатыается утилитой <literal>browserify</literal>: |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
294 <example> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
295 $ npx browserify load.js -o bundle.js -d |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
296 </example> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
297 В результате генерируется объёмный файл, содержащий все зависимости: |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
298 <example> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
299 (function(){function...... |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
300 ... |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
301 ... |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
302 },{"protobufjs/minimal":9}]},{},[1]) |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
303 //# sourceMappingURL.............. |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
304 </example> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
305 Для получения результирующего файла "<literal>njs_bundle.js</literal>" |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
306 необходимо объединить "<literal>bundle.js</literal>" и следующий код: |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
307 <example> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
308 // Пример использования библиотеки protobuf: подготовка буфера к отправке |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
309 function set_buffer(pb) |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
310 { |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
311 // назначение полей gRPC payload |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
312 var payload = { name: "TestString" }; |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
313 |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
314 // создание объекта |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
315 var message = pb.helloworld.HelloRequest.create(payload); |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
316 |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
317 // сериализация объекта в буфер |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
318 var buffer = pb.helloworld.HelloRequest.encode(message).finish(); |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
319 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
320 var n = buffer.length; |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
321 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
322 var frame = new Uint8Array(5 + buffer.length); |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
323 |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
324 frame[0] = 0; // флаг 'compressed' |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
325 frame[1] = (n & 0xFF000000) >>> 24; // длина: uint32 в сетевом порядке байт |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
326 frame[2] = (n & 0x00FF0000) >>> 16; |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
327 frame[3] = (n & 0x0000FF00) >>> 8; |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
328 frame[4] = (n & 0x000000FF) >>> 0; |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
329 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
330 frame.set(buffer, 5); |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
331 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
332 return frame; |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
333 } |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
334 |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
335 // функции, вызываемые снаружи |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
336 function setbuf() |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
337 { |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
338 return set_buffer(global.hello); |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
339 } |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
340 |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
341 // вызов кода |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
342 var frame = setbuf(); |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
343 console.log(frame); |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
344 </example> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
345 Для проверки работоспособности необходимо запустить файл при помощи node: |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
346 <example> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
347 $ node ./njs_bundle.js |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
348 Uint8Array [ |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
349 0, 0, 0, 0, 12, 10, |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
350 10, 84, 101, 115, 116, 83, |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
351 116, 114, 105, 110, 103 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
352 ] |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
353 </example> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
354 Дальнейшие шаги выполняются при помощи njs: |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
355 <example> |
2629
5cd72684e5b8
Fixed typo and updated description in Using node modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2592
diff
changeset
|
356 $ njs ./njs_bundle.js |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
357 Uint8Array [0,0,0,0,12,10,10,84,101,115,116,83,116,114,105,110,103] |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
358 </example> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
359 Теперь необходимо задействовать njs API для преобразования |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
360 массива в байтовую строку для дальнейшего использования модулем nginx. |
2629
5cd72684e5b8
Fixed typo and updated description in Using node modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2592
diff
changeset
|
361 Данный код необходимо добавить перед строкой |
5cd72684e5b8
Fixed typo and updated description in Using node modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2592
diff
changeset
|
362 <literal>return frame; }</literal>: |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
363 <example> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
364 if (global.njs) { |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
365 return String.bytesFrom(frame) |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
366 } |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
367 </example> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
368 Проверка работоспособности: |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
369 <example> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
370 $ njs ./njs_bundle.js |hexdump -C |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
371 00000000 00 00 00 00 0c 0a 0a 54 65 73 74 53 74 72 69 6e |.......TestStrin| |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
372 00000010 67 0a |g.| |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
373 00000012 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
374 </example> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
375 Экспортируемая функция получена. |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
376 Парсинг ответа может быть сделан аналогичным способом: |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
377 <example> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
378 function parse_msg(pb, msg) |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
379 { |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
380 // преобразование байтовой строки в массив целых чисел |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
381 var bytes = msg.split('').map(v=>v.charCodeAt(0)); |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
382 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
383 if (bytes.length < 5) { |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
384 throw 'message too short'; |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
385 } |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
386 |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
387 // первые 5 байт являются фреймом gRPC (сжатие + длина) |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
388 var head = bytes.splice(0, 5); |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
389 |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
390 // проверка правильной длины сообщения |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
391 var len = (head[1] << 24) |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
392 + (head[2] << 16) |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
393 + (head[3] << 8) |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
394 + head[4]; |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
395 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
396 if (len != bytes.length) { |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
397 throw 'header length mismatch'; |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
398 } |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
399 |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
400 // вызов protobufjs для декодирования сообщения |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
401 var response = pb.helloworld.HelloReply.decode(bytes); |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
402 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
403 console.log('Reply is:' + response.message); |
2489
bda080989b6c
Fixed indentation and braces in njs example.
Vladimir Homutov <vl@nginx.com>
parents:
2481
diff
changeset
|
404 } |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
405 </example> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
406 </para> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
407 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
408 </section> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
409 |
2576
4c8d0b37932d
Corrected syntax and style of "Using node modules with njs".
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2489
diff
changeset
|
410 |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
411 <section id="dnspacket" name="Пакет DNS"> |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
412 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
413 <para> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
414 В примере используется библиотека для создания и парсинга пакетов DNS. |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
415 Эта библиотека, а также её зависимости, |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
416 использует современные языковые конструкции, не поддерживаемые в njs. |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
417 Для поддержки таких конструкций |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
418 потребуется дополнительный шаг: транспилирование исходного кода. |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
419 </para> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
420 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
421 <para> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
422 Необходимо установить дополнительные пакеты node: |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
423 <example> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
424 $ npm install @babel/core @babel/cli @babel/preset-env babel-loader |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
425 $ npm install webpack webpack-cli |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
426 $ npm install buffer |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
427 $ npm install dns-packet |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
428 </example> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
429 Файл конфигурации webpack.config.js: |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
430 <example> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
431 const path = require('path'); |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
432 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
433 module.exports = { |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
434 entry: './load.js', |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
435 mode: 'production', |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
436 output: { |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
437 filename: 'wp_out.js', |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
438 path: path.resolve(__dirname, 'dist'), |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
439 }, |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
440 optimization: { |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
441 minimize: false |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
442 }, |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
443 node: { |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
444 global: true, |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
445 }, |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
446 module : { |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
447 rules: [{ |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
448 test: /\.m?js$$/, |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
449 exclude: /(bower_components)/, |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
450 use: { |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
451 loader: 'babel-loader', |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
452 options: { |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
453 presets: ['@babel/preset-env'] |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
454 } |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
455 } |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
456 }] |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
457 } |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
458 }; |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
459 </example> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
460 В данном случае используется режим "<literal>production</literal>". |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
461 Конструкция "<literal>eval</literal>" не используется, так как |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
462 не поддерживается njs. |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
463 Точкой входа является файл <literal>load.js</literal>: |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
464 <example> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
465 global.dns = require('dns-packet') |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
466 global.Buffer = require('buffer/').Buffer |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
467 </example> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
468 Сначала необходимо создать единый файл для библиотек, как в предыдущих примерах: |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
469 <example> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
470 $ npx browserify load.js -o bundle.js -d |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
471 </example> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
472 Затем необходимо обработать утилитой webpack, что также запускает babel: |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
473 <example> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
474 $ npx webpack --config webpack.config.js |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
475 </example> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
476 Команда создаёт файл <literal>dist/wp_out.js</literal>, являющийся |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
477 трансплицированной версией <literal>bundle.js</literal>. |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
478 Далее необходимо объединить этот файл с <literal>code.js</literal>, |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
479 хранящим код: |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
480 <example> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
481 function set_buffer(dnsPacket) |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
482 { |
2489
bda080989b6c
Fixed indentation and braces in njs example.
Vladimir Homutov <vl@nginx.com>
parents:
2481
diff
changeset
|
483 // create DNS packet bytes |
bda080989b6c
Fixed indentation and braces in njs example.
Vladimir Homutov <vl@nginx.com>
parents:
2481
diff
changeset
|
484 var buf = dnsPacket.encode({ |
bda080989b6c
Fixed indentation and braces in njs example.
Vladimir Homutov <vl@nginx.com>
parents:
2481
diff
changeset
|
485 type: 'query', |
bda080989b6c
Fixed indentation and braces in njs example.
Vladimir Homutov <vl@nginx.com>
parents:
2481
diff
changeset
|
486 id: 1, |
bda080989b6c
Fixed indentation and braces in njs example.
Vladimir Homutov <vl@nginx.com>
parents:
2481
diff
changeset
|
487 flags: dnsPacket.RECURSION_DESIRED, |
bda080989b6c
Fixed indentation and braces in njs example.
Vladimir Homutov <vl@nginx.com>
parents:
2481
diff
changeset
|
488 questions: [{ |
bda080989b6c
Fixed indentation and braces in njs example.
Vladimir Homutov <vl@nginx.com>
parents:
2481
diff
changeset
|
489 type: 'A', |
bda080989b6c
Fixed indentation and braces in njs example.
Vladimir Homutov <vl@nginx.com>
parents:
2481
diff
changeset
|
490 name: 'google.com' |
bda080989b6c
Fixed indentation and braces in njs example.
Vladimir Homutov <vl@nginx.com>
parents:
2481
diff
changeset
|
491 }] |
bda080989b6c
Fixed indentation and braces in njs example.
Vladimir Homutov <vl@nginx.com>
parents:
2481
diff
changeset
|
492 }) |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
493 |
2489
bda080989b6c
Fixed indentation and braces in njs example.
Vladimir Homutov <vl@nginx.com>
parents:
2481
diff
changeset
|
494 return buf; |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
495 } |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
496 </example> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
497 В данном примере генерируемый код не обёрнут в функцию, |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
498 явного вызова не требуется. |
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
499 Результат доступен в каталоге "<literal>dist</literal>": |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
500 <example> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
501 $ cat dist/wp_out.js code.js > njs_dns_bundle.js |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
502 </example> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
503 Далее осуществляется вызов кода в конце файла: |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
504 <example> |
2592
fca42223b9fc
Fixed example in the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
2577
diff
changeset
|
505 var b = set_buffer(global.dns); |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
506 console.log(b); |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
507 </example> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
508 И затем выполнение кода при помощи node: |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
509 <example> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
510 $ node ./njs_dns_bundle_final.js |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
511 Buffer [Uint8Array] [ |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
512 0, 1, 1, 0, 0, 1, 0, 0, |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
513 0, 0, 0, 0, 6, 103, 111, 111, |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
514 103, 108, 101, 3, 99, 111, 109, 0, |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
515 0, 1, 0, 1 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
516 ] |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
517 </example> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
518 Тестирование и запуск кода вместе с njs: |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
519 <example> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
520 $ njs ./njs_dns_bundle_final.js |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
521 Uint8Array [0,1,1,0,0,1,0,0,0,0,0,0,6,103,111,111,103,108,101,3,99,111,109,0,0,1,0,1] |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
522 </example> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
523 </para> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
524 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
525 <para> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
526 Ответ можно распарсить следующим способом: |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
527 <example> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
528 function parse_response(buf) |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
529 { |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
530 var bytes = buf.split('').map(v=>v.charCodeAt(0)); |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
531 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
532 var b = global.Buffer.from(bytes); |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
533 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
534 var packet = dnsPacket.decode(b); |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
535 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
536 var resolved_name = packet.answers[0].name; |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
537 |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
538 // ожидаемое имя 'google.com', согласно запросу выше |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
539 } |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
540 </example> |
2577
67fd664e2612
Translated "Using node modules with njs" into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2576
diff
changeset
|
541 |
2480
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
542 </para> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
543 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
544 </section> |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
545 |
73d254c3376d
Added the "Using node modules with njs" article.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
546 </article> |