Skip to main content

Codehooks CLI Documentation

Version: 1.2.28

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

Getting Started

CommandDescription
docsOpen the codehooks.io documentation
loginAuthenticate CLI - sign up and/or sign in
logoutLog out of the CLI
accountShow info about account, projects and invitations

Project Management

CommandDescription
createCreate a new codehooks project
initLink an existing Codehooks project to the current folder
infoShow info about project and spaces
inviteInvite user to project
joinJoin project
leaveLeave project
remove-projectRemove the project

Space Management

CommandDescription
addAdd new space to project
useSet active space
remove-spaceRemove space and data

Deployment

CommandDescription
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

Database & Collections

CommandDescription
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

Data Operations

CommandDescription
query (q)Run query on collection in current space
count (co)Count objects in a collection in current space
import (imp)Import JSON or CSV data from file
exportExport JSON or CSV data
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

Key-Value Store

CommandDescription
getRetrieve key-value pair(s) from a space
setSet key-value pair in a space
delDelete key-value pair in a space

File Management

CommandDescription
file-upload (up, upload)Upload files to server
file-delete (delete)Delete a file from server
file-list (files)List files from server

Monitoring & Logs

CommandDescription
log (logs)Show system logs for a space.
statsShow usage metrics for project spaces
workflow-status (wfstat)Visualize workflow data from workflowdata collection
queue-status (qs, queues)Visualize queue status with item counts and workers

Security & Access

CommandDescription
add-tokenAdd token to space
remove-tokenRemove token from space
set-envSet environment variable for space
remove-envRemove environment variable from space
jwksSet/replace JWKS endpoint for OAuth2 authentication. Set to "" (empty string) to remove.
whitelistAdd host to whitelist (use to restrict space access)
whitelist-removeRemove host from whitelist

Admin Tools

CommandDescription
adminOpen the codehooks.io admin account UI at account.codehooks.io
admintokensShow active admintokens for account or team
add-admintokenAdd admin token to account or team (for use with CI)
remove-admintokenRemove admin token from account or team

Shell Integration

CommandDescription
completionGenerate command completion script. Just add this to your .bashrc, .bash_profile, .zshrc (or similar) on *nix machines

Global Options

These options are available for all commands:

OptionDescription
-d, --debugShow debug (verbose) information
-h, --helpShow help
-v, --versionShow version number

Command Reference

Getting Started

docs

Open the codehooks.io documentation


login

Authenticate CLI - sign up and/or sign in


logout

Log out of the CLI

Options:

OptionDescription
--dir[default: "."]

account

Show info about account, projects and invitations


Project Management

create

Create a new codehooks project

Options:

OptionDescription
-n, --projectnameProject name
--descriptionA few words about this project
-t, --teamidAdd project to team with this id
--templateTemplate to use (e.g., "slack-memory-bot") or "default" for CRUD template [string]
--hereCreate project in current folder instead of new subfolder [boolean] [default: false]
-e, --emptyOnly create config.json, skip generating code files [boolean] [default: false]
--no-deploySkip automatic deployment of default template [boolean] [default: false]
-g, --ga-deployAdd Github Action for automatic deploy [boolean]
-y, --yesSkip 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:

OptionDescription
-n, --projectnameProject name
-s, --spaceSpace (environment) name [default: "dev"]
-e, --emptyOnly create the project config file [boolean]
--downloadDownload source code from project [boolean] [default: true]

Examples:

codehooks init
codehooks init --empty
codehooks init --download

info

Show info about project and spaces

Options:

OptionDescription
--projectnameActive project [required]
--jsonOutput info as JSON (not table) [boolean]
--spaceOnly show info for this space [string]
-e, --examplesInclude cURL examples [boolean]

invite

Invite user to project

Options:

OptionDescription
--projectnameProject name [required]
-t, --email[string] [required]
--role[string] [default: "ADMIN"]
--removeremove invitation [boolean]

join

Join project

Options:

OptionDescription
--projectnameProject name [required]

leave

Leave project

Options:

OptionDescription
--projectnameProject name [required]

remove-project

Remove the project

Options:

OptionDescription
-p, --projectnameProject name [string] [required]

Space Management

add

