Code Monkey home page Code Monkey logo

serverless-cnode's Introduction

Serverless Cnode

在线预览

使用 Next.js + TypeScript 开发,并且基于 Serverless 部署的 cnode 客户端

流程图

Deploy Flow

功能

  • Typescript
  • Next.js
  • 自定义 Express Server
  • LRU Render Cache
  • 基于 Serverless Next.js 组件部署
  • 静态资源分离,自动部署到 COS
  • 自动为静态 COS 配置 CDN
  • node_modules 基于层部署,大大提高部署效率

本地开发

$ npm install

$ npm run dev

构建

$ npm run build

配置

在部署到 Serverless 前,将 .env.example 重命名为 .env,并请完成如下配置:

# 腾讯云授权密钥
TENCENT_APP_ID=xxx
TENCENT_SECRET_ID=xxx
TENCENT_SECRET_KEY=xxx

# 部署地区
REGION=ap-guangzhou

# 静态资源上传 COS 桶名称
BUCKET=serverless-cnode

# API 网关自定义域名 和 证书 ID
APIGW_CUSTOM_DOMAIN=cnode.yuga.chat
APIGW_CUSTOM_DOMAIN_CERTID=xxx

# CDN 域名,证书 ID
CDN_DOMAIN=static.cnode.yuga.chat
CDN_DOMAIN_CERTID=xxx

注意:如果不需要使用 CDN,直接使用 COS 自动生成的域名,也是可以的,只需要删除 serverless.yml 中的 cdnConf 即可。

部署

此项目会先将 node_modules 部署到 ,然后在部署项目代码, 这样下次部署项目时,如果 node_modules 没有修改,我们就不需要部署庞大的 node_modules 文件夹了。

  1. 部署层:
$ npm run deploy:layer

注意:如果项目 node_modules 没有变更,就不需要执行此命令。

  1. 部署业务代码:
$ npm run deploy

License

MIT

serverless-cnode's People

Contributors

dependabot[bot] avatar yugasun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

serverless-cnode's Issues

Serverless下如何让next.js支持增量静态再生

我们的网站是用next.js开发的,为了让网页更快响应我们使用了next.js的页面静态化功能,现在碰到两个这样的问题

  1. 我们的首页是需要定期更新的,因此使用了next.js的revalidate来定期重新更新缓存文件
  2. 我们的子页面有很多,几百上千个,因此我们使用了等到访问再生成页面缓存文件的策略

但查看后云函数的代码部署位置不支持文件的写入,导致上面这些都无效了。请问有什么方案可以解决这样的问题吗?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.