This file contains 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
|
This file contains 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 fs from 'fs'; | |
import path from 'path'; | |
export const write = ( | |
data: string, | |
filename: string, | |
dir: string = process.cwd(), | |
): Promise<string> => | |
new Promise((resolve, reject) => { | |
const dest = path.resolve(`${dir}/${filename}`); |
This file contains 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
// The filter() method creates a new array filled with elements that pass a test provided by a function | |
[1, 2, 3, 4, 5].filter((n) => n > 3); // [4,5] | |
// The find() method returns the value of the first element that passes the test | |
[1, 2, 3, 4, 5].find((n) => n > 3); // 4 | |
//. The every() method tests whether all elements in the array pass the test implemented by the provided function. It returns a Boolean value. | |
[1, 30, 39, 29, 10, 34].every((n) => n < 40); // true |
This file contains 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 myObj = { firstName: 'John', lastName: 'Doe' }; | |
for (const [key, value] of Object.entries(myObj)) { | |
console.log(`${key} ${value}`); // John Doe | |
} |
This file contains 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
name: Build and deploy | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-18.04 | |
strategy: |
This file contains 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
cd ~/dynamodb_local_latest | |
java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb | |
aws dynamodb create-table \ | |
--endpoint-url http://localhost:8000 \ | |
--table-name pricing-api-tst-menu-dyn \ | |
--attribute-definitions \ | |
AttributeName=id,AttributeType=S \ | |
AttributeName=storeId,AttributeType=S \ | |
--key-schema \ |
This file contains 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 util from 'util'; | |
console.log(util.inspect(myObject, false, null, true /* enable colors */)) |
This file contains 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 { describe, it } from 'mocha'; | |
import chai, { expect } from 'chai'; | |
import chaiAsPromised from 'chai-as-promised'; | |
chai.use(chaiAsPromised); | |
describe('Example', () => { | |
it('should return 404', () => | |
expect(foo()).to.eventually.be.rejected | |
.and.be.an.instanceOf(Error) |
This file contains 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 | |
# You may want to remove the `--endpoint-url http://localhost:8000` line for actual AWS deployment | |
aws dynamodb create-table \ | |
--endpoint-url http://localhost:8000 \ | |
--table-name exampleTableName \ | |
--attribute-definitions \ | |
AttributeName=id,AttributeType=S \ | |
AttributeName=status,AttributeType=S \ | |
AttributeName=createdDateTime,AttributeType=S \ | |
--key-schema \ |
This file contains 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 * as httpInterceptor from 'global-request-logger'; | |
const debug = require('debug')('my:app'); | |
if(process.env.DEBUG){ | |
httpInterceptor.initialize(); | |
httpInterceptor.on('success', (req, res) => { | |
const protocol = (req.port === 443 ? 'https://' : 'http://'); |
NewerOlder