Skip to content

Instantly share code, notes, and snippets.

View innerdaze's full-sized avatar
👾

Lee Driscoll innerdaze

👾
  • Acre Software
  • Bournemouth, UK
View GitHub Profile
;========================================================================================================
;
; Program : Security:User
; Date : 14 Mar 2016
; Author : Lee Driscoll
;
; Description : Service for interaction with the Security:User module
;
;========================================================================================================
.include "CODE_WEB_SERVER:Import.def"
@innerdaze
innerdaze / package.json
Last active March 7, 2017 16:36
Default package.json for server-side development
{
"name": "project-name",
"version": "0.1.0",
"description": "",
"main": "index.js",
"scripts": {
"pretest": "npm run lint",
"test": "NODE_PATH=source ava --verbose",
"lint": "NODE_PATH=source xo",
"babel-node": "NODE_PATH=source babel-node .",
var path = require('path')
var webpack = require('webpack')
module.exports = {
entry: path.resolve(__dirname, 'public/index.js'),
devtool: 'cheap-eval-source-map',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist/public')
},
@innerdaze
innerdaze / OrdersReducer.js
Last active March 30, 2017 15:07
First Reducer
import { Orders } from '../actions/OrderActions'
const initialState = {
orders: []
}
function orderApp(state = initialState, action) {
switch (action.type) {
case 'ADD_ORDER':
return {
@innerdaze
innerdaze / add-order.js
Created March 31, 2017 10:40
Redux Store Unit Test
import test from 'ava'
import {createStore} from 'redux'
import {addOrder} from '../client/actions/OrderActions'
import orderApp from '../client/reducers/AppReducer'
test('add order', t => {
let store = createStore(orderApp)
const order = {
id: 99,
@innerdaze
innerdaze / package.json
Created March 31, 2017 10:45
XO config for universal project
{
"xo": {
"space": true,
"semicolon": false,
"overrides": [
{
"files": "server/**/*.js",
"settings": {
"import/resolver": {
"node": {
@innerdaze
innerdaze / fetch-orders.js
Last active April 4, 2017 14:20
Example unit test of Redux Fetch (without Jest)
import test from 'ava'
import nock from 'nock'
import { createStore, applyMiddleware } from 'redux'
import thunkMiddleware from 'redux-thunk'
import { apiURL } from '../client/config'
import { fetchOrders } from '../client/actions/OrderActions'
import * as types from '../client/constants/ActionTypes'
import appReducer from '../client/reducers/RootReducer'
import _ from 'lodash'
@innerdaze
innerdaze / config.js
Created April 4, 2017 12:14
Example config using JS instead of JSON
// Set a boolean for Dev mode
export const isDevelopment = process.env.NODE_ENV === 'development'
// Everything for remote calls should go in here
export const api = {
protocol : isDevelopment ? 'http' : 'https',
host: isDevelopment ? 'dev.url' : 'prod.url',
port: isDevelopment ? 80 : 5678
}
import express from 'express'
import bodyParser from 'body-parser'
import webpack from 'webpack'
import webpackDevMiddleware from 'webpack-dev-middleware'
import webpackHotMiddleware from 'webpack-hot-middleware'
import WebpackDashboardPlugin from 'webpack-dashboard/plugin'
import webBuildConfig from './webpack.web'
import cordovaBuildConfig from './webpack.cordova'
const IP = process.env.IP || 'localhost'
@innerdaze
innerdaze / webpack-dev-server.js
Last active June 30, 2017 15:20
webpack-dev-server
import express from 'express'
import bodyParser from 'body-parser'
import webpack from 'webpack'
import webpackDevMiddleware from 'webpack-dev-middleware'
import webpackHotMiddleware from 'webpack-hot-middleware'
import WebpackDashboardPlugin from 'webpack-dashboard/plugin'
import webBuildConfig from './webpack.web'
import cordovaBuildConfig from './webpack.cordova'
const IP = process.env.IP || 'localhost'