REST

Overview

code.store platform support file based REST endpoints. To avoid manual file creation allowed a command cs generate:rest, which generate an empty route template with handler method.

To generate REST route just execute cs generate:rest CLI command, select one of HTTP methods: GET, POST, PUT, DELETE and specify a new route name

> cs generate:rest

? Select HTTP method (Use arrow keys)
❯ GET 
  POST 
  PUT 
  DELETE 
  
? Select HTTP method GET

? Name of your REST endpoint hello

Also, you can use flags:

-m for method specification (GET, POST, PUT, DELETE)

-n for route name

For example, here a command from previous example: cs generate:rest -m get -n hello

After command execution will be generated file get.hello.ts in src/rest directory:

More information about handler method and his params can be found in REST section.

Last updated

Was this helpful?