Options
All
  • Public
  • Public/Protected
  • All
Menu

Build next-generation realtime APIs simply and easily

Install

One command and you're ready to make some killer APIs:

npm install sutro --save

Now, check out the documentation to get started!

Examples

10-LOC ES7 API

const api = {
  user: {
    create: async ({ data }) => User.create(data),
    find: async ({ options }) => User.findAll(options),
    findById: async ({ userId }) => User.findById(userId),
    updateById: async ({ userId, data }) => User.updateById(userId, data),
    replaceById: async ({ userId, data }) => User.replaceById(userId, data),
    deleteById: async ({ userId }) => User.deleteById(userId)
  }
}

Yields:

GET /swagger.json
GET /users
POST /users
GET /users/:userId
PATCH /users/:userId
PUT /users/:userId
DELETE /users/:userId

Index

Type aliases

EndpointCache

EndpointCache: { get: (opt: SutroRequest | string, key: string) => Promise<any> | any; header: CacheOptions | (() => CacheOptions); key: () => string; set: (opt: SutroRequest | string, data: any, key: string) => Promise<any> | any }

Type declaration

  • get: (opt: SutroRequest | string, key: string) => Promise<any> | any
      • (opt: SutroRequest | string, key: string): Promise<any> | any
      • Parameters

        Returns Promise<any> | any

  • header: CacheOptions | (() => CacheOptions)
  • key: () => string
      • (): string
      • Returns string

  • set: (opt: SutroRequest | string, data: any, key: string) => Promise<any> | any
      • (opt: SutroRequest | string, data: any, key: string): Promise<any> | any
      • Parameters

        Returns Promise<any> | any

EndpointExecute

EndpointExecute: (opt: SutroRequest) => Promise<any> | any

Type declaration

EndpointFormat

EndpointFormat: () => Promise<any> | any

Type declaration

    • (): Promise<any> | any
    • Returns Promise<any> | any

EndpointHTTP

EndpointHTTP: { instance: boolean; method: MethodVerbs }

Type declaration

  • instance: boolean
  • method: MethodVerbs

EndpointIsAuthorized

EndpointIsAuthorized: (opt: SutroRequest) => Promise<boolean> | boolean

Type declaration

Properties

default

default: (__namedParameters: SutroArgs) => SutroRouter

Type declaration

    • (__namedParameters: SutroArgs): SutroRouter
    • Parameters

      • __namedParameters: SutroArgs

      Returns SutroRouter

Variables

Const codes

codes: { badRequest: number; forbidden: number; notFound: number; serverError: number; unauthorized: number } = ...

Type declaration

  • badRequest: number
  • forbidden: number
  • notFound: number
  • serverError: number
  • unauthorized: number

Functions

Const rewriteLargeRequests

  • rewriteLargeRequests(req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>, next: NextFunction): void
  • Parameters

    • req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>
    • res: Response<any, Record<string, any>>
    • next: NextFunction

    Returns void

Legend

  • Constructor
  • Property
  • Method
  • Property
  • Inherited property

Generated using TypeDoc