Giter Club home page Giter Club logo

serverless-typescript-boilerplate's Introduction

⚡️ Serverless Typescript Boilerplate ⚡️

Minimalist but yet supercharged project template to jump start a Serverless application in TypeScript.

Motivation

Serverless is awesome : no more server to setup, ultra scalable and very cheap. But getting started can be intimidating. The boilerplate will save you a considerable amount of time and energy.

Keys features

The current Serverless Starter Kit adds a light layer on top of the Serverless framework with modern JavaScript tools:

  • Babel / Webpack Support so you can use the Modern ESNext features.
  • TypeScript Support.
  • Unit testing with Jest and code coverage
  • Linting with Eslint
  • Offline mode
  • Full CRUD DynamoDB
  • Formatting with Prettier to enforce a consistent code style.
  • ESLint and Prettier are both run on git commit thanks to husky and lint-staged.

Services

Currently, the boilerplate is built and tested on AWS using the following services.

  • AWS Lambda
  • Amazon DynamoDB
  • Amazon Cognito
  • Amazon S3 (in progress)
  • Amazon CloudFront (in progress)

Quick start

nvm use
npm install
# Amend your AWS profile in the [serverless.yml](serverless.yml) file. Search for YOUR_PROFILE.
npm run deploy

Testing

Jest Unit Testing

npm run test:unit

Integration

Commands

Local

npm run local

Quick local script running

To run the hello function with the event data defined in fixtures/event.json (with live reloading), run:

npm run watch:hello

Logs

Going to the AWS lambda console is slow and not really user-friendly. You can retrieve the log from your deployed AWS Lambda from your project's command line.

"tail:hello:dev": "serverless logs --function hello --tail --stage dev --aws-profile <your profile>"

Deploy individually

npm run deploy:hello

More

  • npm run clean: remove coverage data, Jest cache and transpiled files.
  • npm run lint: lint source files and tests.
  • npm test: run tests.

Serverless plugins

Files structure

webpack.config.js: Webpack default config file

TODO

License

Serverless Boilerplate is MIT licensed.

serverless-typescript-boilerplate's People

Contributors

targoo avatar

Stargazers

Grigore Budac avatar Iqbal DP avatar Kai Barzen avatar  avatar Sergio Sicari avatar Yatin Badal avatar  avatar

Watchers

James Cloos avatar Francois Paquette avatar Hamza Waheed avatar

Forkers

aswin-scalex

serverless-typescript-boilerplate's Issues

allocation failure scavenge might not succeed

Just by adding few more resource and lambdas, here is memory leak error, any suggestions ?

`<--- Last few GCs --->

[66020:0x102d52000] 1355018 ms: Mark-sweep 14282.0 (14334.6) -> 14281.2 (14334.4) MB, 58664.4 / 0.2 ms (average mu = 0.058, current mu = 0.003) allocation failure scavenge might not succeed
[66020:0x102d52000] 1355108 ms: Scavenge 14282.1 (14334.4) -> 14281.4 (14334.9) MB, 57.2 / 0.0 ms (average mu = 0.058, current mu = 0.003) allocation failure

<--- JS stacktrace --->

==== JS stack trace =========================================

0: ExitFrame [pc: 0x1009d39b9]
1: StubFrame [pc: 0x100955380]

Security context: 0x194b572808d1
2: addJSDocComment(aka addJSDocComment) [0x194bdb017f29] [/Users/xxx/Dev/next-gen/core-api/node_modules/typescript/lib/typescript.js:~19840] [pc=0x222d3bace007](this=0x194b34c404b1 ,0x194b63d62669 )
3: parseTypeMember(aka parseTypeMember) [0x194bdb0198a9] [/Users/xxx/De...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 0x1011c2ff5 node::Abort() (.cold.1) [/Users/xxx/.nvm/versions/node/v12.18.3/bin/node]
2: 0x10009fbc9 node::Abort() [/Users/xxx/.nvm/versions/node/v12.18.3/bin/node]
3: 0x10009fd2f node::OnFatalError(char const*, char const*) [/Users/xxx/.nvm/versions/node/v12.18.3/bin/node]
4: 0x1001e3907 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/Users/xxx/.nvm/versions/node/v12.18.3/bin/node]
5: 0x1001e38a7 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/Users/xxx/.nvm/versions/node/v12.18.3/bin/node]
6: 0x1003695e5 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/Users/xxx/.nvm/versions/node/v12.18.3/bin/node]
7: 0x10036ae3a v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [/Users/xxx/.nvm/versions/node/v12.18.3/bin/node]
8: 0x1003678be v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/Users/xxx/.nvm/versions/node/v12.18.3/bin/node]
9: 0x100365670 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/Users/xxx/.nvm/versions/node/v12.18.3/bin/node]
10: 0x10037149a v8::internal::Heap::AllocateRawWithLightRetry(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/Users/xxx/.nvm/versions/node/v12.18.3/bin/node]
11: 0x100371521 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/Users/xxx/.nvm/versions/node/v12.18.3/bin/node]
12: 0x10033f73a v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/Users/xxx/.nvm/versions/node/v12.18.3/bin/node]
13: 0x10068e808 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/Users/xxx/.nvm/versions/node/v12.18.3/bin/node]
14: 0x1009d39b9 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit [/Users/xxx/.nvm/versions/node/v12.18.3/bin/node]
sh: line 1: 66020 Abort trap: 6 serverless deploy --stage dev --verbose
npm ERR! code ELIFECYCLE
npm ERR! errno 134
npm ERR! [email protected] deploy: export NODE_OPTIONS=--max_old_space_size=14312 && serverless deploy --stage dev --verbose
npm ERR! Exit status 134
npm ERR!
npm ERR! Failed at the [email protected] deploy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/rasikh/.npm/_logs/2020-07-24T12_55_05_600Z-debug.log`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.