![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@seneca/repl
Advanced tools
Seneca REPL is a plugin for Seneca
A plugin that provides a REPL (Read-Execute-Print-Loop) for Seneca instances, very much like the standard Node.js command line REPL, with a some extra Seneca convenience commands.
![]() | This open source module is sponsored and supported by Voxgig. |
---|
Supports Seneca versions 3.x and higher.
This is Seneca plugin, so you'll also need the Seneca framework installed to use the REPL.
$ npm install seneca
$ npm install @seneca/repl
To use the REPL client on the command line, you should install globally:
$ npm i -g seneca @seneca/repl
$ seneca-repl # now works!
This plugin can provide a REPL for AWS Lambda functions (via
invoke
). You will need to install the AWS SDK so the REPL client can
use it to connect to your lambda function.
$ npm i -g @aws-sdk/client-lambda
Add the REPL as a plugin to your Seneca instance. By default the plugin will listen on localhost port 30303.
var Seneca = require('seneca')
var seneca = Seneca()
// open repl on default port 30303
.use('repl')
// open another repl on port 10001
.use('repl', {port: 10001})
// open yet another repl on a free port chosen by your OS
// look at the INFO level logs for the host and port
// or get them from seneca.export('repl/address')
.use('repl', {port: 0})
To access the REPL, run the seneca-repl
command provided by this
plugin.
$ seneca-repl
You can specify the target Seneca server using a URI
$ seneca-repl telnet://localhost:30303 # same as default
NOTE: If the connection drops, the seneca-repl
client will attempt
to reconnect at regular intervals. This means you can stop and start
your development server without needing to restart the REPL.
Skip ahead to the Commands section if this is all you need.
You can submit REPL commands using the message
sys:repl,send:cmd
. This message requires an id
property to
indicate the REPL instance to use:
const Seneca = require('seneca')
const seneca = Seneca()
.use('promisify') // npm install @seneca/promisify
.use('repl')
.act('sys:repl,use:repl,id:foo')
await seneca.ready()
let res = await seneca.post('sys:repl,send:cmd,id:foo', {
cmd: '1+1'
})
// Prints { ok: true, out:'4\n' }
console.log(res)
You can use this to expose a REPL connector in custom environments. This plugin provides a REPL over HTTP, and over AWS Lambda invocations. Review the implementation code for these if you want to write your own REPL connector.
Opening a local port is usually only possible for local development, so you can also expose the REPL via a HTTP endpoint. This can be useful to debug build or staging systems. This is NOT recommended for production.
WARNING This is a security risk. Your app will need to apply additional constraints to prevent arbitrary message submission via the REPL.
On the server, use the sys:repl,use:repl
message to start a new REPL
inside the Seneca instance. Do this on startup (without a REPL
instance, a REPL connection will not operate). You will need to
special an identifier for this REPL.
seneca.act('sys:repl,use:repl,id:web')
Next you will need to call the sys:repl,send:cmd
message when your
chosen HTTP endpoint for the REPL is called. For express, this might look like:
const Express = require('express')
const BodyParser = require('body-parser')
const Seneca = require('seneca')
const app = express()
const seneca = Seneca()
seneca
.use('repl')
.act('sys:repl,use:repl,id:web')
app.use(bodyParser.json())
// Accepts body = {cmd:'...repl cmd goes here...'}
app.post('/seneca-repl', (req, res) => {
const body = req.body
seneca.act(
{ sys: 'repl', send: 'cmd', id: 'web', cmd: body.cmd },
function (err, result) {
if (err) {
return res.status(500).json({ ok: false, error: err.message })
}
return res.json(result.out)
})
})
app.listen(8080)
On the command line, access the REPL using a HTTP URL:
$ seneca-repl http://localhost:8888/seneca-repl?id=web
By default, HTTP URLs with use web
as the identifier.
To expose a REPL from an AWS Lambda function using Seneca, use the set up code for the HTTP example in the Lambda itself.
For the REPL client, you will need to install the
@aws-sdk/client-lambda
package, and correctly configure your AWS access using the
$AWS_PROFILE
environment variable.
Connect to your Lambda function REPL using:
seneca-repl "aws://lambda/FUNCTION?region=REGION&id=invoke"
where FUNCTION
is the name of the Lambda function,REGION
is the
AWS region, such as us-east-1
(the default). The default REPL id
value is invoke. NOTE: make sure to quote or escape the &
.
This mechanism uses AWS Lambda invocation mechanism and thus relies on AWS for security. Special care should be taken with Lambdas that are externally exposed to prevent external requests from calling the Seneca REPL messages.
WARNING This is a security risk. Your app will need to apply additional constraints to prevent arbitrary message submission via the REPL.
This can be useful to debug build or staging systems, but is NOT recommended for production, unless used with specifically access controlled Lambda functions.
The seneca-repl
command provides a convenient REPL interface
including line editing and history. In remote settings you'll want
to create an SSH tunnel or similar for this purpose.
Alternatively you can telnet to the port:
$ telnet localhost 30303
Replace localhost
if remote with the address of the remote system.
For more comfortable experience with working cursor keys, use rlwrap
$ rlwrap telnet localhost 30303
The repl evaluates JavaScript directly:
> 1+1
2
You also have a seneca
instance available:
> seneca.id
'SENECA-ID'
You can submit messages directly using jsonic format (JSON, but not strict!):
> role:seneca,cmd:stats
{
start: '2023-08-01T17:37:39.880Z',
act: { calls: 122, done: 121, fails: 8, cache: 0 },
actmap: undefined,
now: '2023-08-01T17:49:17.316Z',
uptime: 697436
}
This is very useful for local debugging.
To access entity data, use the list$
, load$
, save$
and remove$
commands:
> list$ foo
[
{ entity$: '-/-/foo', ...},
{ entity$: '-/-/foo', ...},
...
]
These all accept the parameters:
zone/base/name
{field:value,...}
NOTE: this is a Node.js REPL, so you also get some of the features of a Node.js REPL:
_
variableCtrl-A
, Ctrl-E
, etclist <pin>|plugin
:
<pin>
: list local message patterns, optionally narrowed by pin
(e.g. foo:1
)plugin
: list all plugins by full namefind <pin>|<plugin-name>
:
<pin
: find an exact matching message pattern definition (e.g. sys:entity,cmd:load
)<plugin-name>
: find a plugin definitionlist$ canon <query>
: list entity data (like seneca.entity(canon).list$(query)
)load$ canon <query>
: load entity data (like seneca.entity(canon).load$(query)
)save$ canon <data>
: save entity data (like seneca.entity(canon).save$(data)
)remove$ canon <query>
: remove entity data (like seneca.entity(canon).remove$(query)
)entity$ canon
: describe an entity (like seneca.entity(canon)
)stats
: print local statisticsstats full
: print full local statisticsexit
or quit
: exit the repl sessionlast
: run last command againset <path> <value>
: set a seneca option, e.g: set debug.deprecation true
get <path>
: get a seneca optionalias <name> <cmd>
: define a new aliaslog
: toggle printing of remote log entries in test format (NOTE: these are unfiltered)log match <literal>
: when logging is enabled, only print lines matching the provided literal stringdepth <number>
: set depth of Util.inspect printingThe command history is saved to text files in a .seneca
in your home
folder. History is unique to each target server. You can also add
additional URL parameters to isolate a server history:
$ seneca-repl localhost?project=foo # separate history for foo server
$ seneca-repl localhost?project=bar # separate history for bar server
test
: boolean falseSet plugin options when loading with:
seneca.use('repl', { name: value, ... })
Note: foo.bar
in the list above means
{ foo: { bar: ... } }
add:cmd,sys:repl
»Add a REPL command dynamically
echo:true,sys:repl
»No description provided.
send:cmd,sys:repl
»No description provided.
sys:repl,use:repl
»No description provided.
The Senecajs org encourages open participation. If you feel you can help in any way, be it with documentation, examples, extra testing, or new features please get in touch.
To run tests, simply use npm:
> npm run test
Copyright (c) 2015-2020, Richard Rodger and other contributors. Licensed under MIT.
FAQs
Provides a client and server REPL for Seneca microservice systems.
The npm package @seneca/repl receives a total of 254 weekly downloads. As such, @seneca/repl popularity was classified as not popular.
We found that @seneca/repl demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.