Add new space to project

Options:

OptionDescription
--projectname[required]
-n, --spacespace name [required]
--restrictedonly team admins or owner can use if restricted [boolean]

use

Set active space

Options:

OptionDescription
--projectname[required]
-n, --name

remove-space

Remove space and data

Options:

OptionDescription
--projectnameProject name
--spaceA space in your project [required]

Deployment

verify

Aliases: compile, ver, comp

Compile code (defaults to current dir)

Options:

OptionDescription
--dir[default: "."]
--spaceSelect which space to access
-p, --projectnameSelect which project name to use
--admintokenUse admin token authentication (use for CI)
-e, --mainApplication main file, default is codehooks [default: "index"]
--tofileOutput file path, writes to specified file when provided

deploy

Aliases: de, dep

Deploys current codehook folder

Options:

OptionDescription
--dir[default: "."]
-s, --spaceSelect which space to access
-p, --projectnameSelect which project name to use
--historyShow deployment history
--rollbackUndo last deployment, set previous as active
--jsonOutput JSON format
--admintokenUse admin token authentication (use for CI)
--templateDeploy a pre defined code template
--uploadUpload source code assets to codehooks.io this projects environment [boolean] [default: true]
--compressCompress source code assets before upload [boolean] [default: true]
-e, --mainApplication main file, default is codehooks [default: "index"]

undeploy

Aliases: unde, undep

Undeploy current codehook folder

Options:

OptionDescription
--dir[default: "."]
-s, --spaceSelect which space to access
-p, --projectnameSelect which project name to use
--jsonOutput JSON format
--admintokenUse admin token authentication (use for CI)

install

Aliases: inst, i

Install a template application

Options:

OptionDescription
-t, --templateTemplate directory from Github repo with templates [string]
--spaceSelect which space (environment) to access
-p, --projectnameSelect which project name to use
--admintokenUse 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

Database & Collections

collection

Aliases: coll, col, ls

Show collections for space

Options:

OptionDescription
-p, --projectSelect which project to query
-s, --spaceSelect which space to query
--jsonJSON output format
--sysShow system collections [boolean]
--admintokenUse admin token authentication (use for CI)

createcollection

Aliases: createcoll, add-collection

Create a new collection

Options:

OptionDescription
-p, --projectSelect which project to use
-s, --spaceSelect which space to use
--collectionCollection name [required]
--admintokenUse admin token authentication (use for CI)
--capCap collection to max documents
--capdelayDelay 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:

OptionDescription
-p, --projectSelect which project to use
-s, --spaceSelect which space to use
--collectionCollection name [required]
--admintokenUse admin token authentication (use for CI)

Examples:

codehooks dropcollection pets

add-schema

Aliases: schema, create-schema

Add a JSON schema to a collection

Options:

OptionDescription
-p, --projectSelect which project to use
-s, --spaceSelect which space to use
--collectionCollection name [required]
--admintokenUse admin token authentication (use for CI)
--schemaPath 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:

OptionDescription
-p, --projectSelect which project to use
-s, --spaceSelect which space to use
--collectionCollection name [required]
--admintokenUse admin token authentication (use for CI)

Examples:

codehooks remove-schema --collection 'person'

cap-collection

Aliases: cap, cap-coll, capcoll

Cap a collection

Options:

OptionDescription
-p, --projectSelect which project to use
-s, --spaceSelect which space to use
--collectionCollection name [required]
--admintokenUse admin token authentication (use for CI)
--capCap collection to max documents [default: 1000]
--capdelayDelay capping to max millis [default: 1000]

Examples:

codehooks capcollection --collection 'temperature' --cap 10000

uncap-collection

Aliases: uncap

Remove cap on a collection

Options:

OptionDescription
-p, --projectSelect which project to use
-s, --spaceSelect which space to use
--collectionCollection name [required]
--admintokenUse admin token authentication (use for CI)

Examples:

codehooks uncap-collection --collection 'temperature'

Data Operations

query

Aliases: q

Run query on collection in current space

Options:

