How to use the @airtasker/spot.specificError function in @airtasker/spot

To help you get started, we’ve selected a few @airtasker/spot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github airtasker / spot / examples / src / single-file / single-file-api.ts View on Github external
getUser(
    @pathParam({ description: "User unique identifier" }) userId: Int64
  ): Promise<{
    name: string;
    age?: Float;
  }> {
    return response();
  }

  @endpoint({
    method: "DELETE",
    path: "/users/:userId-confirmed",
    tags: ["users"]
  })
  @genericError()
  @specificError({
    name: "forbidden",
    statusCode: 403
  })
  deleteUser(
    @pathParam() userId: Int64,
    @header({
      name: "Authorization"
    })
    authToken: string
  ): null {
    return response();
  }
}

// Requests and responses.
github airtasker / spot / examples / src / multi-file / endpoints / delete-user.ts View on Github external
header,
  Int64,
  pathParam,
  response,
  specificError
} from "@airtasker/spot";
import { BaseError, ForbiddenError } from "../errors";

export class DeleteUser {
  @endpoint({
    method: "DELETE",
    path: "/users/:userId-confirmed",
    tags: ["users"]
  })
  @genericError()
  @specificError({
    name: "forbidden",
    statusCode: 403
  })
  deleteUser(
    @pathParam() userId: Int64,
    @header({
      name: "Authorization"
    })
    authToken: string
  ): null {
    return response();
  }
}

@airtasker/spot

**Spot** (_"Single Point Of Truth"_) is a concise, developer-friendly way to describe your API contract.

MIT
Latest version published 5 months ago

Package Health Score

72 / 100
Full package analysis

Similar packages