Installation

Installing SherpaJS and creating a new SherpaJS Server.


Quick Installation

We recommend starting a new SherpaJS server by downloading the SherpaJS Server Template. This template will have all the required structure and example endpoints setup for you. After download the project, install all the dependencies by running:

npm install

You can start the development server with npm run dev.

Now your project is all setup, explore around the project files and get acquainted with the SherpaJS Project Structure and SherpaJS CLI.


Manual Installation

Creating a new server is extremely easy and can be done within a couple of minutes. To manually create a new server start by create a new NodeJS project with npm init. Then install the SherpaJS Core package:

npm install sherpa-core

Updating package.json

Open the package.json file in the root directory of your project, and update the following properties.

package.json
{
    "type": "module",
    "scripts": {
        "build": "sherpa build -b Vercel",
        "build-local": "sherpa build -b local",
        "start": "sherpa start",
        "dev": "sherpa dev"
    }
}

Creating Server Config

Create a new Typescript file for your server configuration in the root directory of your project named sherpa.server.ts.

sherpa.server.ts
import { SherpaJS } from "sherpa-core";

export default SherpaJS.New.server({
    context: { // optional, provide a context that are provided to endpoints
        example: "foo"
    }
});

Creating Endpoints

SherpaJS uses a directory-based structure for routing, similar to NextJS. Start by creating a /routes directory and place a new enpoint index.ts file in the directory. This will be processed at the root / of your application.

/routes/index.ts
import { Request, Response, Context } from "sherpa-core";

export function GET(request:Request, context:Context) {
    return Response.text("Hello World!");
}

Learn more about routing and endpoints.


Creating Static Assets (Optional)

Create a /public directory in the root directory of your project to store static assets such as images, stylings and more.

Learn more about static assets.