mirror of
https://github.com/serverless/serverless.git
synced 2025-12-08 19:46:03 +00:00
Adding aws-nodejs-ecma-script template
This commit is contained in:
parent
b06a891b92
commit
b2fbfb720d
@ -9,6 +9,7 @@ const userStats = require('../../utils/userStats');
|
||||
// class wide constants
|
||||
const validTemplates = [
|
||||
'aws-nodejs',
|
||||
'aws-nodejs-ecma-script',
|
||||
'aws-python',
|
||||
'aws-python3',
|
||||
'aws-groovy-gradle',
|
||||
|
||||
@ -99,6 +99,26 @@ describe('Create', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should generate scaffolding for "aws-nodejs-ecma-script" template', () => {
|
||||
process.chdir(tmpDir);
|
||||
create.options.template = 'aws-nodejs-ecma-script';
|
||||
|
||||
return create.create().then(() => {
|
||||
expect(create.serverless.utils.fileExistsSync(path.join(tmpDir, 'serverless.yml')))
|
||||
.to.be.equal(true);
|
||||
expect(create.serverless.utils.fileExistsSync(path.join(tmpDir, 'first.js')))
|
||||
.to.be.equal(true);
|
||||
expect(create.serverless.utils.fileExistsSync(path.join(tmpDir, 'second.js')))
|
||||
.to.be.equal(true);
|
||||
expect(create.serverless.utils.fileExistsSync(path.join(tmpDir, 'package.json')))
|
||||
.to.be.equal(true);
|
||||
expect(create.serverless.utils.fileExistsSync(path.join(tmpDir, 'webpack.config.js')))
|
||||
.to.be.equal(true);
|
||||
expect(create.serverless.utils.fileExistsSync(path.join(tmpDir, '.gitignore')))
|
||||
.to.be.equal(true);
|
||||
});
|
||||
});
|
||||
|
||||
it('should generate scaffolding for "aws-csharp" template', () => {
|
||||
process.chdir(tmpDir);
|
||||
create.options.template = 'aws-csharp';
|
||||
|
||||
@ -0,0 +1,90 @@
|
||||
(function(e, a) { for(var i in a) e[i] = a[i]; }(exports, /******/ (function(modules) { // webpackBootstrap
|
||||
/******/ // The module cache
|
||||
/******/ var installedModules = {};
|
||||
/******/
|
||||
/******/ // The require function
|
||||
/******/ function __webpack_require__(moduleId) {
|
||||
/******/
|
||||
/******/ // Check if module is in cache
|
||||
/******/ if(installedModules[moduleId]) {
|
||||
/******/ return installedModules[moduleId].exports;
|
||||
/******/ }
|
||||
/******/ // Create a new module (and put it into the cache)
|
||||
/******/ var module = installedModules[moduleId] = {
|
||||
/******/ i: moduleId,
|
||||
/******/ l: false,
|
||||
/******/ exports: {}
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // Execute the module function
|
||||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
||||
/******/
|
||||
/******/ // Flag the module as loaded
|
||||
/******/ module.l = true;
|
||||
/******/
|
||||
/******/ // Return the exports of the module
|
||||
/******/ return module.exports;
|
||||
/******/ }
|
||||
/******/
|
||||
/******/
|
||||
/******/ // expose the modules object (__webpack_modules__)
|
||||
/******/ __webpack_require__.m = modules;
|
||||
/******/
|
||||
/******/ // expose the module cache
|
||||
/******/ __webpack_require__.c = installedModules;
|
||||
/******/
|
||||
/******/ // define getter function for harmony exports
|
||||
/******/ __webpack_require__.d = function(exports, name, getter) {
|
||||
/******/ if(!__webpack_require__.o(exports, name)) {
|
||||
/******/ Object.defineProperty(exports, name, {
|
||||
/******/ configurable: false,
|
||||
/******/ enumerable: true,
|
||||
/******/ get: getter
|
||||
/******/ });
|
||||
/******/ }
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
||||
/******/ __webpack_require__.n = function(module) {
|
||||
/******/ var getter = module && module.__esModule ?
|
||||
/******/ function getDefault() { return module['default']; } :
|
||||
/******/ function getModuleExports() { return module; };
|
||||
/******/ __webpack_require__.d(getter, 'a', getter);
|
||||
/******/ return getter;
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // Object.prototype.hasOwnProperty.call
|
||||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
||||
/******/
|
||||
/******/ // __webpack_public_path__
|
||||
/******/ __webpack_require__.p = "";
|
||||
/******/
|
||||
/******/ // Load entry module and return exports
|
||||
/******/ return __webpack_require__(__webpack_require__.s = 0);
|
||||
/******/ })
|
||||
/************************************************************************/
|
||||
/******/ ([
|
||||
/* 0 */
|
||||
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
const hello = (event, context, cb) => {
|
||||
const p = new Promise(resolve => {
|
||||
resolve('success');
|
||||
});
|
||||
const response = {
|
||||
statusCode: 200,
|
||||
body: JSON.stringify({
|
||||
message: 'Go Serverless Webpack (Ecma Script) v1.0! Second module!',
|
||||
input: event
|
||||
})
|
||||
};
|
||||
p.then(() => cb(null, response)).catch(e => cb(e));
|
||||
};
|
||||
/* harmony export (immutable) */ __webpack_exports__["hello"] = hello;
|
||||
|
||||
|
||||
/***/ })
|
||||
/******/ ])));
|
||||
12
lib/plugins/create/templates/aws-nodejs-ecma-script/first.js
Normal file
12
lib/plugins/create/templates/aws-nodejs-ecma-script/first.js
Normal file
@ -0,0 +1,12 @@
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export const hello = (event, context, callback) => {
|
||||
const p = new Promise((resolve) => {
|
||||
resolve('success');
|
||||
});
|
||||
p
|
||||
.then(() => callback(null, {
|
||||
message: 'Go Serverless Webpack (Ecma Script) v1.0! First module!',
|
||||
event,
|
||||
}))
|
||||
.catch(e => callback(e));
|
||||
};
|
||||
@ -0,0 +1,6 @@
|
||||
# package directories
|
||||
node_modules
|
||||
jspm_packages
|
||||
|
||||
# Serverless directories
|
||||
.serverless
|
||||
@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "aws-nodejs-ecma-script",
|
||||
"version": "1.0.0",
|
||||
"description": "Serverless webpack example using ecma script",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-core": "^6.25.0",
|
||||
"babel-loader": "^7.1.1",
|
||||
"babel-plugin-transform-runtime": "^6.23.0",
|
||||
"babel-polyfill": "^6.23.0",
|
||||
"babel-preset-env": "^1.6.0",
|
||||
"serverless-webpack": "^2.2.0",
|
||||
"webpack": "^3.3.0"
|
||||
},
|
||||
"author": "The serverless webpack authors (https://github.com/elastic-coders/serverless-webpack)",
|
||||
"license": "MIT"
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export const hello = (event, context, cb) => {
|
||||
const p = new Promise((resolve) => {
|
||||
resolve('success');
|
||||
});
|
||||
const response = {
|
||||
statusCode: 200,
|
||||
body: JSON.stringify({
|
||||
message: 'Go Serverless Webpack (Ecma Script) v1.0! Second module!',
|
||||
input: event,
|
||||
}),
|
||||
};
|
||||
p
|
||||
.then(() => cb(null, response))
|
||||
.catch(e => cb(e));
|
||||
};
|
||||
@ -0,0 +1,26 @@
|
||||
service: babel-dynamically-entries-example
|
||||
|
||||
# Add the serverless-webpack plugin
|
||||
plugins:
|
||||
- serverless-webpack
|
||||
|
||||
provider:
|
||||
name: aws
|
||||
runtime: nodejs6.10
|
||||
|
||||
functions:
|
||||
# Example without LAMBDA-PROXY integration
|
||||
# Invoking locally:
|
||||
# sls webpack invoke -f first
|
||||
first:
|
||||
handler: first.hello
|
||||
# Example with LAMBDA-PROXY integration
|
||||
# Invoking locally:
|
||||
# sls webpack invoke -f second
|
||||
second:
|
||||
handler: second.hello
|
||||
events:
|
||||
- http:
|
||||
method: get
|
||||
path: second
|
||||
integration: lambda
|
||||
@ -0,0 +1,20 @@
|
||||
const path = require('path');
|
||||
const slsw = require('serverless-webpack');
|
||||
|
||||
module.exports = {
|
||||
entry: slsw.lib.entries,
|
||||
target: 'node',
|
||||
module: {
|
||||
loaders: [{
|
||||
test: /\.js$/,
|
||||
loaders: ['babel-loader'],
|
||||
include: __dirname,
|
||||
exclude: /node_modules/,
|
||||
}],
|
||||
},
|
||||
output: {
|
||||
libraryTarget: 'commonjs',
|
||||
path: path.join(__dirname, '.webpack'),
|
||||
filename: '[name].js',
|
||||
},
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user