Skip to content

Instantly share code, notes, and snippets.

import {IBaseProtocol} from 'pg-promise';
import cfg from '../app-config';
import * as pgp from 'pg-promise';
import * as types from './admin-api-types';
import {Auth} from './auth';
import {InvalidRequest, AccessDenied} from './errors';
import * as path from 'path';
const requestTypes:string[] = types.RequestT.types.map(rt => rt.props.type.value);
const sql:{[requestType:string]:pgp.QueryFile} = {};
import * as t from 'io-ts';
function request<P extends t.Props>(type:string, props:P) {
return t.type({
type: t.literal(type),
props: t.type(props)
});
}
export const RequestT = t.union([
request('foo', {
baz: t.string,
import React from 'react';
import {appConnect, createPropsMapper, PropsOf} from './app-connect';
import {RootState} from '../reducers';
import {
getPlayers,
setCurrentTime,
setBuffered,
setNextPlaying,
setPlaying,
setSeekTime,
interface SetGet<A,V> {
setValue: (o:A, v:V) => A;
getValue: (o:A) => V;
}
function f<A>(k:keyof A):SetGet<A, A[typeof k]> {
return {
setValue: (a:A, v:A[typeof k]) => Object.assign({}, a, {[k]: v}),
getValue: (a:A) => a[k]
function f<A>(k:keyof A) {
return {
setValue: (a:A, v:A[typeof k]) => Object.assign({}, a, {[k]: v}),
getValue: (a:A) => a[k]
};
}
interface B {
s: string;
n: number;
import {connect} from 'react-redux';
import {Dispatch, bindActionCreators, ActionCreatorsMapObject} from 'redux';
import {createStandardAction} from 'typesafe-actions';
import React from 'react';
interface RootState {
counters: {
[name: string]: {count: number};
};
}
const actions = {
import {connect} from 'react-redux';
import {bindActionCreators, ActionCreatorsMapObject} from 'redux';
import {RootState, Dispatch} from '../reducers';
export interface PropsMapper<StateProps, DispatchProps, OwnProps> {
fromState: (state:RootState, ownProps:OwnProps) => StateProps;
actions: (ownProps:OwnProps) => DispatchProps;
}
export type PropsOf<T> = T extends PropsMapper<infer StateProps, infer DispatchProps, infer OwnProps>
{
"compilerOptions": {
"outDir": "../../dist/frontend",
"sourceMap": true,
"esModuleInterop": true,
"noImplicitAny": true,
"strict": true,
"module": "commonjs",
"target": "es5",
"jsx": "react",
'use strict';
var path = require('path')
, webpack = require('webpack')
, HtmlWebpackPlugin = require('html-webpack-plugin');
var proxySettings = {
'/api/*': {
target: 'http://localhost:3000',
pathRewrite: {