next-compose-middleware
Version:
`next-compose-middleware` is a library that simplifies building complex, declarative middleware for Next.js applications. It allows you to create highly readable and maintainable middleware by composing multiple functions together.
30 lines • 868 B
JavaScript
const initialState = {
path: [],
brokenOnce: false,
brokenAll: false,
};
export const reducer = (state = initialState, action) => {
switch (action.type) {
case 'setPath':
return Object.assign(Object.assign({}, state), { path: action.payload });
case 'breakOnce':
return Object.assign(Object.assign({}, state), { brokenOnce: true });
case 'breakAll':
return Object.assign(Object.assign({}, state), { brokenAll: true });
case 'reset':
return initialState;
default:
return state;
}
};
export const createStore = () => {
let state = initialState;
return {
getState: () => state,
dispatch: (action) => {
state = reducer(state, action);
return action;
},
};
};
//# sourceMappingURL=index.js.map