diff --git a/packages/docker/build/flecks.hooks.js b/packages/docker/build/flecks.hooks.js index 5b70846..232fc47 100644 --- a/packages/docker/build/flecks.hooks.js +++ b/packages/docker/build/flecks.hooks.js @@ -2,8 +2,12 @@ export const hooks = { /** * Define docker containers. * - * Beware: the user running the server must have Docker privileges. + * :::warning + * + * The user running the server must have Docker privileges. * See: https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user + * + * ::: */ '@flecks/docker.containers': () => ({ someContainer: { diff --git a/packages/web/build/flecks.hooks.js b/packages/web/build/flecks.hooks.js index ece001a..13ca694 100644 --- a/packages/web/build/flecks.hooks.js +++ b/packages/web/build/flecks.hooks.js @@ -6,13 +6,11 @@ export const hooks = { await youCanDoAsyncThingsHere(); }, /** - * Override flecks configuration sent to client flecks. + * Send configuration to clients. * @param {http.ClientRequest} req The HTTP request object. */ '@flecks/web.config': (req) => ({ - someClientFleck: { - someConfig: req.someConfig, - }, + someConfig: req.someConfig, }), /** * Define HTTP routes. diff --git a/website/docs/repl.mdx b/website/docs/repl.mdx index 87c7c76..b624e32 100644 --- a/website/docs/repl.mdx +++ b/website/docs/repl.mdx @@ -2,3 +2,83 @@ title: REPL description: Start a REPL server and connect to it. --- + +import Create from '@site/helpers/create'; + +flecks provides `@flecks/repl` to make it easy to run a +[REPL](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop) inside your running +application. `@flecks/repl` provides a [command](./cli#repl) to easily connect to your application. + +## Prerequisites + +In order to use it you will need to have [socat](https://manpages.org/socat). + +## Play with a REPL + +Let's create an application to test the REPL: + + + +``` +npx flecks add -d @flecks/repl +``` + +Start your application: + +``` +npm run start +``` + +It will just sit there. Open another terminal in the project directory and run the command: + +``` +npx flecks repl +``` + +:::tip + +For a more ergonomic experience, you may use: + +``` +npx flecks repl -r +``` + +If you have [rlwrap](https://manpages.org/rlwrap) installed. + +::: + +and you will be greeted with a prompt: + +``` +repl-test> +``` + +That's our application ID! We can run commands: + +```js +repl-test> flecks.get('@flecks/core') +{ id: 'repl-test' } +``` + +Confirm we're actually in our application by killing it: + +``` +repl-test> process.exit(0) +``` + +That will kick us back out to the terminal. If we try to run the command again, we'll get an error +that looks something like this: + +```bash +[...] socat[...] E connect(5, AF=1 "/tmp/flecks/repl-test/repl/repl-test-[...].sock", 57): Connection refused +``` + +This is because there's no application to connect to anymore. + +## Extend the REPL + +Your flecks can implement [@flecks/repl.commands](./flecks/hooks#flecksreplcommands) and/or +[@flecks/repl.context](./flecks/hooks#flecksreplcontext) to add context or commands to the REPL. + +For instance, `@flecks/passport-local` implements a command to easily create a user account in +the REPL. diff --git a/website/docs/sockets.mdx b/website/docs/sockets.mdx index d4fdc10..51c77ca 100644 --- a/website/docs/sockets.mdx +++ b/website/docs/sockets.mdx @@ -343,4 +343,4 @@ Send a string which will be assigned to `window.location.href`. socket.send(['Redirect', '/']); ``` -See [the generated hooks page](./flecks/@flecks/dox/hooks#fleckssocketpackets) for an exhaustive list of packets. +See [the generated hooks page](./flecks/hooks#fleckssocketpackets) for an exhaustive list of packets.