npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

serverless-qcloud-scf

v0.0.4

Published

Provider plugin for the Serverless Framework v1.x which adds support for Qcloud SCF(Serverless Cloud Function).

Downloads

12

Readme

English | 简体中文

Serverless QCloud SCF(Serverless Cloud Function) Plugin

Serverless License NPM Build Status Coverage Status Conventional Commits

This plugin enables support for QCloud SCF within the Serverless Framework.

Getting started

Pre-requisites

  • Node.js >= 6 for using the plugin.
    • Note that at the moment, Qcloud Serverless Cloud Function only supports v6.10. If you use a higher version of nodejs. Don't forget transform your code down to es5.
  • Serverless CLI v1.20.0+. You can get it by running npm i -g serverless.
  • A Qcloud account.

Example

The structure of the project should look something like this:

├── index.js
├── node_modules
├── package.json
└── serverless.yml

serverless.yml:

service: hello-world

provider:
  name: qcloud
  runtime: nodejs6.10
  credentials: ~/.qcloudcli/credentials # path must be absolute

plugins:
  - serverless-qcloud-scf

package:
  include:
    - index.js
  exclude:
    - package-lock.json
    - .gitignore
    - .git/**

functions:
  hello:
    handler: index.hello
    events:
      - http:
          path: /hello
          method: get

package.json:

{
  "name": "serverless-qcloud-hello-world",
  "version": "0.1.0",
  "description": "Hello World example for qcloud provider with Serverless Framework.",
  "main": "index.js",
  "license": "MIT",
  "devDependencies": {
    "serverless-qcloud-scf": "*"
  }
}

index.js:

'use strict'

exports.hello = (event, context, callback) => {
  callback(null, 'Hello!')
}

Credentials

Note that ~/.qcloudcli/credentials is where the qcloudcli puts the crendentials after running qcloudcli configure. You don't have to use qcloudcli though, you can just create a similar file with your own access keys and make sure pointing the value of the credentials field in serverless.yml to it.

In addition to qcloud_secretkey and qcloud_secretid, please configure qcloud_appid (a numeric number for identifying your account, available in Qcloud Console) as well. This credential file should look something like this:

[default]
qcloud_secretkey = ****************Ewdm
qcloud_secretid = ****************ugEY
qcloud_appid = 1250000000

Put credentials in ENV

If you not prefer qcloudcli. You can write credentials in ENV. serverless-qcloud-scf will read them.

QCLOUD_SECRETID=xxx QCLOUD_SECRETKEY=xxx QCLOUD_APPID=1250000000 serverless package

Consider use dotenv or direnv.

Workflow

  • Deploy your service to Qcloud:

    serverless deploy

    If your service contains HTTP endpoints, you will see the URLs for invoking your functions after a successful deployment.

  • When you no longer needs your service, you can remove the service, functions, along with deployed endpoints and triggers using:

    serverless remove

    Note: Some resources cannot remove, since it's not empty. The reason is your projects share a common service name. This issue different project deploy into same COS Bucket / API Gateway.

LIMIT

SCF

Function name is unique in a region.

The functions cannot more than 20, see scf document

COS

Bucket name is unique in an account.

Plugin will try overwrite ACL to public-read and write files into it if deploy target bucket is exists.

When create function in bj region, Qcloud will read code from COS ap-beijing-1 region.

API Gateway

Service ID is unique. Service name and API name is not unique.

Plugin will search service by region and name. Create it if not exists. Overwrite exists apis if service exists. But cannot handle multi service with same names.

Inside service, API "method+path" is unique.

Develop

# clone this repo
git clone [email protected]:vitarn/serverless-qcloud-scf.git

# link this module to global node_modules
cd serverless-qcloud-scf
npm install
npm link

# try it out by packaging the test project
cd test/project
npm install
npm link serverless-qcloud-scf
serverless package

TODO

  • [x] serverless package
  • [x] serverless deploy
  • [x] serverless deploy --function
  • [x] serverless remove
  • [ ] serverless invoke
  • [x] serverless info
  • [ ] serverless rollback
  • [x] function: event: cos
  • [ ] function: event: cmq
  • [ ] function: event: http: usagePlan
  • [ ] function: event: http: key
  • [ ] function: event: http: custom domain
  • [ ] function: event: http: switch release

License

MIT