NetanelBasal / nx-serverless

Modern Serverless framework template using Nrwl Nx monorepo dev tools

Home Page:https://github.com/sudokar/nx-serverless

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nx-serverless-template

serverless esbuild npm peer dependency version (scoped) code style: prettier GitHub license Percentage of issues still open PRs Welcome Maintained

TypeScript GitHub Actions

A monrepo style, modern boilerplate or template project for Serverless framework using Nx monorepo toolkit πŸ›  and aws-nodejs-typesript serverless template

Table of contents

Whats Included

  • A template project layout using latest version of Nx and Servrless framework
  • An easy to use workspace generator to generate a template/stack with Serverless framework files and related Nx configuration
  • Configured with AWS provider and it can be easily adopted to any cloud provider

Template Layout

.
β”œβ”€β”€ stacks/    # stack for each serverless configuration/template and its associated files
β”œβ”€β”€ libs/      # shared libraries
β”œβ”€β”€ tools/
β”œβ”€β”€ README.md
β”œβ”€β”€ jest.config.js
β”œβ”€β”€ jest.preset.js
β”œβ”€β”€ nx.json
β”œβ”€β”€ package.json
β”œβ”€β”€ serverless.base.ts  # base configuration for serverless
β”œβ”€β”€ tsconfig.base.json
β”œβ”€β”€ workspace.json
β”œβ”€β”€ .editorconfig
β”œβ”€β”€ .eslintrc.json
β”œβ”€β”€ .gitignore
β”œβ”€β”€ .husky              # git hooks
β”œβ”€β”€ .nvmrc
β”œβ”€β”€ .prettierignore
β”œβ”€β”€ .prettierrc

Prerequisites

  • Nodejs protip: use nvm

    ⚠️ Version: lts/fermium (v.14.x.x). If you're using nvm, run nvm use to ensure you're using the same Node version in local and in your lambda's runtime.

  • πŸ“¦ Package Manager

    • Yarn

      (or)

    • NPM Pre-installed with Nodejs

  • πŸ’… Code format plugins

    On your preferred code editor, Install plugins for the above list of tools

Usage

Depending on your prefrered package manager, follow the instructions below to build and deploy serverless stack(s).

  • Install project dependencies

    • Using NPM

      npm i
    • Using Yarn

      yarn
  • Generate a new stack

    nx workspace-generator serverless <STACK_NAME>

    Run with -d or --dry-run flag for dry run

  • Generate a new library

    nx g @nrwl/node:lib --skipBabelrc --tags lib <LIBRARY_NAME>

    Run with -d or --dry-run flag for dry run

  • Package stack

    • To package single stack

      nx run <STACK_NAME>:build --stage=<STAGE_NAME>
    • To package stack affected by a change

      nx affected:build --stage=<STAGE_NAME>
    • To package all stacks

      nx run-many --target=build --stage=<STAGE_NAME>
  • Deploy stack to cloud

    • To deploy single stack

      nx run <STACK_NAME>:deploy --stage=<STAGE_NAME>
    • To deploy stack affected by a change

      nx affected:deploy --stage=<STAGE_NAME>
    • To deploy all stacks

      nx run-many --target=deploy --all --stage=<STAGE_NAME>
  • Remove stack from cloud

    • To remove single stack

      nx run <STACK_NAME>:remove --stage=<STAGE_NAME>
    • To remove stack affected by a change

      nx affected:remove --stage=<STAGE_NAME>
    • To remove all stacks

      nx run-many --target=remove --all --stage=<STAGE_NAME>
  • Run tests

    • To run tests in single stack

      nx run <STACK_NAME>:test --stage=<STAGE_NAME>
    • To run tests affected by a change

      nx affected:test --stage=<STAGE_NAME>
    • To run tests in all stacks

      nx run-many --target=test --all --stage=<STAGE_NAME>
  • Run offline / locally

    • To run offlline, configure serverless-offline plugin as documented here and run below command

      nx run <STACK_NAME>:serve --stage=<STAGE_NAME>
  • Understand your workspace

    nx dep-graph
    

Further help

Nx Cloud

Computation Memoization in the Cloud

​ Nx Cloud pairs with Nx in order to enable you to build and test code more rapidly, by up to 10 times.

​ Visit Nx Cloud to learn more and enable it

Contribution

Found an issue? feel free to raise an issue with information to reproduce.

Pull requests are welcome to improve.

Support

Like the template?

Buy Me A Coffee

Or, Add a star ⭐ to the repository

Or, Simply use it πŸ˜ƒ

Maintainer

This template is authored and maintained by sudokar

License

MIT

About

Modern Serverless framework template using Nrwl Nx monorepo dev tools

https://github.com/sudokar/nx-serverless

License:MIT License


Languages

Language:TypeScript 94.1%Language:JavaScript 3.7%Language:Shell 2.3%