Coder Social home page Coder Social logo

wxcloudrun-koa

GitHub license GitHub package.json dependency version (prod) GitHub package.json dependency version (prod)

微信云托管 Node.js Koa 框架模版,实现简单的计数器读写接口,使用云托管 MySQL 读写、记录计数值。

快速开始

前往 微信云托管快速开始页面,选择相应语言的模板,根据引导完成部署。

本地调试

下载代码在本地调试,请参考微信云托管本地调试指南

实时开发

代码变动时,不需要重新构建和启动容器,即可查看变动后的效果。请参考微信云托管实时开发指南

Dockerfile最佳实践

请参考如何提高项目构建效率

项目结构说明

.
├── Dockerfile
├── README.md
├── container.config.json  
├── db.js
├── index.js
├── index.html
├── package.json
  • index.js:项目入口,实现主要的读写 API
  • db.js:数据库相关实现,使用 sequelize 作为 ORM
  • index.html:首页代码
  • package.json:Node.js 项目定义文件
  • container.config.json:模板部署「服务设置」初始化配置(二开请忽略)
  • Dockerfile:容器配置文件

服务 API 文档

GET /api/count

获取当前计数

请求参数

响应结果

  • code:错误码
  • data:当前计数值
响应结果示例
{
  "code": 0,
  "data": 42
}

调用示例

curl https://<云托管服务域名>/api/count

POST /api/count

更新计数,自增或者清零

请求参数

  • actionstring 类型,枚举值
    • 等于 "inc" 时,表示计数加一
    • 等于 "clear" 时,表示计数重置(清零)
请求参数示例
{
  "action": "inc"
}

响应结果

  • code:错误码
  • data:当前计数值
响应结果示例
{
  "code": 0,
  "data": 42
}

调用示例

curl -X POST -H 'content-type: application/json' -d '{"action": "inc"}' https://<云托管服务域名>/api/count

使用注意

如果不是通过微信云托管控制台部署模板代码,而是自行复制/下载模板代码后,手动新建一个服务并部署,需要在「服务设置」中补全以下环境变量,才可正常使用,否则会引发无法连接数据库,进而导致部署失败。

  • MYSQL_ADDRESS
  • MYSQL_PASSWORD
  • MYSQL_USERNAME 以上三个变量的值请按实际情况填写。如果使用云托管内MySQL,可以在控制台MySQL页面获取相关信息。

License

MIT

Bio_Gas's Projects

aiintern-training-program icon aiintern-training-program

为了对新来的实习学生有一个较为系统的培训,我们构建了关于实习生培训的数据专用git,主要的内容包括:任务书,学习资料,论文,以及原始代码,欢迎大家

ailearning icon ailearning

AiLearning: 机器学习 - MachineLearning - ML、深度学习 - DeepLearning - DL、自然语言处理 NLP

air_quality_ppm_prediction icon air_quality_ppm_prediction

This is an implementation of Time Series forecasting methods namely VAR(Vector Auto Regressive) model and various other RNN models like Non-Linear AutoRegressive with eXogenous inputs) (4 Layers), Elman RNN, Jordan RNN.

algorithm_interview_notes-chinese icon algorithm_interview_notes-chinese

2018/2019/校招/春招/秋招/算法/机器学习(Machine Learning)/深度学习(Deep Learning)/自然语言处理(NLP)/C/C++/Python/面试笔记

analysis-of-college-graduates-employment-orientation icon analysis-of-college-graduates-employment-orientation

本项目旨在建立一个基于大数据处理的大学生就业方向分析预测系统,通过爬虫技术获取各大公司和著名招聘网站的大量招聘信息,然后将获取的数据进行清洗分类后储存在数据库中,最后从大学生的就业角度出发,通过算法分析数据,建立一个帮助大学生明确就业方向与社会需求的平台

awesome-bigdata icon awesome-bigdata

A curated list of awesome big data frameworks, ressources and other awesomeness.

awesome-programming-books icon awesome-programming-books

经典编程书籍大全,涵盖:计算机系统与网络、系统架构、算法与数据结构、前端开发、后端开发、移动开发、数据库、测试、项目与团队、程序员职业修炼、求职面试等

aws-deepracer-1 icon aws-deepracer-1

The reward function achieved 42 sec on *re:Invent 2018* by time trial (3 laps).

aws_deepracer_worksheet icon aws_deepracer_worksheet

Worksheet and Utilities for AWS DeepRacer – one of the most exciting ways of building strong skills in reinforcement learning and through a hands-on approach. This repository offers: 1) Functionally-rich and flexible reward function 2) Utilities with Jupiter notes for Racing Line calculation and visualisation of track 3) Scripts to parse RoboMaker

bigdata icon bigdata

BigData Project 大数据项目由浅入深

bigdata18 icon bigdata18

Transfer learning for time series classification

bigdataplatform icon bigdataplatform

BigDataPlatform:基于大数据、数据平台、微服务、机器学习、商城、自动化运维、DevOps、容器部署平台、数据平台采集、数据平台存储、数据平台计算、数据平台开发、数据平台应用搭建的大数据解决方案。

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.