Skip to content

Latest commit

 

History

History
235 lines (155 loc) · 4.82 KB

README.md

File metadata and controls

235 lines (155 loc) · 4.82 KB

entities-monorepo

serverless npm peer dependency version (scoped) code style: prettier

Table of contents


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.17.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


Install project dependencies

  • Using Yarn
yarn
Generate a new stack
nx workspace-generator serverless <STACK_NAME>

Set the basePath of the custom domain manager for each new stack in serverless.ts file

Stack name shouldn't include special characters or whitespaces

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

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

Stack name shouldn't include special characters or whitespaces

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

    ```shell
    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

    ```shell
    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

      ```shell
      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

      ```shell
      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

      ```shell
      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

    Currently not active