1.0.6 • Published 1 year ago

@greencloud/gc-base-handler v1.0.6

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Greencloud Base Handler

How To Use

Use this template in your lambda function that serves API Gateway request.

import { ApiCallback, ApiContext, ApiEvent, HandlerBase } from "@greencloud/gc-base-handler";

export function handler(event: ApiEvent, context: ApiContext, callback: ApiCallback) {
  return new Handler().handle(event, context, callback);
}

class Handler extends HandlerBase<string> {
  constructor() {
    super({
      successResponseCode: 200,
      action: 'post',
      resource: 'A handler to get user dsata',
      level: 'info',
      forceDisableCors: false
    });
  }

  protected doWork(request: ApiEvent, context: ApiContext, response: ApiCallback): Promise<string> {
      return Promise.resolve("Success");
  }
}

Extending Handler

import { ApiContext, HandlerBase, ApiEvent, ApiCallback } from "@greencloud/gc-base-handler";

export abstract class NewHandler<T> extends HandlerBase<T> {
  public async handle(
    request: ApiEvent,
    context: ApiContext,
    response: ApiCallback
  ) {
    return super.handle(request, context, response);
  }
}

Do Prerelease in Local Machine

If you want to build package and test your work on another repo, you can bump the prerelease with --preid argument when executing the npm version command. Please do make sure you already logged in to the npm by using the dev account. Then, run these commands to publish your prerelease package.

npm version prerelease --preid ugc-xx
npm publish

That's it!

Release Option

When working with release, the CI will automatically publish the package when it detects the release type by analyzing the commit message. So, in order to publish/release/deploy, you name it, make sure you follow the semantic-release commit message convention.

See:

semantic-release

Or, you might use commitizen to help you figure out the hassle by running

git add . && npm run commit
  • Assuming you already have files that ready to be committed
1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.2-ugc-32.0

2 years ago

1.0.0

2 years ago

1.0.1-ugc-32.0

2 years ago