Installation

Installation

System requirements:

10 seconds setup

To get started, type the following command:

npm create sensai
 
# or
npx create-sensai

On installation, you'll see the following prompts:

? What is your project named? › hello-world

The CLI create-sensai automatically install/setup your project dependencies, allowing you to start coding immediately!

Manual Installation

To manually install Sensai in your project, please:

Install dependencies

npm install sensai@latest

Add scripts

Open your project package.json and add the following scripts:

package.json
{
  "scripts": {
    "dev": "sensai dev",
    "build": "sensai build",
    "start": "sensai start"
  }
}

Those scripts accompany you at each step of the development process:

  • dev run development server (with live reload, automatic documentation and more)
  • build build and optimize production artifacts and documentation
  • start run the fastest production server in the west

Sensai provides an integrated TypeScript experience, including on the fly transpilation, zero-configuration set up and dependencies.

Create api folder

Create an api folder at the root of your project and add a basic route.ts file.

route.ts
export default ({ name = "world" }) => {
  return "hello " + name;
};

Congratulation, you created your first API. This will be served everytime a user send a request to the path /.

Please note that routes can also be written in Javascript by using the .js, .mjs or .cjs extension. Your project can contain both JavaScript and/or TypeScript routes.

Run development server

After the set up is complete:

With Sensai, creating an API is as easy as writing a function with data as input and data as output. Everything is taken care of and developers don't need to get bogged down anymore in the details of request handling and response generation.