-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from nfroidure/feat/aws_lambda_build
feat(@whook/aws-lambda): add AWS lambda to the build
- Loading branch information
Showing
41 changed files
with
2,551 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
The MIT License (MIT) | ||
Copyright © 2017 Nicolas Froidure | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the “Software”), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
[//]: # ( ) | ||
[//]: # (This file is automatically generated by a `metapak`) | ||
[//]: # (module. Do not change it except between the) | ||
[//]: # (`content:start/end` flags, your changes would) | ||
[//]: # (be overridden.) | ||
[//]: # ( ) | ||
# @whook/aws-lambda | ||
> Build and deploy to AWS Lambda with Whook. | ||
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/nfroidure/whook/blob/master/packages/whook-aws-lambda/LICENSE) | ||
[![NPM version](https://badge.fury.io/js/%40whook%2Faws-lambda.svg)](https://npmjs.org/package/@whook/aws-lambda) | ||
|
||
|
||
[//]: # (::contents:start) | ||
|
||
This module is aimed to help you to deploy your Whook server | ||
to AWS Lambda. | ||
|
||
## Testing commands | ||
|
||
Building lambdas is done by creating the build script in your project `bin` | ||
folder : | ||
```sh | ||
cat "#! /usr/bin/env node | ||
const { runBuild } = require('../dist/index'); | ||
runBuild(); | ||
" > bin/build.js | ||
``` | ||
|
||
And add create the runBuild function in you `index.ts` main file : | ||
```diff | ||
+ import { | ||
+ initBuildConstants, | ||
+ runBuild as runBaseBuild, | ||
+ prepareBuildEnvironment as prepareBaseBuildEnvironment, | ||
+ } from '@whook/aws-lambda'; | ||
+ | ||
+ // The `runBuild` function is intended to build the | ||
+ // project | ||
+ | ||
+ export async function runBuild( | ||
+ innerPrepareEnvironment = prepareBuildEnvironment, | ||
+ ): Promise<void> { | ||
+ return runBaseBuild(innerPrepareEnvironment); | ||
+ } | ||
+ | ||
+ export async function prepareBuildEnvironment( | ||
+ $: Knifecycle = new Knifecycle(), | ||
+ ): Promise<Knifecycle> { | ||
+ $ = await prepareEnvironment($); | ||
+ $ = await prepareBaseBuildEnvironment($); | ||
+ | ||
+ $.register( | ||
+ constant('INITIALIZER_PATH_MAP', { | ||
+ ENV: require.resolve('@whook/aws-lambda/dist/services/ENV'), | ||
+ log: require.resolve('@whook/aws-lambda/dist/services/log'), | ||
+ apm: require.resolve('@whook/http-transaction/dist/services/apm'), | ||
+ obfuscator: require.resolve( | ||
+ '@whook/http-transaction/dist/services/obfuscator', | ||
+ ), | ||
+ time: require.resolve('common-services/dist/time'), | ||
+ delay: require.resolve('common-services/dist/delay'), | ||
+ }), | ||
+ ); | ||
+ $.register(alsoInject(['API_DEFINITIONS'], initBuildConstants)); | ||
+ | ||
+ return $; | ||
+ } | ||
``` | ||
|
||
Also add the following line in your `package.json` file : | ||
```diff | ||
scripts: { | ||
+ "build": "NODE_ENV=${NODE_ENV:-development} node bin/build", | ||
}, | ||
devDependencies: { | ||
+ "@whook/aws-lambda": "^3.1.3", | ||
+ "@whook/http-transaction": "^3.1.3", | ||
+ "babel-loader": "^8.0.6", | ||
+ "babel-plugin-knifecycle": "^1.1.1", | ||
+ "webpack": "4.41.5", | ||
} | ||
``` | ||
|
||
To build your lambdas : | ||
```sh | ||
# Build all lambdas | ||
npm run compile && npm run build | ||
# Build only one lambda | ||
npm run compile && npm run build -- getPing | ||
``` | ||
|
||
You can easily test your lambda builds by adding `@whook/aws-lambda` | ||
to your `WHOOK_PLUGINS` list. It provides you some commands like | ||
the `testHTTPLambda` one: | ||
```sh | ||
npm run whook -- testHTTPLambda --name getPing | ||
``` | ||
|
||
[//]: # (::contents:end) | ||
|
||
# Authors | ||
- [Nicolas Froidure](http://insertafter.com/en/index.html) | ||
|
||
# License | ||
[MIT](https://github.com/nfroidure/whook/blob/master/packages/whook-aws-lambda/LICENSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,188 @@ | ||
{ | ||
"name": "@whook/aws-lambda", | ||
"version": "3.1.3", | ||
"description": "Build and deploy to AWS Lambda with Whook.", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"metapak": { | ||
"configs": [ | ||
"main", | ||
"readme", | ||
"eslint", | ||
"babel", | ||
"jest", | ||
"jsdocs", | ||
"typescript" | ||
], | ||
"data": { | ||
"childPackage": true, | ||
"files": "'src/**/*.ts'", | ||
"testsFiles": "'src/**/*.test.ts'", | ||
"ignore": [ | ||
"dist" | ||
], | ||
"bundleFiles": [ | ||
"dist", | ||
"src" | ||
] | ||
} | ||
}, | ||
"author": { | ||
"name": "Nicolas Froidure", | ||
"email": "nicolas.froidure@insertafter.com", | ||
"url": "http://insertafter.com/en/index.html" | ||
}, | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/nfroidure/whook.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/nfroidure/whook/issues" | ||
}, | ||
"homepage": "https://github.com/nfroidure/whook", | ||
"peerDependencies": { | ||
"babel-loader": "^8.0.6", | ||
"babel-plugin-knifecycle": "^1.1.1", | ||
"webpack": "4.41.5" | ||
}, | ||
"dependencies": { | ||
"@whook/cli": "3.1.3", | ||
"@whook/http-router": "3.1.3", | ||
"@whook/whook": "3.1.3", | ||
"ajv": "^6.11.0", | ||
"camel-case": "^4.1.1", | ||
"common-services": "^6.2.0", | ||
"cpr": "3.0.1", | ||
"memfs": "3.0.4", | ||
"memory-fs": "0.5.0", | ||
"qs": "^6.9.1", | ||
"knifecycle": "^8.1.0", | ||
"openapi-types": "^1.3.5", | ||
"yerror": "^5.0.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "^7.8.3", | ||
"@babel/core": "^7.8.3", | ||
"@babel/plugin-proposal-class-properties": "^7.8.3", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.8.3", | ||
"@babel/preset-env": "^7.8.3", | ||
"@babel/preset-typescript": "^7.8.3", | ||
"@babel/register": "^7.8.3", | ||
"@types/jest": "^24.9.0", | ||
"@typescript-eslint/eslint-plugin": "^2.16.0", | ||
"@typescript-eslint/parser": "^2.16.0", | ||
"babel-eslint": "^10.0.3", | ||
"babel-plugin-knifecycle": "^1.1.1", | ||
"eslint": "^6.8.0", | ||
"eslint-plugin-prettier": "^3.1.2", | ||
"jest": "^24.9.0", | ||
"jsdoc-to-markdown": "^5.0.3", | ||
"metapak": "^3.1.7", | ||
"metapak-nfroidure": "9.8.2", | ||
"prettier": "^1.19.1", | ||
"rimraf": "^3.0.1", | ||
"typescript": "^3.7.5" | ||
}, | ||
"contributors": [], | ||
"engines": { | ||
"node": ">=8.12.0" | ||
}, | ||
"files": [ | ||
"dist", | ||
"src", | ||
"LICENSE", | ||
"README.md", | ||
"CHANGELOG.md" | ||
], | ||
"eslintConfig": { | ||
"extends": "eslint:recommended", | ||
"parserOptions": { | ||
"ecmaVersion": 2018, | ||
"sourceType": "module", | ||
"modules": true | ||
}, | ||
"env": { | ||
"es6": true, | ||
"node": true, | ||
"jest": true, | ||
"mocha": true | ||
}, | ||
"plugins": [ | ||
"prettier" | ||
], | ||
"rules": { | ||
"prettier/prettier": "error" | ||
}, | ||
"parser": "@typescript-eslint/parser", | ||
"ignorePatterns": [ | ||
"*.d.ts" | ||
], | ||
"overrides": [ | ||
{ | ||
"files": [ | ||
"*.ts" | ||
], | ||
"rules": { | ||
"no-unused-vars": [ | ||
1, | ||
{ | ||
"args": "none" | ||
} | ||
] | ||
} | ||
} | ||
] | ||
}, | ||
"prettier": { | ||
"semi": true, | ||
"printWidth": 80, | ||
"singleQuote": true, | ||
"trailingComma": "all", | ||
"proseWrap": "always" | ||
}, | ||
"babel": { | ||
"presets": [ | ||
"@babel/typescript", | ||
[ | ||
"@babel/env", | ||
{ | ||
"targets": { | ||
"node": "8.12.0" | ||
} | ||
} | ||
] | ||
], | ||
"plugins": [ | ||
"@babel/proposal-class-properties", | ||
"@babel/plugin-proposal-object-rest-spread", | ||
"babel-plugin-knifecycle" | ||
] | ||
}, | ||
"jest": { | ||
"coverageReporters": [ | ||
"lcov", | ||
"html" | ||
], | ||
"testPathIgnorePatterns": [ | ||
"/node_modules/" | ||
], | ||
"roots": [ | ||
"<rootDir>/src" | ||
] | ||
}, | ||
"scripts": { | ||
"cli": "env NODE_ENV=${NODE_ENV:-cli}", | ||
"compile": "babel --extensions '.ts,.js' src --out-dir=dist --source-maps=true", | ||
"cover": "npm run jest -- --coverage", | ||
"doc": "echo \"# API\" > API.md; jsdoc2md undefined >> API.md && git add API.md", | ||
"jest": "NODE_ENV=test jest", | ||
"lint": "eslint 'src/**/*.ts'", | ||
"metapak": "metapak", | ||
"precz": "npm run compile", | ||
"prettier": "prettier --write 'src/**/*.ts'", | ||
"preversion": "npm run compile", | ||
"test": "npm run jest", | ||
"types": "rimraf -f 'dist/**/*.d.ts' && tsc --project . --declaration --emitDeclarationOnly --outDir dist" | ||
} | ||
} |
Oops, something went wrong.