Sensai CLI

Development

simpi dev runs your APIs at http://localhost:3030 in development mode NODE_ENV=development. You get a few features out of the box:

  • built-in Typescript support,
  • hot reloading, eliminating the need for server restarts,
  • and more

Argument

This CLI serves APIs from the root api directory but can be changed like so:

Terminal
npx simpi dev src

Options

Please type npx simpi dev --help to get the list of options available:

Options:
  -p, --port <number>  port number on which to start the API server (default: 3030)
  --no-watch           disable hot reload
  -h, --help           display help for command

Port

The default port 3030 can also be changed with the option -p:

Terminal
npx simpi dev -p 80

or via the PORT environment variable:

Terminal
PORT=80 npx simpi dev

Watch

By default, simpi dev will watch for changing in your working directory and invalidates the module cache for hot reloading. However, you can choose to disable watching for changes with the following option:

Terminal
npx simpi dev --no-watch

Please note that this option does not prevent files from being transpiled into JavaScript in development mode.

Building

simpi build bundle and build optimized artifacts that will be used to run your production API.

Argument

This CLI generates APIs from the root api directory but can be changed like so:

Terminal
npx simpi build src

Please note that the API directory needs to match for all commands (i.e simpi dev, simpi build and simpi start).

Options

Please type npx simpi build --help to get the list of options available:

Options:
  --copy-files      copy all files in working directory
  -h, --help        display help for command

Copy all files

By default, simpi build will only copy and transpile JavaScript and TypeScript files. With the option --copy-files, all files in the working directory will be copied over the cache storage.

Terminal
npx simpi build --copy-files

Production

simpi start runs your APIs at http://localhost:80 in production mode NODE_ENV=production. The APIs should be compiled first by simpi build.

The production server is built for speed and with security in mind.

Options

Please type simpi start --help to get the list of options available:

Options:
  -p, --port <number>  port number on which to start the API server (default: 80)
  -h, --help           display help for command

Port

The default port 80 can also be changed with the option -p:

Terminal
npx simpi start -p 8080

or via the PORT environment variable:

Terminal
PORT=8080 npx simpi start

Testing

simpi test parse your project and allow you to test your API in testing mode NODE_ENV=testing. Amongst other things, simpi test will:

  • automatically run unit tests (files with the following pattern *.test.{ts,js})

Please note that by default simpi will run your tests concurrently based on your OS.