This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
| { | |
| ## deno extension settings | |
| "deno.enable": true, | |
| "deno.unstable": true, | |
| ## editor settings | |
| "editor.formatOnSave": true, | |
| "editor.formatOnPaste": true, | |
| "editor.defaultFormatter": "denoland.vscode-deno" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { readFile } from 'node:fs'; | |
| const readFileCallback = (err: Error | null, data: string | Buffer) => { | |
| if (err) { | |
| console.log(err); | |
| return; | |
| } | |
| // process data ... | |
| console.log(data.length); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type PromiseFunc = (...args: any[]) => Promise<any>; | |
| type TryCatch<Func extends PromiseFunc> = ( | |
| ...args: [...Parameters<Func>] | |
| ) => Promise<[Error | null, Awaited<ReturnType<Func>> | null]>; | |
| const trycatch = | |
| <Func extends PromiseFunc>(f: Func): TryCatch<Func> => async (...args) => { | |
| try { | |
| const v = await f(...args); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const readFile = async (file: string): Promise<string | Error> => { | |
| try { | |
| return await Deno.readTextFile(file); | |
| } catch (err) { | |
| return err; | |
| } | |
| }; | |
| const main = async () => { | |
| const file = Deno.env.get("FILE"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const readFile = async (file: string): Promise<[Error | null, string]> => { | |
| try { | |
| const text = await Deno.readTextFile(file); | |
| return [null, text]; | |
| } catch (err) { | |
| return [err, ""]; | |
| } | |
| }; | |
| const main = async () => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const readFile = async (file: string): Promise<string> => | |
| await Deno.readTextFile(file); | |
| const main = async () => { | |
| const file = Deno.env.get("FILE"); | |
| if (!file) { | |
| console.log("file name required."); | |
| return; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| ################################################################################ | |
| ## | |
| ## The following creates AWS resources for the project | |
| ## | |
| ################################################################################ | |
| . .env # populate parameters from .env file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| PROJECT=my-awesome-project | |
| TABLE=my-awesome-table | |
| API_RESOURCE=my-awesome-resource | |
| STAGE=some-stage | |
| FRONTEND_BUCKET_NAME=my-frontend-assets-bucket | |
| DISTRIBUTION_ENABLED=false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| AWSTemplateFormatVersion: '2010-09-09' | |
| Parameters: | |
| ProjectName: | |
| Description: Project name used to identify created AWS resources | |
| Type: String | |
| Resources: | |
| WebACL: | |
| Type: AWS::WAFv2::WebACL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Distribution: | |
| Type: AWS::CloudFront::Distribution | |
| Properties: | |
| DistributionConfig: | |
| Comment: !Sub ${ProjectName} project distribution | |
| DefaultCacheBehavior: | |
| AllowedMethods: | |
| - GET | |
| - HEAD | |
| - OPTIONS |