aboutsummaryrefslogtreecommitdiffhomepage
path: root/support/doc
diff options
context:
space:
mode:
Diffstat (limited to 'support/doc')
-rw-r--r--support/doc/tools.md131
1 files changed, 131 insertions, 0 deletions
diff --git a/support/doc/tools.md b/support/doc/tools.md
index 8efb0c13d..0df8c9f6c 100644
--- a/support/doc/tools.md
+++ b/support/doc/tools.md
@@ -206,3 +206,134 @@ To fix this, you have to run:
206``` 206```
207$ sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run update-host 207$ sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run update-host
208``` 208```
209
210### REPL ([Read Eval Print Loop](https://nodejs.org/docs/latest-v8.x/api/repl.html))
211
212If you want to interact with the application libraries and objects, there is a REPL for that.
213
214usage: `node ./dist/server/tools/repl.js`
215
216"The default evaluator will, by default, assign the result of the most recently evaluated expression to the special variable `_` (underscore). Explicitly setting `_` to a value will disable this behavior."
217
218- type `.help` to list commands available in the repl, notice it starts with a dot
219- type `.exit` to exit, note that you still have to press CTRL-C to actually exit, or press CTRL-C (3 times) without typing `.exit` to exit
220- type `context` to list all available objects and libraries in the context, note: `Promise` is also available but it's not listed in the context, in case you need promises for something
221- type `env` to see the loaded environment variables
222- type `path` to access path library
223- type `lodash` to access lodash library
224- type `uuidv1` to access uuid/v1 library
225- type `uuidv3` to access uuid/v3 library
226- type `uuidv4` to access uuid/v4 library
227- type `uuidv5` to access uuid/v5 library
228- type `YoutubeDL` to access youtube-dl library
229- type `cli` to access the cli helpers object
230- type `logger` to access the logger; if you log to it, it will write to stdout and to the peertube.log file
231- type `constants` to access the constants loaded by the server
232- type `coreUtils` to access the core-utils helpers object
233- type `ffmpegUtils` to access the ffmpeg-utils helpers object
234- type `peertubeCryptoUtils` to access the peertube-crypto helpers object
235- type `signupUtils` to access the signup helpers object
236- type `utils` to access the utils helpers object
237- type `YoutubeDLUtils` to access the youtube-dl helpers object
238- type `sequelizeTypescript` to access sequelizeTypescript
239- type `modelsUtils` to access the models/utils
240- type `models` to access the shortcut to sequelizeTypescript.models
241- type `transaction` to access the shortcut to sequelizeTypescript.transaction
242- type `query` to access the shortcut to sequelizeTypescript.query
243- type `queryInterface` to access the shortcut to sequelizeTypescript.queryInterface
244
245#### .help
246
247```
248PeerTube [1.0.0] (b10eb595)> .help
249.break Sometimes you get stuck, this gets you out
250.clear Break, and also clear the local context
251.editor Enter editor mode
252.exit Exit the repl
253.help Print this help message
254.load Load JS from a file into the REPL session
255.r Reset REPL
256.reset Reset REPL
257.save Save all evaluated commands in this REPL session to a file
258PeerTube [1.0.0] (b10eb595)>
259```
260
261#### Lodash example
262
263```
264PeerTube [1.0.0] (b10eb595)> lodash.keys(context)
265[ 'global',
266 'console',
267 'DTRACE_NET_SERVER_CONNECTION',
268 'DTRACE_NET_STREAM_END',
269 'DTRACE_HTTP_SERVER_REQUEST',
270 'DTRACE_HTTP_SERVER_RESPONSE',
271 'DTRACE_HTTP_CLIENT_REQUEST',
272 'DTRACE_HTTP_CLIENT_RESPONSE',
273 'process',
274 'Buffer',
275 'clearImmediate',
276 'clearInterval',
277 'clearTimeout',
278 'setImmediate',
279 'setInterval',
280 'setTimeout',
281 'XMLHttpRequest',
282 'compact2string',
283 'module',
284 'require',
285 'path',
286 'repl',
287 'context',
288 'env',
289 'lodash',
290 'uuidv1',
291 'uuidv3',
292 'uuidv4',
293 'uuidv5',
294 'cli',
295 'logger',
296 'constants',
297 'Sequelize',
298 'sequelizeTypescript',
299 'modelsUtils',
300 'models',
301 'transaction',
302 'query',
303 'queryInterface',
304 'YoutubeDL',
305 'coreUtils',
306 'ffmpegUtils',
307 'peertubeCryptoUtils',
308 'signupUtils',
309 'utils',
310 'YoutubeDLUtils' ]
311PeerTube [1.0.0] (b10eb595)>
312```
313
314#### YoutubeDL example
315```
316YoutubeDL.getInfo('https://www.youtube.com/watch?v=I5ZN289jjDo', function(err, data) {console.log(err, data)})
317```
318
319#### Models examples
320```
321PeerTube [1.0.0] (b10eb595)> new models.ActorModel({id: 3}).getVideoChannel().then(function(data){console.log(data.dataValues.name)})
322Promise {
323 _bitField: 0,
324 _fulfillmentHandler0: undefined,
325 _rejectionHandler0: undefined,
326 _promise0: undefined,
327 _receiver0: undefined }
328PeerTube [1.0.0] (b10eb595)> Main root channel
329PeerTube [1.0.0] (b10eb595)> let out; new models.UserModel({id: 1}).getAccount().then(function (data) {out = data.dataValues.id})
330Promise {
331 _bitField: 0,
332 _fulfillmentHandler0: undefined,
333 _rejectionHandler0: undefined,
334 _promise0: undefined,
335 _receiver0: undefined }
336PeerTube [1.0.0] (b10eb595)> out
3372
338PeerTube [1.0.0] (b10eb595)>
339```