Skip to content

mtimbs/typescript-serverless

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 

typescript-serverless

Base template for serverless framework with typescript, eslint and jest preconfigured

This repository comes pre-configured with some common tools and configuration for working serverless frameowrk and Typescript with AWS.

A full breakdown of this setup can be found here

Serverless Plugins

  • serverless-iam-roles-per-function
  • serverless-create-global-dynamodb-table
  • serverless-offline

Lambda PowerTools

  • @dazn/lambda-powertools-cloudwatchevents-client
  • @dazn/lambda-powertools-correlation-ids
  • @dazn/lambda-powertools-logger
  • @dazn/lambda-powertools-pattern-basic
  • @dazn/lambda-powertools-lambda-client
  • @dazn/lambda-powertools-sns-client
  • @dazn/lambda-powertools-sqs-client
  • @dazn/lambda-powertools-dynamodb-client
  • @dazn/lambda-powertools-kinesis-client

Linting

  • eslint
  • eslint-config-airbnb-base
  • typescript-eslint
  • eslint-plugin-import
  • @typescript-eslint/eslint-plugin
  • @typescript/eslint-parser
  • eslint-import-resolver-alias
  • eslint-plugin-module-resolver

Testing

  • jest
  • babel-jest
  • @babel/core
  • @babel/preset-env
  • @babel/preset-typescript

A default test is included to verify that jest is configured correctly

describe('who tests the tests?', () => {
  it('can run a test', () => {
    expect.hasAssertions();
    expect(1).toBe(1);
  });
});

Module Aliasing

Everything comes configured out the box to leverage module aliasing. 3 example aliases have been preconfigured.

Aliases must be defined in webpack, tsconfig, and eslint

webpack:

resolve: {
  extensions: ['.mjs', '.json', '.ts'],
  symlinks: false,
  cacheWithContext: false,
  alias: {
    '@src': path.resolve(__dirname, './src'),
    '@queries': path.resolve(__dirname, './queries'),
    '@tests': path.resolve(__dirname, './tests'),
  },
},

tsconfig:

"paths": {
  "@src/*": ["src/*"],
  "@queries/*": ["queries/*"],
  "@tests/*": ["tests/*"]
}

eslint:

"settings": {
  "import/resolver": {
    "alias": {
      "map": [
        ["@src", "./src"],
        ["@tests", "./tests"],
        ["@queries", "./queries"]
      ],
      "extensions": [
        ".ts",
        ".js"
      ]
    }
  }
}

About

Base template for serverless framework with typescript, eslint and jest preconfigured

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published