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

@cloudbase/framework-plugin-node

v1.9.7

Published

云开发 Tencent CloudBase Framework Node Plugin 插件,将项目下的Node应用一键部署云开发环境,提供自动弹性伸缩的高性能Node服务。

Downloads

548

Readme

Tencent CloudBase Framework Node Plugin

Tencent CloudBase Framework Node Plugin

Github License Npm version issue PRs Welcome star

云开发 CloudBase Framework 框架「Node.js App」插件: 通过云开发 CloudBase Framework 框架将 Node 应用一键部署云开发环境,提供自动弹性伸缩的高性能 Node 应用服务,支持底层部署为函数或者 云托管,可以搭配其他插件如 Website 插件、函数插件实现云端一体开发。

功能特性

  • 无须关心底层架构: 只需要开发业务服务,不用适配函数或者容器
  • 节约成本: 资源伸缩,弹性扩缩容,灵活计费,极大节约资源成本
  • 框架支持: 无缝支持原生和前端框架构建的项目
    • 原生 Node.js
    • Express
    • Koa

使用方法

步骤一. 准备工作

具体步骤请参照 准备云开发环境和 CloudBase CLI 命令工具

步骤二. 进入 Node 项目目录进行初始化

如果目前已有 Node 应用项目

cloudbase

如果想全新开始一个项目,可以直接执行 init 来从模板开始一个项目

cloudbase init

步骤三. 一键部署

cloudbase framework deploy

配置

默认情况下不需要任何配置即可使用,以下配置参数针对有特殊需求的场景

配置示例

cloudbase init 之后会创建云开发的配置文件 cloudbaserc.json,可在配置文件的 plugins 里修改和写入插件配置

{
  "envId": "{{envId}}",
  "framework": {
    "plugins": {
      "server": {
        "use": "@cloudbase/framework-plugin-node",
        "inputs": {
          "entry": "app.js",
          "path": "/nodeapp",
          "name": "nodeapp"
        }
      }
    }
  }
}

配置参数说明

entry

默认 app.js

Node 服务入口文件,相对于projectPath,需要导出 app 或者 server 的实例,同时也支持导出异步获取 app 的 tcbGetApp 方法,方法的返回值为 app 或者 server 的实例。

如 koa 服务的 app.js

const Koa = require('koa');
const { router } = require('./routes/');

const app = new Koa();

app.use(router.routes());

module.exports = app;

nest 服务的 app.js

const express = require('express');
const { NestFactory } = require('@nestjs/core');
const { ExpressAdapter } = require('@nestjs/platform-express');
const { AppModule } = require('./dist/app.module');

const expressApp = express();
const adapter = new ExpressAdapter(expressApp);

exports.tcbGetApp = async () => {
  const app = await NestFactory.create(AppModule, adapter);
  await app.init();
  return expressApp;
};

path

必填,访问子路径,如 /node-app

name

必填,服务名,如node-app

projectPath

选填,指定 Node 服务所在目录,相对于当前项目根目录

buildCommand

0.5.x 版本以后支持

选填,指定构建命令,比如npm run build

platform

选填,底层使用平台,支持 container( 云托管) 和 function (云函数), 默认是 function

installDeps

选填,类型 boolean,是否需要安装依赖,默认值 true, 如果依赖私有 npm 包需要填写 false

containerOptions

选填,当 platform 选择 container 时,可以支持自定义更多高级设置,例如 CPU 内存等

例如

{
  "use": "@cloudbase/framework-plugin-node",
  "inputs": {
    "entry": "app.js",
    "path": "/nodeapp",
    "name": "nodeapp",
    "platform": "container",
    "containerOptions": {
      "cpu": 2,
      "mem": 2
    }
  }
}

具体配置信息请参考 @cloudbase/framework-plugin-container 配置

functionOptions

选填,当 platform 选择 function 时,可以支持自定义更多高级设置,例如 VPC 环境变量等

例如

{
  "use": "@cloudbase/framework-plugin-node",
  "inputs": {
    "entry": "app.js",
    "path": "/nodeapp",
    "name": "nodeapp",
    "platform": "function",
    "functionOptions": {
      "timeout": 5,
      "envVariables": {
        "TEST_ENV": 1
      },
      "vpc": {
        "vpcId": "xxx",
        "subnetId": "xxx"
      }
    }
  }
}

具体配置信息请参考 @cloudbase/framework-plugin-function 配置

wrapExpress

选填,当 platform 选择 function 时,可以支持自动为函数包上一层 express

例如

{
  "envId": "fx",
  "framework": {
    "plugins": {
      "server": {
        "use": "@cloudbase/framework-plugin-node",
        "inputs": {
          "entry": "./api/index.js",
          "path": "/api",
          "name": "github-stats-api",
          "wrapExpress": true
        }
      },
      "pin": {
        "use": "@cloudbase/framework-plugin-node",
        "inputs": {
          "entry": "./api/pin.js",
          "path": "/api/pin",
          "name": "github-stats-pin",
          "wrapExpress": true
        }
      }
    }
  }
}

更多插件

请访问 CloudBase Framework 插件列表 搭配使用其他插件

文档资料