slak
v1.0.2
Published
Generator for a Serverless application using Typescript on AWS Lambda
Downloads
2
Readme
the Serverless App Kit
Cousin of Rak, Slak bootstraps a Serverless project for building Lambda functions with Typescript in a joyous environment.
Features include:
- TypeScript, for safe programming
- TSLint and Prettier, to promote good code style
- Jest, for unit testing
- TS-Node, for debugging
- Webpack, to bundle your functions
- Serverless, to manage deployment and provisioning
- Node 12 LTS, for the fastest startup and execution possible
- N|Solid, for profiling in production with minimal overhead
- Builtin logging utils and project structure for getting moving fast
Start a Slak project
It's easiest to use Slak with npx
- that way, you won't need to install any dependencies to get started. In an empty folder, run:
npx slak my-new-project-name
Slak will template out the files you need for your application and install its dependencies.
Contribute changes to Slak
Most of the files in this repository are templates. To make changes to the app that Slak sets up for you initially, the recommended workflow is to run Slak to template those files out into a real app, make the changes and test them, and then convert the built files back into templates using hygen-create
. The basic workflow looks like:
Template out a new Slak app
npx slak my-new-lambda
Make some changes in the templated app, e.g., adding a new util file
echo "module.exports = {};" > src/utils/newUtil.ts
Make
hygen-create
aware of the new filenpx hygen-create add src/utils/newUtil.ts
Generate the templates again, merging them with the existing ones at the location you specify
yarn upstream ~/code/slak/_templates
This works because Slak adds a hygen-create.json
to the templated app, marking it as a hygen-create project in-session. Don't delete this file.
Executing tasks on the templates
It's possible to run anything you would normally run as a yarn run
command on the templates without creating a new project first using the yarn tpl
command. tpl
sets up a new project in a /tmp
directory, then invokes yarn run
there. For example, to run the package.json
-defined test
script on the current state of the templates:
yarn tpl test
This command will even clean up the /tmp
folder after.
Making changes and executing tasks
Combining the two above processes is easy, if you want to run a command on the files that the template would produce and then save file changes effected by that command back to the templates. Simply pass the --upstream
argument to yarn tpl
, e.g.:
yarn tpl upgrade-interactive --latest --upstream
After selecting packages to upgrade, this command would update the template versions of package.json and yarn.lock.