https://github.com/tw00/nodemon-remote
Node.js remote control to be used with containers during development
https://github.com/tw00/nodemon-remote
Last synced: 25 days ago
JSON representation
Node.js remote control to be used with containers during development
- Host: GitHub
- URL: https://github.com/tw00/nodemon-remote
- Owner: tw00
- License: mit
- Created: 2021-12-14T14:04:34.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-12-15T11:48:30.000Z (over 3 years ago)
- Last Synced: 2025-04-28T07:22:37.169Z (about 1 month ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/nodemon-remote
- Size: 747 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Nodemon-Remote
![]()
Drop-in replacement for [nodemon](https://nodemon.io/) with HTTP remote control and support for custom commands.
## Application: Ephemeral environments
- Run your node app with `nodemon-remote` in your deployed environment and instantly switch to branches and new commits without the need to re-deploy
- `nodemon-remomte` supports Github Webhooks. Once a configurable label (`"preview"` by default) is assigned to a PR, the remote container will automatically switch to the latest commit of the corresponding branch
- ⚠️ WARNING ⚠️ Using `nodemon-remote` is potentially dangenrous. Make sure to use a strong access key and don't use `nodemon-remote` in production.## How to use it
### Installation
```bash
npm install --save nodemon # install nodemon as peer dependency
npm install --save nodemon-remote
# or
npm install -g nodemon
npx nodemon-remote
```### Create a config: `.remoterc.js`
```js
module.exports = {
port: 2020,
access_key: "MY_SECRET_ACCESS_KEY",
commands: {
// Custom commands (arguments are always escaped)
checkout: { cmd: "git checkout '${branch}'" },
fetch: { cmd: "git fetch --all" },
// Define multiple commands
pullAndInstall: {
cmd: [
"git pull origin '${branch}'"
"npm ci"
]
},
},
};
```For safety reasons the following characters are removed from arguments:
` " $ & ' ( ) * ; < > ? [ \ ] `` { | } ~ space tab new-line `### Send custom remote command
```bash
curl -X POST \
http://:2020/
--header "Authorization: BEARER " \
--data '{ "cmd": "checkout", "branch": "main" }'
```### Send nodemon restart command
```bash
curl -X POST \
http://:2020/
--header "Authorization: BEARER " \
--data '{ "cmd": "nodemon:restart" }'
```Available build-in commands:
- `nodemon:restart`: Restart nodemon
- `nodemon:reset`: Resets all settings### Github Webhook Integration
Trigger commands based on a configurable label.
Example: Any PR that has the "preview" label assigned
and that code is pushed to will get checked out in the remote container.```js
module.exports = {
// ...
webhook: {
label: "preview",
// Commands will run, if a PR with the label above is modified
cmd: [
"git fetch --all",
"git checkout '${ref}'",
"npm ci",
"nodemon:restart",
],
},
};
```1. Got to webhook settings (`https://github.com///settings/hooks/new`)
2. Enter payload URL:
```
http://:2020/webhook
```3. Select `application/json` and enter secret

4. Select `Let me select individual events.`
5. Enable `Pull requests` only

6. Hit `Add Webhook`
7. Assign label configured in `config.webhook.label` (e.g. `"preview"`) to PR