Code Monkey home page Code Monkey logo

js's Introduction

Serverless + JavaScript

简介

serverlessplus 是一个简单易用的工具,它可以帮助你将现有的 express / koa / restify 等框架构建的应用借助 API 网关 迁移到 腾讯云无服务云函数(Tencent Cloud Serverless Cloud Function)上。

开始使用

$ npm install serverlessplus

假设有如下 express 应用:

// app.js
'use strict';

const express = require('express');
const app = express();

app.get('/', (request, response) => {
    response.end('hello world');
});

app.litsen(8000);

可以通过如下简单修改,迁移到 serverless 平台上:

// app.js
'use strict';

const express = require('express');
const app = express();

app.get('/', (request, response) => {
    response.end('hello world');
});

// comment out `listen`
// exports your `app`

// app.litsen(8000);
module.exports = app;

将服务到入口文件修改为如下内容:

// index.js
'use strict';

const app = require('./app');
const serverlessplus = require('serverlessplus');

const options = {
    binaryMIMETypes: [
        'image/gif',
        'image/png',
        'image/jpeg',
    ],
    framework: 'express',
};

const proxy = serverlessplus.createProxy(app, options);

exports.main_handler = (event, context) => {
    return proxy.serveRequest(event, context);
}

示例

支持的框架

路线图

  • 更多 Web 框架的支持
  • 对小程序云开发的支持

serverlessplus 处于活跃开发中,API 可能在未来的版本中发生变更,我们十分欢迎来自社区的贡献,你可以通过 pull request 或者 issue 来参与。

js's People

Contributors

serverlessplus avatar

Watchers

 avatar

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.