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 | |
echo "Starting PostgreSQL 11..." | |
docker run -it --rm \ | |
-e POSTGRES_PASSWORD=mysecretpassword \ | |
-v postgres11-data:/var/lib/postgresql/data \ | |
-p 5432:5432 \ | |
postgres:11 |
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 { Readable } from 'stream' | |
class ReadableString extends Readable { | |
private sent = false | |
constructor(private str: string) { | |
super(); | |
} | |
_read() { |
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 TestRenderer from 'react-test-renderer'; | |
let renderer: TestRenderer.ReactTestRenderer; | |
let instance: TestRenderer.ReactTestInstance; | |
beforeAll(() => { | |
renderer = TestRenderer.create( | |
<div> | |
<h2>My Super-sweet Component</h2> | |
<SomeComponent /> |
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
console.log(`Welcome to Briggsy's Awesome Quote Generator v1.5!`); | |
(async () => { | |
for (let i=0; i<3; i++) { | |
await getUserQuote(); | |
} | |
console.log('Profit!'); |
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
console.log(`Welcome to Briggsy's Awesome Quote Generator!`); | |
(async () => { | |
await getUserQuote(); | |
await getUserQuote(); | |
await getUserQuote(); | |
console.log('Profit!'); | |
})(); |
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 request from 'axios'; | |
async function getUserQuote() { | |
const userResponse = await request({ url: 'https://randomuser.me/api/', responseType: 'json' }); | |
console.log('Got User:', response.data); | |
const quoteResponse = await request({ url: 'http://quotes.rest/qod.json', responseType: 'json' }); | |
console.log('Got Quote:', response.data); |
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 request from 'axios'; | |
function getUserQuote() { | |
return request({ url: 'https://randomuser.me/api/', responseType: 'json' }) | |
.then((response) => { | |
console.log('Got User:', response.data); | |
return request({ url: 'http://quotes.rest/qod.json', responseType: 'json' }); | |
}) | |
.then((response) => { | |
console.log('Got Quote:', response.data); |
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 { createDemoData } from './models'; | |
... | |
console.log(`Server is running at http://localhost:${config.port}/`); | |
createDemoData().then(() => { | |
console.log('Demo Data Loaded!') | |
}); |
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
export async function createDemoData() { | |
const user1 = ( | |
await modelManager.create(new User({ | |
full_name: 'Russell Briggs', | |
email: '[email protected]' | |
})) | |
).result; | |
const user2 = ( | |
await modelManager.create(new User({ |
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 Koa from 'koa'; | |
import * as KoaRouter from 'koa-router'; | |
import { api } from './models'; | |
import { graphqlKoa, graphiqlKoa } from 'apollo-server-koa'; | |
export function registerRoutes(app: Koa) { | |
const router = new KoaRouter(); | |
const schema = api.getGraphQLSchema(); |
NewerOlder