Getting started

Before you start

You need to pick the base library you want to create your project with.

If your project consists of few simple functions and you’re comfortable dealing with raw http requests, you can start with @httpc/server. Otherwise, it’s strongly suggested to build upon @httpc/kit as it offers lots of features you’ll end up using anyway.

Installation

Requirements

Start from a template

You can quickly setup a project from a template.

npm create httpc

Manual setup

If you already have a package, you can manually add httpc to your project.

# for server-based projects
npm install @httpc/server
# for kit-based projects
npm install @httpc/kit tsyringe reflect-metadata

# used in both, for development tasks
npm install @httpc/cli --save-dev

Start the server

If you used a template, you can start the development server. Enter the project directory and run:

npm run dev

Generate the client

After you wrote some functions, you can generate the client package. In a project directory, just run:

npm run generate:client

Underneath it runs the @httpc/cli with httpc client generate. You can checkout more about client generation with all the advanced options.

Project structure

The minimal project is composed by:

project/
├─ src/
│  ├─ calls/
│  │  └─ index.ts
│  └─ index.ts
├─ httpc.json
├─ package.json
└─ tsconfig.json
import { createHttpCServer } from "@httpc/server";
import calls from "./calls";


const server = createHttpCServer({
  calls,
  cors: true
});

server.listen();

The core files:

Next steps