OptionDescription
-p, --projectSelect which project to query
-s, --spaceSelect which space to query
-q, --queryLimit selection with a query expression or JSON string '{...}' [default: ""]
-n, --countCount query results
-c, --collectionCollection name [required]
--deleteDelete all items from query result
--updatePatch all items from query result with JSON string '{...}' [string]
--replaceReplace all items from query result with JSON string '{...}' [string]
--useindexUse an indexed field to scan data in query [string]
--startStart value for index scan [string]
--endEnd value for index scan [string]
--limitLimit query result [number]
--fieldsComma separated list of fields to include [string]
--sortComma separated list of fields to sort by [string]
--offsetSkip items before returning data in query result [number]
--enqueueAdd query result to queue topic [string]
--prettyOutput data with formatting and colors
--reverseScan index in reverse order
--tableOutput data as formatted table (not JSON) [boolean]
--csvOutput data in CSV format [boolean]
--jsonlOutput as JSON Lines (one JSON object per line) [boolean]
--admintokenUse 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

count

Aliases: co

Count objects in a collection in current space

Options:

OptionDescription
-p, --projectSelect which project to query
-s, --spaceSelect which space to query
-c, --collectionCollection name [required]
--admintokenUse admin token authentication (use for CI)

import

Aliases: imp

Import JSON or CSV data from file

Options:

OptionDescription
-p, --projectProject name [string] [required]
-s, --spaceA space in your project [string]
-c, --collectionA collection in a Space [string] [required]
-f, --filepathFile to import [string] [required]
--separatorField separator character, default is ',', also normal with '\t' or ';' [string] [default: ","]
--dryrunTest only, will not import any data [boolean] [default: false]
--rowcountAdd a row count field to each imported record [boolean] [default: false]
--admintokenUse admin token authentication (use for CI)
--localImport data to local development server on port parameter [number]
--encodingString 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:

OptionDescription
-p, --projectProject name [string] [required]
-s, --spacea space name in your project [string]
--collectionA collection in the space [string] [required]
-f, --filepathFilename to save export data [string]
--csvExport to CSV [boolean]
--jsonlExport to JSONL (JSON Lines) [boolean]
--admintokenUse admin token authentication (use for CI)

createindex

Aliases: index, idx, create-index

Add field(s) to a query index

Options:

OptionDescription
-p, --projectSelect which project to use
-s, --spaceSelect which space to use
-c, --collectionCollection with indexes [required]
-i, --indexField to index [required]
--admintokenUse 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:

OptionDescription
-p, --projectSelect which project to use
-s, --spaceSelect which space to use
-c, --collectionCollection with indexes [required]
-i, --indexField to remove index for [required]
--admintokenUse admin token authentication (use for CI)

Examples:

codehooks removeindex pets name
codehooks removeindex --collection pets --index 'name' --index 'type'

Key-Value Store

get

Retrieve key-value pair(s) from a space

Options:

OptionDescription
-p, --projectSelect which project to use
-s, --spaceSelect which space to query
-k, --keyKey to match, or key* to fetch list [default: "*"]
--keyspaceKeyspace to scan
--textOutput info as text line [boolean]
--jsonlOutput as JSON Lines (one JSON object per line) [boolean]
--onlycountOutput only the count of keys [boolean]
--admintokenUse 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:

OptionDescription
-p, --projectSelect which project to use [string]
-s, --spaceSelect which space to use [string]
--keyKey to set [string] [required]
--valValue to set [string] [required]
--keyspaceKeyspace to use [string]
--ttlTime to live in millis for value [number]
--jsonOutput info as JSON [boolean]
--admintokenUse 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:

OptionDescription
-p, --projectSelect which project to use
-s, --spaceSelect which space to use
--keyKey to delete [required]
--keyspaceKeyspace to use
--jsonOutput info as JSON [boolean]
--admintokenUse admin token authentication (use for CI)

Examples:

codehooks del 'my-value-one'
codehooks del 'my-value-two' --keyspace 'spacex'

File Management

file-upload

Aliases: up, upload

Upload files to server

Options:

OptionDescription
-f, --srcPath to directory or file [default: "."]
-t, --targetTarget directory on server, same as local if not set
-e, --extInclude files matching the extension [string]
--spaceSelect which space (environment) to access
-p, --projectnameSelect which project name to use
--admintokenUse admin token authentication (use for CI)
--dryrunOutput 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:

