3.0.7 • Published 4 years ago

@sheetbase/server v3.0.7

Weekly downloads
12
License
MIT
Repository
github
Last release
4 years ago

@sheetbase/server

Build server app on Google Apps Script.

  • Install: npm install --save @sheetbase/server

  • Usage:

// 1. import module
import { ServerModule } from "@sheetbase/server";

// 2. create an instance
export class App {
  // the object
  serverModule: ServerModule;

  // initiate the instance
  constructor() {
    this.serverModule = new ServerModule(/* options */);
  }
}
NameTypeDescription
apiKeys?ApiKeysMultiple api keys
appName?undefined | stringThe unique app name
failure?undefined | functionHandler for invalid api key
key?undefined | stringSingle api key
trigger?undefined | functionTrigger every time an api key is used
views?undefined | stringThe view template folder

The Lib class.

NameTypeDescription
apiKeyMiddlewareAPIKeyMiddleware
apiKeyServiceAPIKeyService
httpServiceHttpService
loggingRouteLoggingRoute
monitoringServiceMonitoringService
optionServiceOptionService
responseServiceResponseService
routerServiceRouterService
serverRouteServerRoute
serverServiceServerService
FunctionReturns typeDescription
registerRoutes(routeEnabling?, middlewares?)RouterServiceExpose the module routes
useAPIKeyMiddleware()RoutingHandlerGet the API key middleware

Expose the module routes

Parameters

ParamTypeDescription
routeEnablingtrue | DisabledRoutes
middlewaresMiddlewares | RouteMiddlewares

Returns

RouterService


Get the API key middleware

Returns

RoutingHandler


ServerModule provides REST API endpoints allowing clients to access server resources. Theses enpoints are not exposed by default, to expose the endpoints:

ServerModule.registerRoutes(routeEnabling?);

ServerModule returns these routing errors, you may use the error code to customize the message:

  • server/no-app-name: No unique "appName" provided
RouteMethodDisabledDescription
/loggingPUTtrueSet a server log
/systemGETGet the system infomation

DISABLED Set a server log

Request body

NameTypeDescription
levelLoggingLevel
valueLoggingValue

Response

void


Get the system infomation

Response

object


License

@sheetbase/server is released under the MIT license.