Lemoncode /
react-typescript-samples
The goal of this project is to provide a set of simple samples, providing and step by step guide to start working with React and Typescript.
Loading repository data…
danielzotti / repository
A simple project to test AWS Lambda Functions & Layers written in TypeScript
A simple project to test AWS Lambda functions & Layers written in TypeScript
npm install -g serverlessOpen a terminal and run these commands:
cd layers # enter the layers foldernpm run build:all # install all dependencies and transpile TypeScript code into JScd ../test-layer # enter the lambda function foldernpm run first-start # install dependencies and run the lambda function locally using serverless offline pluginlayers the folder that contains all layers:
express-pg-moment an example layer that bundles 3rd parties modules
logging an example of a custom layer that logs messagestest-layer a simple lambda function that uses the two layers listed aboveTo test the Lambda function locally just type:
cd test-layernpm install if you have just cloned the repo)npm run start
sls offline startTo deploy the lambda that uses the layers using serverless just type:
cd test-layernpm run deploy -- --stage dev
npm installsls deployTo deploy all layers using serverless just type:
cd layersnpm run deploy -- --stage dev it builds all layers, and it deploys them
npm run installnpm run buildsls deployLayer must be exported wit TitleCase and LayerExport suffix: LoggingLayerExport
Layer name must be written with TitleCase and LambdaLayer suffix: LoggingLambdaLayer
in lambda layers serverless.yml:
sercice: layers
...
resources:
Outputs:
LoggingLayerExport:
Value:
Ref: LoggingLambdaLayer
Export:
Name: LoggingLambdaLayer-${self:provider.stage}
in lambda function serverless.yml:
functions:
functionName:
layers:
- ${cf:layers-${self:provider.stage}.LoggingLayerExport}
where layers is the service name and LoggingLayerExport is the resource name
Function layers must be added in package.json as devDependencies, in this way won't be deployed.
To prevent errors, custom dependencies must be excluded in the serverless.yml file
in package.json:
{
"devDependencies": {
"express": "^4.17.1",
"logging": "file:../layers/logging/dist/nodejs/node_modules/logging"
}
}
in serverless.yml:
package:
exclude:
- node_modules/logging
please note the difference from 3rd parties dependency (express) and custom dependency (logging)
As the AWS Layers doc, a NodeJs layer is deployed on nodejs/node_modules folder.
It's better to compile the TypeScript layer in Javascript and deploy only the compiled version.
This is why I've chosen the following folder structure for a layer written in TypeScript:
logging the root folder
dist contains the compiled code (JavaScript) and follows the folder structure specified in the AWS documentation
nodejs
node_modules
logging
src contains the source folder (TypeScript)node_modules contains dependencies to compile and manage the deploymentpackage.jon contains scripts to compile and deploy the layertsconfig.json manage the compilation processOnly the content of the dist folder will be deployed, as configured in the path field in serverless.yml:
layers:
logging:
path: logging/dist
description: Layer with a simple Logger
compatibleRuntimes:
- nodejs12.x
Selected from shared topics, language and repository description—not editorial ratings.
Lemoncode /
The goal of this project is to provide a set of simple samples, providing and step by step guide to start working with React and Typescript.
microsoft /
A guide for converting a simple JavaScript/React project to TypeScript. Contains both before an after code with the step-by-step process in the README below.
once-ui-system /
⚡ A simple Once UI setup for a new project. Just what's necessary, nothing else.
apexcharts /
ng-apexcharts is an implementation of apexcharts for angular. It comes with one simple component that enables you to use apexcharts in an angular project.
runejs /
RuneJS is a RuneScape game server written in TypeScript and JavaScript. The goal of the project is to create a comprehensive game engine, while also providing simple and easy to use content development systems and APIs.
adisreyaj /
Compito is a simple and easy to use project management application with support for Multiple orgs.