Codehooks CLI Documentation
Version: 1.2.25
Command-line interface for Codehooks.io - A serverless backend platform
Quick Start
Installation
npm install -g codehooks
Basic Usage
# Login to your account
codehooks login
# Create a new project
codehooks create my-project
# Deploy your code
codehooks deploy
Commands by Category
Admin Tools
| Command | Description |
|---|---|
admin | Open the codehooks.io admin account UI at account.codehooks.io |
admintokens | Show active admintokens for account or team |
add-admintoken | Add admin token to account or team (for use with CI) |
remove-admintoken | Remove admin token from account or team |
Getting Started
| Command | Description |
|---|---|
docs | Open the codehooks.io documentation |
login | Authenticate CLI - sign up and/or sign in |
logout | Log out of the CLI |
account | Show info about account, projects and invitations |
Project Management
| Command | Description |
|---|---|
invite | Invite user to project |
join | Join project |
leave | Leave project |
create | Create a new codehooks project |
init | Link an existing Codehooks project to the current folder |
add | Add new space to project |
use | Set active space |
info | Show info about project and spaces |
remove-project | Remove the project |
Monitoring & Stats
| Command | Description |
|---|---|
stats | Show usage metrics for project spaces |
log (logs) | Show system logs for a space. |
workflow-status (wfstat) | Visualize workflow data from workflowdata collection |
File Management
| Command | Description |
|---|---|
file-upload (up, upload) | Upload files to server |
file-delete (delete) | Delete a file from server |
file-list (files) | List files from server |
Deployment
| Command | Description |
|---|---|
verify (compile, ver, comp) | Compile code (defaults to current dir) |
deploy (de, dep) | Deploys current codehook folder |
undeploy (unde, undep) | Undeploy current codehook folder |
install (inst, i) | Install a template application |
Data Operations
| Command | Description |
|---|---|
count (co) | Count objects in a collection in current space |
query (q) | Run query on collection in current space |
createindex (index, idx, create-index) | Add field(s) to a query index |
dropindex (removeindex, remove-index, rmindex, delete-index) | Remove field(s) from a query index |
import (imp) | Import JSON or CSV data from file |
export | Export JSON or CSV data |
Key-Value Store
| Command | Description |
|---|---|
get | Retrieve key-value pair(s) from a space |
set | Set key-value pair in a space |
del | Delete key-value pair in a space |
Database & Collections
| Command | Description |
|---|---|
collection (coll, col, ls) | Show collections for space |
createcollection (createcoll, add-collection) | Create a new collection |
dropcollection (dropcoll, rmcoll, deletecoll) | Delete all data in collection and remove collection name |
add-schema (schema, create-schema) | Add a JSON schema to a collection |
remove-schema (delete-schema, del-schema) | Remove JSON schema for a collection |
cap-collection (cap, cap-coll, capcoll) | Cap a collection |
uncap-collection (uncap) | Remove cap on a collection |
Security & Access
| Command | Description |
|---|---|
add-token | Add token to space |
remove-token | Remove token from space |
set-env | Set environment variable for space |
remove-env | Remove environment variable from space |
jwks | Set/replace JWKS endpoint for OAuth2 authentication. Set to "" (empty string) to remove. |
whitelist | Add host to whitelist (use to restrict space access) |
whitelist-remove | Remove host from whitelist |
Other
| Command | Description |
|---|---|
completion | Generate command completion script. Just add this to your .bashrc, .bash_profile, .zshrc (or similar) on *nix machines |
Space Management
| Command | Description |
|---|---|
remove-space | Remove space and data |
Global Options
These options are available for all commands:
| Option | Description |
|---|---|
-d, --debug | Show debug (verbose) information |
-h, --help | Show help |
-v, --version | Show version number |
Command Reference
Admin Tools
admin
Open the codehooks.io admin account UI at account.codehooks.io
admintokens
Show active admintokens for account or team
add-admintoken
Add admin token to account or team (for use with CI)
remove-admintoken
Remove admin token from account or team
Getting Started
docs
Open the codehooks.io documentation
login
Authenticate CLI - sign up and/or sign in
logout
Log out of the CLI
Options:
| Option | Description |
|---|---|
--dir | [default: "."] |
account
Show info about account, projects and invitations
Project Management
invite
Invite user to project
Options:
| Option | Description |
|---|---|
--projectname | Project name [required] |
-t, --email | [string] [required] |
--role | [string] [default: "ADMIN"] |
--remove | remove invitation [boolean] |
join
Join project
Options:
| Option | Description |
|---|---|
--projectname | Project name [required] |
leave
Leave project
Options:
| Option | Description |
|---|---|
--projectname | Project name [required] |
create
Create a new codehooks project
Options:
| Option | Description |
|---|---|
-n, --projectname | Project name |
--description | A few words about this project |
-t, --teamid | Add project to team with this id |
--template | Template to use (e.g., "slack-memory-bot") or "default" for CRUD template [string] |
--here | Create project in current folder instead of new subfolder [boolean] [default: false] |
-e, --empty | Only create config.json, skip generating code files [boolean] [default: false] |
--no-deploy | Skip automatic deployment of default template [boolean] [default: false] |
-g, --ga-deploy | Add Github Action for automatic deploy [boolean] |
-y, --yes | Skip all prompts and use defaults (non-interactive mode) [boolean] |
Examples:
codehooks create myapp Create a new project interactively
codehooks create myapp --yes Create with defaults, no prompts
codehooks create myapp --here Create in current folder
codehooks create myapp --empty Create config only, no code files
codehooks create myapp --here --empty Create config in current folder
codehooks create myapp --template slack-memory-bot Create with a specific template
codehooks create myapp --teamid abc123 --yes Create in team, non-interactive
codehooks create myapp --no-deploy Create without deploying
init
Link an existing Codehooks project to the current folder
Options:
| Option | Description |
|---|---|
-n, --projectname | Project name |
-s, --space | Space (environment) name [default: "dev"] |
-e, --empty | Only create the project config file [boolean] |
--download | Download source code from project [boolean] [default: true] |
Examples:
codehooks init
codehooks init --empty
codehooks init --download
add
Add new space to project
Options:
| Option | Description |
|---|---|
--projectname | [required] |
-n, --space | space name [required] |
--restricted | only team admins or owner can use if restricted [boolean] |
use
Set active space
Options:
| Option | Description |
|---|---|
--projectname | [required] |
-n, --name |
info
Show info about project and spaces
Options:
| Option | Description |
|---|---|
--projectname | Active project [required] |
--json | Output info as JSON (not table) [boolean] |
--space | Only show info for this space [string] |
-e, --examples | Include cURL examples [boolean] |
remove-project
Remove the project
Options:
| Option | Description |
|---|---|
-p, --projectname | Project name [string] [required] |
Monitoring & Stats
stats
Show usage metrics for project spaces
Options:
| Option | Description |
|---|---|
-p, --project | Select which project to query |
--space | Only show info for this space [string] |
--json | Output info as json [boolean] |
log
Aliases: logs
Show system logs for a space.
Options:
| Option | Description |
|---|---|
-p, --project | Select which project name to use |
-s, --space | Select which space to log |
-t, --tail | Chop log to n lines [default: 100] |
-f, --follow | Keep log stream open |
-c, --context | Filter log on: jobhooks, queuehooks, routehooks, datahooks, auth |
--admintoken | Use admin token authentication (use for CI) |
Examples:
codehooks log
codehooks log -f
codehooks coho log --tail 10
workflow-status
Aliases: wfstat
Visualize workflow data from workflowdata collection
Options:
| Option | Description |
|---|---|
-p, --project | Select which project to query |
-s, --space | Select which space to query |
-f, --format | Output format [string] [choices: "json", "markdown", "html", "ascii"] [default: "ascii"] |
-a, --active | Show only active (running) workflows [boolean] [default: false] |
-i, --detailed | Show detailed Instance Status table (default is summary only) [boolean] [default: false] |
-v, --verbose | Show version number [boolean] [default: false] |
File Management
file-upload
Aliases: up, upload
Upload files to server
Options:
| Option | Description |
|---|---|
-f, --src | Path to directory or file [default: "."] |
-t, --target | Target directory on server, same as local if not set |
-e, --ext | Include files matching the extension [string] |
--space | Select which space (environment) to access |
-p, --projectname | Select which project name to use |
--admintoken | Use admin token authentication (use for CI) |
--dryrun | Output files to upload without performing the action [boolean] |
Examples:
codehooks file-upload './static'
codehooks file-upload --src './local' --target '/remote'
codehooks file-upload --src './local' --target '/remote' --ext 'png'
codehooks file-upload --src './local' --target '/remote' --ext 'png|jpg|jpeg|gif'
codehooks file-upload afile.txt
file-delete
Aliases: delete
Delete a file from server
Options:
| Option | Description |
|---|---|
-f, --filename | Delete file with match on absolute path/filename |
-r, --match | Delete multiple file that matches regular expression to a file path |
--space | Select which space (environment) to access |
-p, --projectname | Select which project name to use |
--admintoken | Use admin token authentication (use for CI) |
--dryrun | Output files to upload without performing the action [boolean] |
Examples:
codehooks file-delete --filename '/static/myfile.txt'
codehooks file-delete --match '/static/*'
codehooks file-delete --match '.css$'
file-list
Aliases: files
List files from server
Options:
| Option | Description |
|---|---|
-f, --path | Path to directory or file [default: "."] |
--space | Select which space (environment) to access |
-p, --project | Select which project name to use |
--admintoken | Use admin token authentication (use for CI) |
--reverse | Scan index in reverse order |
--table | Output data as formatted table (not JSON) [boolean] |
--json | Output data as formatted JSON [boolean] |
Examples:
codehooks file-list '/static/'
Deployment
verify
Aliases: compile, ver, comp
Compile code (defaults to current dir)
Options:
| Option | Description |
|---|---|
--dir | [default: "."] |
--space | Select which space to access |
-p, --projectname | Select which project name to use |
--admintoken | Use admin token authentication (use for CI) |
-e, --main | Application main file, default is codehooks [default: "index"] |
--tofile | Output file path, writes to specified file when provided |
deploy
Aliases: de, dep
Deploys current codehook folder
Options:
| Option | Description |
|---|---|
--dir | [default: "."] |
-s, --space | Select which space to access |
-p, --projectname | Select which project name to use |
--history | Show deployment history |
--rollback | Undo last deployment, set previous as active |
--json | Output JSON format |
--admintoken | Use admin token authentication (use for CI) |
--template | Deploy a pre defined code template |
--upload | Upload source code assets to codehooks.io this projects environment [boolean] [default: true] |
--compress | Compress source code assets before upload [boolean] [default: true] |
-e, --main | Application main file, default is codehooks [default: "index"] |
undeploy
Aliases: unde, undep
Undeploy current codehook folder
Options:
| Option | Description |
|---|---|
--dir | [default: "."] |
-s, --space | Select which space to access |
-p, --projectname | Select which project name to use |
--json | Output JSON format |
--admintoken | Use admin token authentication (use for CI) |
install
Aliases: inst, i
Install a template application
Options:
| Option | Description |
|---|---|
-t, --template | Template directory from Github repo with templates [string] |
--space | Select which space (environment) to access |
-p, --projectname | Select which project name to use |
--admintoken | Use admin token authentication (use for CI) |
Examples:
codehooks install Interactive template selection
codehooks install static-website-tailwindcss Install specific template
codehooks install --template slack-memory-bot Install with --template flag
Data Operations
count
Aliases: co
Count objects in a collection in current space
Options:
| Option | Description |
|---|---|
-p, --project | Select which project to query |
-s, --space | Select which space to query |
-c, --collection | Collection name [required] |
--admintoken | Use admin token authentication (use for CI) |
query
Aliases: q
Run query on collection in current space
Options:
| Option | Description |
|---|---|
-p, --project | Select which project to query |
-s, --space | Select which space to query |
-q, --query | Limit selection with a query expression or JSON string '{...}' [default: ""] |
-n, --count | Count query results |
-c, --collection | Collection name [required] |
--delete | Delete all items from query result |
--update | Patch all items from query result with JSON string '{...}' [string] |
--replace | Replace all items from query result with JSON string '{...}' [string] |
--useindex | Use an indexed field to scan data in query [string] |
--start | Start value for index scan [string] |
--end | End value for index scan [string] |
--limit | Limit query result [number] |
--fields | Comma separated list of fields to include [string] |
--sort | Comma separated list of fields to sort by [string] |
--offset | Skip items before returning data in query result [number] |
--enqueue | Add query result to queue topic [string] |
--pretty | Output data with formatting and colors |
--reverse | Scan index in reverse order |
--table | Output data as formatted table (not JSON) [boolean] |
--csv | Output data in CSV format [boolean] |
--jsonl | Output as JSON Lines (one JSON object per line) [boolean] |
--admintoken | Use admin token authentication (use for CI) |
Examples:
codehooks query pets name=Polly
codehooks query --collection pets --query 'name=Polly&type=Parrot'
codehooks query --collection pets --query 'name=/^po/'
codehooks query --collection pets --query 'name=/^po/' --sort 'age,name'
codehooks query pets 'name=Polly' --useindex name --fields 'name,type'
codehooks q pets 'name=Polly&type=Parrot' --update '{"name": "Zilla"}'
codehooks q pets 'type=Fish' --delete
codehooks q pets 'type=Snake' --enqueue 'mytopic'
codehooks q pets --jsonl
codehooks query pets --q '{"type":"Dog"}' --project petsdb-5544 --space dev
createindex
Aliases: index, idx, create-index
Add field(s) to a query index
Options:
| Option | Description |
|---|---|
-p, --project | Select which project to use |
-s, --space | Select which space to use |
-c, --collection | Collection with indexes [required] |
-i, --index | Field to index [required] |
--admintoken | Use admin token authentication (use for CI) |
Examples:
codehooks createindex --collection pets --index name
codehooks idx pets name
codehooks idx pets -i name -i type -i 'price-in-dollar'
dropindex
Aliases: removeindex, remove-index, rmindex, delete-index
Remove field(s) from a query index
Options:
| Option | Description |
|---|---|
-p, --project | Select which project to use |
-s, --space | Select which space to use |
-c, --collection | Collection with indexes [required] |
-i, --index | Field to remove index for [required] |
--admintoken | Use admin token authentication (use for CI) |
Examples:
codehooks removeindex pets name
codehooks removeindex --collection pets --index 'name' --index 'type'
import
Aliases: imp
Import JSON or CSV data from file
Options:
| Option | Description |
|---|---|
-p, --project | Project name [string] [required] |
-s, --space | A space in your project [string] |
-c, --collection | A collection in a Space [string] [required] |
-f, --filepath | File to import [string] [required] |
--separator | Field separator character, default is ',', also normal with '\t' or ';' [string] [default: ","] |
--dryrun | Test only, will not import any data [boolean] [default: false] |
--rowcount | Add a row count field to each imported record [boolean] [default: false] |
--admintoken | Use admin token authentication (use for CI) |
--local | Import data to local development server on port parameter [number] |
--encoding | String encoding to use, latin1, utf8, ascii, hex, ucs2 [string] [default: "utf8"] |
Examples:
codehooks import ./myfile.csv mycollection
codehooks import --filepath ./myfile.csv --collection mycollection
codehooks import -f ./myfile.json -c mycollection
codehooks import -f ./myfile.csv -c mycollection --separator ';' --encoding 'latin1'
export
Export JSON or CSV data
Options:
| Option | Description |
|---|---|
-p, --project | Project name [string] [required] |
-s, --space | a space name in your project [string] |
--collection | A collection in the space [string] [required] |
-f, --filepath | Filename to save export data [string] |
--csv | Export to CSV [boolean] |
--jsonl | Export to JSONL (JSON Lines) [boolean] |
--admintoken | Use admin token authentication (use for CI) |
Key-Value Store
get
Retrieve key-value pair(s) from a space
Options:
| Option | Description |
|---|---|
-p, --project | Select which project to use |
-s, --space | Select which space to query |
-k, --key | Key to match, or key* to fetch list [default: "*"] |
--keyspace | Keyspace to scan |
--text | Output info as text line [boolean] |
--jsonl | Output as JSON Lines (one JSON object per line) [boolean] |
--onlycount | Output only the count of keys [boolean] |
--admintoken | Use admin token authentication (use for CI) |
Examples:
codehooks get 'my-value-one'
codehooks get 'my*'
codehooks get '*' --keyspace spacex
codehooks get 'my*' --text
codehooks get 'my*' --jsonl
codehooks get 'my*' --onlycount
set
Set key-value pair in a space
Options:
| Option | Description |
|---|---|
-p, --project | Select which project to use [string] |
-s, --space | Select which space to use [string] |
--key | Key to set [string] [required] |
--val | Value to set [string] [required] |
--keyspace | Keyspace to use [string] |
--ttl | Time to live in millis for value [number] |
--json | Output info as JSON [boolean] |
--admintoken | Use admin token authentication (use for CI) |
Examples:
codehooks set 'my-value-one' 'foo'
codehooks set 'my-value-two' 'bar'
codehooks set 'session-4f51-9bed' 'OK' --keyspace 'spacex' --ttl 60000
del
Delete key-value pair in a space
Options:
| Option | Description |
|---|---|
-p, --project | Select which project to use |
-s, --space | Select which space to use |
--key | Key to delete [required] |
--keyspace | Keyspace to use |
--json | Output info as JSON [boolean] |
--admintoken | Use admin token authentication (use for CI) |
Examples:
codehooks del 'my-value-one'
codehooks del 'my-value-two' --keyspace 'spacex'
Database & Collections
collection
Aliases: coll, col, ls
Show collections for space
Options:
| Option | Description |
|---|---|
-p, --project | Select which project to query |
-s, --space | Select which space to query |
--json | JSON output format |
--sys | Show system collections [boolean] |
--admintoken | Use admin token authentication (use for CI) |
createcollection
Aliases: createcoll, add-collection
Create a new collection
Options:
| Option | Description |
|---|---|
-p, --project | Select which project to use |
-s, --space | Select which space to use |
--collection | Collection name [required] |
--admintoken | Use admin token authentication (use for CI) |
--cap | Cap collection to max documents |
--capdelay | Delay capping to millis |
Examples:
codehooks createcollection pets
codehooks createcollection logs --cap 5000
dropcollection
Aliases: dropcoll, rmcoll, deletecoll
Delete all data in collection and remove collection name
Options:
| Option | Description |
|---|---|
-p, --project | Select which project to use |
-s, --space | Select which space to use |
--collection | Collection name [required] |
--admintoken | Use admin token authentication (use for CI) |
Examples:
codehooks dropcollection pets
add-schema
Aliases: schema, create-schema
Add a JSON schema to a collection
Options:
| Option | Description |
|---|---|
-p, --project | Select which project to use |
-s, --space | Select which space to use |
--collection | Collection name [required] |
--admintoken | Use admin token authentication (use for CI) |
--schema | Path to file with JSON schema for collection [required] |
Examples:
codehooks add-schema --collection 'person' --schema './personSchema.json'
remove-schema
Aliases: delete-schema, del-schema
Remove JSON schema for a collection
Options:
| Option | Description |
|---|---|
-p, --project | Select which project to use |
-s, --space | Select which space to use |
--collection | Collection name [required] |
--admintoken | Use admin token authentication (use for CI) |
Examples:
codehooks remove-schema --collection 'person'
cap-collection
Aliases: cap, cap-coll, capcoll
Cap a collection
Options:
| Option | Description |
|---|---|
-p, --project | Select which project to use |
-s, --space | Select which space to use |
--collection | Collection name [required] |
--admintoken | Use admin token authentication (use for CI) |
--cap | Cap collection to max documents [default: 1000] |
--capdelay | Delay capping to max millis [default: 1000] |
Examples:
codehooks capcollection --collection 'temperature' --cap 10000
uncap-collection
Aliases: uncap
Remove cap on a collection
Options:
| Option | Description |
|---|---|
-p, --project | Select which project to use |
-s, --space | Select which space to use |
--collection | Collection name [required] |
--admintoken | Use admin token authentication (use for CI) |
Examples:
codehooks uncap-collection --collection 'temperature'
Security & Access
add-token
Add token to space
Options:
| Option | Description |
|---|---|
--projectname | Project name [required] |
--space | A space in your project [required] |
--readonly | [boolean] [default: false] |
--description | [string] [default: ""] |
remove-token
Remove token from space
Options:
| Option | Description |
|---|---|
--projectname | Project name [required] |
--space | A space in your project [required] |
-t, --token | [string] [required] |
set-env
Set environment variable for space
Options:
| Option | Description |
|---|---|
--projectname | Project name [required] |
--space | A space in your project [required] |
--encrypted | [boolean] [default: false] |
--key | [string] [required] |
--value | [string] [required] |
remove-env
Remove environment variable from space
Options:
| Option | Description |
|---|---|
--projectname | Project name [required] |
--space | A space in your project [required] |
-k, --key | [string] [required] |
jwks
Set/replace JWKS endpoint for OAuth2 authentication. Set to "" (empty string) to remove.
Options:
| Option | Description |
|---|---|
--projectname | Project name [required] |
--space | A space in your project [required] |
--url | URL of JWKS endpoint (must be https) [string] [required] |
whitelist
Add host to whitelist (use to restrict space access)
Options:
| Option | Description |
|---|---|
--projectname | Project name [required] |
--space | A space in your project [required] |
--ip | IP address which should be allowed access to space [string] [required] |
whitelist-remove
Remove host from whitelist
Options:
| Option | Description |
|---|---|
--projectname | Project name [required] |
--space | A space in your project [required] |
--ip | The IP address to remove from the whitelist. [required] |
Other
completion
Generate command completion script. Just add this to your .bashrc, .bash_profile, .zshrc (or similar) on *nix machines
Space Management
remove-space
Remove space and data
Options:
| Option | Description |
|---|---|
--projectname | Project name |
--space | A space in your project [required] |
Additional Resources
- Documentation: https://codehooks.io/docs
- API Reference: https://codehooks.io/docs/api
- Examples: https://github.com/RestDB/codehooks-examples
- Support: [email protected]
License
MIT License - Copyright © Codehooks AS