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 { Entity, PrimaryGeneratedColumn, Column } from 'typeorm'; | |
@Entity() | |
export class List { | |
@PrimaryGeneratedColumn() | |
id: number; | |
@Column() | |
name: string; | |
} |
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 { Entity, PrimaryGeneratedColumn, Column } from 'typeorm'; | |
@Entity() | |
export class TodoItem { | |
@PrimaryGeneratedColumn() | |
id: number; | |
@Column() | |
name: string; |
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
// states of h2o | |
type h2o = 'water'|'steam'|'ice' | |
// states of h2o that will pass through a filter | |
type filter = 'water'|'steam' | |
// Extract non solid forms of h2o | |
type nonSolidH2o = Extract<h2o, filter> | |
// these are fine, they are not solid | |
const water: nonSolidH2o = 'water' |
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 EventEMitter3 from 'eventemitter3' | |
interface EmitterEvent<Type extends string> extends Object { | |
type: Type; | |
} | |
interface AEvent extends EmitterEvent<'a'>{ | |
aOnly: 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
/*************************** | |
* configuration | |
* the commands below should line up with your npm run scripts. | |
*/ | |
const initDbCommand = 'initIntegrationDB' | |
const startServerInIntegrationModeCommand = 'start:integration' | |
const apiPort = process.env.API_PORT || 3200 | |
const jestCommand = 'jest:integration' | |
// After starting the server, it must console.log a string we can listen too, |
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
// see https://github.com/request/request-promise | |
const requestPromise = require('request-promise') | |
// in case you want to mess with where the integration test happens | |
const api = process.env.API_URL || 'http://localhost:3200' | |
/************************************************************************ | |
* Test Setup Functions | |
* These functions make our actual tests much shorter and readable | |
************************************************************************/ |
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
// package.json | |
// note that comments aren't typically allowed. | |
{ | |
"scripts": { | |
// recreate the dev database | |
"initDB": "rm dev.sqlite3; knex migrate:latest; knex seed:run", | |
// recreate the integration database | |
"initIntegrationDB": "export DATABASE_FILE=integration.sqlite3; rm integration.sqlite3; knex migrate:latest; knex seed:run", | |
// start the service on port 3000 | |
"start": "node index.js", |
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
// migrations/20170819134815_products.js | |
// Initial migration which adds the products table | |
exports.up = function (knex, Promise) { | |
return knex.schema.createTable('products', function (t) { | |
t.increments('id').unsigned().primary() | |
t.string('name').notNull() | |
t.text('description').nullable() | |
t.decimal('price', 6, 2).notNull() | |
}) |
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": "docker-db-example", | |
"scripts": { | |
"initDocker": "docker run --name snapshot-test-postgres -e POSTGRES_PASSWORD=developPassword -d postgres", | |
"destroyDocker": "docker stop snapshot-test-postgres; docker rm snapshot-test-postgres" | |
} | |
} |
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
// silent because by default shelljs copies output to your main | |
// terminal output. async because shelljs blocks by default. | |
const {stdout, stderr} = shelljs.exec('ping www.google.com', {silent: true, async: true}) |
NewerOlder