OptionDescription
-f, --filenameDelete file with match on absolute path/filename
-r, --matchDelete multiple file that matches regular expression to a file path
--spaceSelect which space (environment) to access
-p, --projectnameSelect which project name to use
--admintokenUse admin token authentication (use for CI)
--dryrunOutput 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:

OptionDescription
-f, --pathPath to directory or file [default: "."]
--spaceSelect which space (environment) to access
-p, --projectSelect which project name to use
--admintokenUse admin token authentication (use for CI)
--reverseScan index in reverse order
--tableOutput data as formatted table (not JSON) [boolean]
--jsonOutput data as formatted JSON [boolean]

Examples:

codehooks file-list '/static/'

Monitoring & Logs

log

Aliases: logs

Show system logs for a space.

Options:

OptionDescription
-p, --projectSelect which project name to use
-s, --spaceSelect which space to log
-t, --tailChop log to n lines [default: 100]
-f, --followKeep log stream open
-c, --contextFilter log on: jobhooks, queuehooks, routehooks, datahooks, auth
--admintokenUse admin token authentication (use for CI)

Examples:

codehooks log
codehooks log -f
codehooks log --tail 10

stats

Show usage metrics for project spaces

Options:

OptionDescription
-p, --projectSelect which project to query
--spaceOnly show info for this space [string]
--jsonOutput info as json [boolean]

workflow-status

Aliases: wfstat

Visualize workflow data from workflowdata collection

Options:

OptionDescription
-p, --projectSelect which project to query
-s, --spaceSelect which space to query
-f, --formatOutput format [string] [choices: "json", "markdown", "html", "ascii"] [default: "ascii"]
-a, --activeShow only active (running) workflows [boolean] [default: false]
-i, --detailedShow detailed Instance Status table (default is summary only) [boolean] [default: false]
-v, --verboseShow version number [boolean] [default: false]
--followContinuously update workflow status (Ctrl+C to exit) [boolean] [default: false]
--intervalRefresh interval in milliseconds when using --follow (min: 1000) [number] [default: 2000]

queue-status

Aliases: qs, queues

Visualize queue status with item counts and workers

Options:

OptionDescription
-p, --projectSelect which project to query
-s, --spaceSelect which space to query
-f, --formatOutput format [string] [choices: "table", "compact", "json"] [default: "table"]
--followContinuously update queue status (Ctrl+C to exit) [boolean] [default: false]
--intervalRefresh interval in milliseconds when using --follow (min: 1000) [number] [default: 2000]
--admintokenUse admin token authentication (use for CI)

Security & Access

add-token

Add token to space

Options:

OptionDescription
--projectnameProject name [required]
--spaceA space in your project [required]
--readonly[boolean] [default: false]
--description[string] [default: ""]

remove-token

Remove token from space

Options:

OptionDescription
--projectnameProject name [required]
--spaceA space in your project [required]
-t, --token[string] [required]

set-env

Set environment variable for space

Options:

OptionDescription
--projectnameProject name [required]
--spaceA space in your project [required]
--encrypted[boolean] [default: false]
--key[string] [required]
--value[string] [required]

remove-env

Remove environment variable from space

Options:

OptionDescription
--projectnameProject name [required]
--spaceA space in your project [required]
-k, --key[string] [required]

jwks

Set/replace JWKS endpoint for OAuth2 authentication. Set to "" (empty string) to remove.

Options:

OptionDescription
--projectnameProject name [required]
--spaceA space in your project [required]
--urlURL of JWKS endpoint (must be https) [string] [required]

whitelist

Add host to whitelist (use to restrict space access)

Options:

OptionDescription
--projectnameProject name [required]
--spaceA space in your project [required]
--ipIP address which should be allowed access to space [string] [required]

whitelist-remove

Remove host from whitelist

Options:

OptionDescription
--projectnameProject name [required]
--spaceA space in your project [required]
--ipThe IP address to remove from the whitelist. [required]

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


Shell Integration

completion

Generate command completion script. Just add this to your .bashrc, .bash_profile, .zshrc (or similar) on *nix machines


Additional Resources

License

MIT License - Copyright © Codehooks AS