Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
serverless-plugin-typescript
Advanced tools
[![serverless](http://public.serverless.com/badges/v3.svg)](http://www.serverless.com) [![npm version](https://badge.fury.io/js/serverless-plugin-typescript.svg)](https://badge.fury.io/js/serverless-plugin-typescript) [![Build Status](https://travis-ci.or
Originally developed by Prisma Labs, now maintained in scope of Serverless, Inc
Serverless plugin for zero-config Typescript support
export
, import
, async
, await
, Promise
, ...)sls package
, sls deploy
and sls deploy function
sls invoke local
+ --watch
modeserverless-offline
yarn add --dev serverless-plugin-typescript typescript
# or
npm install -D serverless-plugin-typescript typescript
Add the following plugin to your serverless.yml
:
plugins:
- serverless-plugin-typescript
See example folder for a minimal example.
tsconfig.json
The default tsconfig.json
file used by the plugin looks like this:
{
"compilerOptions": {
"preserveConstEnums": true,
"strictNullChecks": true,
"sourceMap": true,
"allowJs": true,
"target": "es5",
"outDir": ".build",
"moduleResolution": "node",
"lib": ["es2015"],
"rootDir": "./"
}
}
Note 1: The
outDir
androotDir
options cannot be overwritten.
Note 2: Don't confuse the
tsconfig.json
in this repository with the one mentioned above.
All files from package/include
will be included in the final build file. See Exclude/Include
Override what tsconfig.json to use with the following snippet in your severless.yaml
custom:
serverlessPluginTypescript:
tsConfigFileLocation: './tsconfig.build.json'
When using with Google Cloud Functions via the serverless-google-cloudfunctions
plugin, you simply have to provide a main
field in your package.json
:
{
// ...
"main": "handler.js",
// ..
}
And this plugin will automatically compile your typescript correctly. Note
that the field must refer to the compiled file name, namely, ending with a .js
extension.
If a main
field was not found, then this plugin will use index.js
. Before
compilation begins, it will check to see that the file indicated exists with a
.ts
extension before actually trying to compile it.
The normal Serverless deploy procedure will automatically compile with Typescript:
serverless create -t aws-nodejs
serverless deploy
The plugin integrates very well with serverless-offline to simulate AWS Lambda and AWS API Gateway locally.
Add the plugins to your serverless.yml
file and make sure that serverless-plugin-typescript
precedes serverless-offline
as the order is important:
plugins:
...
- serverless-plugin-typescript
...
- serverless-offline
...
Run serverless offline
or serverless offline start
to start the Lambda/API simulation.
In comparison to serverless offline
, the start
command will fire an init
and a end
lifecycle hook which is needed for serverless-offline
and e.g. serverless-dynamodb-local
to switch off resources (see below)
Configure your service the same as mentioned above, but additionally add the serverless-dynamodb-local
plugin as follows:
plugins:
- serverless-plugin-typescript
- serverless-dynamodb-local
- serverless-offline
Run serverless offline start
.
You can reduce the clutter generated by serverless-offline
with --dontPrintOutput
and
disable timeouts with --noTimeout
.
To run your compiled functions locally you can:
$ serverless invoke local --function <function-name>
Options are:
--function
or -f
(required) is the name of the function to run--watch
- recompile and run a function locally on source changes--path
or -p
(optional) path to JSON or YAML file holding input data--data
or -d
(optional) input dataYou can easily enable support for source-maps (making stacktraces easier to read) by installing and using the following plugin:
yarn add --dev source-map-support
// inside of your function
import 'source-map-support/register'
If you are using webpack (most likely). Add devtool: 'source-map'
to webpack.config.js
:
module.exports = {
.... snip ....
devtool: 'source-map',
.... snip ....
}
FAQs
[![serverless](http://public.serverless.com/badges/v3.svg)](http://www.serverless.com) [![npm version](https://badge.fury.io/js/serverless-plugin-typescript.svg)](https://badge.fury.io/js/serverless-plugin-typescript) [![Build Status](https://travis-ci.or
We found that serverless-plugin-typescript demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.