Installations
npm install @ns3/nx-serverless
Developer Guide
Typescript
Yes
Module System
CommonJS
Min. Node Version
>=16.6.0
Node Version
20.18.0
NPM Version
10.8.2
Releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (99.37%)
JavaScript (0.32%)
Shell (0.31%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
Bielik20
Download Statistics
Total Downloads
1,361,384
Last Day
937
Last Week
4,786
Last Month
19,849
Last Year
461,905
GitHub Statistics
MIT License
62 Stars
314 Commits
22 Forks
6 Watchers
1 Branches
8 Contributors
Updated on Jan 12, 2025
Bundle Size
96.39 kB
Minified
28.92 kB
Minified + Gzipped
Package Meta Information
Latest Version
5.6.0
Package Id
@ns3/nx-serverless@5.6.0
Unpacked Size
75.80 kB
Size
20.80 kB
File Count
81
NPM Version
10.8.2
Node Version
20.18.0
Published on
Oct 23, 2024
Total Downloads
Cumulative downloads
Total Downloads
1,361,384
Last Day
10.8%
937
Compared to previous day
Last Week
11.7%
4,786
Compared to previous week
Last Month
23.7%
19,849
Compared to previous month
Last Year
-31.8%
461,905
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
NX Serverless
A simple plugin for running sls commands in nx monorepo. It executes serverless commands in specific app directory. It is configured to support nx cache out of the box for build and deploy commands.
Install
npm i -D @ns3/nx-serverless
Generate
serverless-esbuild
Default plugin used in generation is serverless-esbuild
.
It supports all providers, nx cache as far as output of serverless is concerned, but it doesn't work with incremental builds.
nx generate @ns3/nx-serverless:app my-app-name
@ns3/nx-serverless/plugin
⚠️ Warning: this plugin is experimental and can change without major version bump.
You can opt in to use experimental @ns3/nx-serverless/plugin
.
It supports only aws
as a provider, but works both with nx cache and incremental build.
It uses @nx/webpack:webpack
executor to compile the code and is independent of serverless framework.
To achieve that it uses withPatterns
plugin to find which files to compile.
It means that you need to create and follow file naming pattern for your handlers.
The default one is './src/handlers/**/handler.ts'
You can use withExternals
plugin to exclude certain dependencies from the bundle (default /^@aws-sdk\//
excludes aws sdk in v3).
nx generate @ns3/nx-serverless:app my-app-name --plugin @ns3/nx-serverless/plugin
Rationale: making build step independent of serverless framework allows us to cache build process. This means that changing serverless config won't trigger rebuild of the whole app. It makes it also easy to replace webpack with other bundler like rspack etc.
Webpack Alternative
If you want to use executor for build other than @nx/webpack you can.
The only requirement is for build executor to have outputPath
option defined and support for --watch
flag.
Of course, you will have to provide equivalent of withPatterns
and withExternals
plugins.
Available commands
nx run my-app-name:package
nx run my-app-name:serve
nx run my-app-name:deploy
nx run my-app-name:remove
nx run my-app-name:lint
nx run my-app-name:test
Stage
To control Serverless stage
param you can use
⚠️ Flag
--stage
flag, but that won't get forwarded to dependant tasks.
1nx run my-app-name:deploy --stage my-stage
✅ Env Variable
STAGE
env variable, package
and deploy
targets are configured to take it into account.
As a bonus you can use it later to also configure e2e tests for your service etc.
1STAGE=my-stage nx run my-app-name:deploy
Custom commands
Should you need a more specific command that is not included you can run it like:
nx run my-app-name:sls logs
nx run my-app-name:sls invoke local
All arguments are forwarded.
If there is an argument that conflicts with Nx or this executor simply suffix it with _
.
For example:
- instead of
--help
- use
--help_

No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
6 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-7q7g-4xm8-89cq
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
- Warn: Project is vulnerable to: GHSA-rhx6-c78j-4q9w
- Warn: Project is vulnerable to: GHSA-c76h-2ccp-4975
Reason
Found 1/7 approved changesets -- score normalized to 1
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/check.yml:1
- Warn: no topLevel permission defined: .github/workflows/publish.yml:1
- Warn: no topLevel permission defined: .github/workflows/release.yml:1
- Info: no jobLevel write permissions found
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/check.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/Bielik20/nx-plugins/check.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/check.yml:41: update your workflow using https://app.stepsecurity.io/secureworkflow/Bielik20/nx-plugins/check.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/Bielik20/nx-plugins/publish.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/Bielik20/nx-plugins/release.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/Bielik20/nx-plugins/release.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:35: update your workflow using https://app.stepsecurity.io/secureworkflow/Bielik20/nx-plugins/release.yml/master?enable=pin
- Info: 0 out of 4 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 2 third-party GitHubAction dependencies pinned
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 30 are checked with a SAST tool
Score
3
/10
Last Scanned on 2025-02-10
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More