Skip to content
Permalink
Browse files

Adding aws-nodejs-typescript template

  • Loading branch information...
franciscocpg committed Aug 8, 2017
1 parent b06a891 commit 0eb1cbccfbacb73f558788de3565c3e1bd4e83d8
@@ -9,6 +9,7 @@ const userStats = require('../../utils/userStats');
// class wide constants
const validTemplates = [
'aws-nodejs',
'aws-nodejs-typescript',
'aws-python',
'aws-python3',
'aws-groovy-gradle',
@@ -99,6 +99,26 @@ describe('Create', () => {
});
});

it('should generate scaffolding for "aws-nodejs-typescript" template', () => {
process.chdir(tmpDir);
create.options.template = 'aws-nodejs-typescript';

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, 'handler.ts')))
.to.be.equal(true);
expect(create.serverless.utils.fileExistsSync(path.join(tmpDir, 'tsconfig.json')))
.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,9 @@
# package directories
node_modules
jspm_packages

# Serverless directories
.serverless

# Webpack directories
.webpack
@@ -0,0 +1,3 @@
export const hello = (event, context, cb) => cb(null,
{ message: 'Go Serverless Webpack (Typescript) v1.0! Your function executed successfully!', event }
);
@@ -0,0 +1,17 @@
{
"name": "aws-nodejs-typescript",
"version": "1.0.0",
"description": "Serverless webpack example using Typescript",
"main": "handler.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"devDependencies": {
"serverless-webpack": "^2.2.0",
"ts-loader": "^2.3.1",
"typescript": "^2.4.2",
"webpack": "^3.3.0"
},
"author": "The serverless webpack authors (https://github.com/elastic-coders/serverless-webpack)",
"license": "MIT"
}
@@ -0,0 +1,21 @@
service: serverless-webpack-typescript-example

# Add the serverless-webpack plugin
plugins:
- serverless-webpack

provider:
name: aws
runtime: nodejs6.10

functions:
# Example with LAMBDA-PROXY integration
# Invoking locally:
# sls webpack invoke -f hello
hello:
handler: handler.hello
events:
- http:
method: get
path: hello
integration: lambda
@@ -0,0 +1,5 @@
{
"compilerOptions": {
"sourceMap": true
}
}
@@ -0,0 +1,18 @@
const path = require('path');
// eslint-disable-next-line import/no-unresolved
const slsw = require('serverless-webpack');

module.exports = {
entry: slsw.lib.entries,
output: {
libraryTarget: 'commonjs',
path: path.join(__dirname, '.webpack'),
filename: '[name].js',
},
target: 'node',
module: {
loaders: [
{ test: /\.ts(x?)$/, loader: 'ts-loader' },
],
},
};

0 comments on commit 0eb1cbc

Please sign in to comment.
You can’t perform that action at this time.