From bf4425c772d157eee2fd7a1dcf34ff8688ec006d Mon Sep 17 00:00:00 2001 From: xshady <54737754+xxshady@users.noreply.github.com> Date: Fri, 15 Mar 2024 01:43:05 +0300 Subject: [PATCH] feat: add server debugging article (#309) --- docs/articles/debugging-server-code.md | 34 ++++++++++++++++++++++++++ docs/articles/toc.yml | 3 ++- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 docs/articles/debugging-server-code.md diff --git a/docs/articles/debugging-server-code.md b/docs/articles/debugging-server-code.md new file mode 100644 index 00000000..32468b3e --- /dev/null +++ b/docs/articles/debugging-server-code.md @@ -0,0 +1,34 @@ +# Debugging server code + +alt:V allows you to debug your server-side code just like you would do in [NodeJS](https://nodejs.org/en/learn/getting-started/debugging). + +## How? + +1. Enable inspector in `resource.toml`. + +```toml +type = 'js' +main = 'main.js' + +[inspector] +# You can also specify host and port if needed +# (127.0.0.1:9229 by default) +# host = '127.0.0.1' +# port = '9999' +``` + +2. Add NodeJS interval with 0 delay. + +```js +setInterval(() => {}, 0) +``` + +3. Now you should be able to connect to inspector via Chrome DevTools for example: + + 1. Open any webpage in Chrome + 2. Press f12 to open console + 3. Click on NodeJS icon + +Video tutorial: + + diff --git a/docs/articles/toc.yml b/docs/articles/toc.yml index a3392c46..5befd658 100644 --- a/docs/articles/toc.yml +++ b/docs/articles/toc.yml @@ -48,4 +48,5 @@ href: vehicle/train-api.md - name: Workers href: workers.md - +- name: Debugging server code + href: debugging-server-code.md