reimagined / resolve Goto Github PK
View Code? Open in Web Editor NEWFull stack CQRS, DDD, Event Sourcing framework for Node.js
Home Page: https://reimagined.github.io/resolve/
License: MIT License
Full stack CQRS, DDD, Event Sourcing framework for Node.js
Home Page: https://reimagined.github.io/resolve/
License: MIT License
Now SecurityContext for command handler and query resolvers is implemented as custom free-form object provider, which should be filled and verified manually by end programmer.
It should be replaced by JWT, including verify tokens on server side out-of-the-box.
The 'storage' field has to params - 'driver' and 'params'. All storage drivers has input as object of options excluding memory driver. It has events array. So if you pass object as params, they are interpriated as array of events and then tried to be used as array by the 'filter' function call. It leads to the error.
Now configuration fields rootComponent
and createReducer
should be manually specified in resolve.client.config.js
and resolve.server.config.js
, which caused by necessity of implementation custom routing and data loading flows on client and server side renderings.
It's useful in general case, but we should provide ability for default behaviour, in which rootComponent
and createReducer
will just be taken from pre-determinated files in appropriate folder, to provide ability for fast start for very simple application.
Use case:
/api/query/comments?query=query comment {CommentById(id: $id)}&variables={id:"3d013c8b-10de-410e-a98f-3c48bb3be107"}
Error throwed in handler is impossible to catch wrapping the 'executeCommand' function by try-catch construction
I want to handle 3 steps of command execution in reducer. That's what I do:
export default (state = Immutable({}), action) => {
switch (action.type) {
case '@@resolve/SEND_COMMAND': {
switch (action.command.type) {
case 'createStory': {
return action.status.error // or action.command.error
? // error handling
: // command sending handling
}
default: {
return state;
}
}
}
}
};
The first problem is that if error is thrown, action.command
is excluded so I can't detect whether I handle the createStory
command error or not.
The second problem is that if there is not error, action.status
is not included to the action. So I need to have to checks - action.status and then action.status.error to put error.
Here is solutions as I see them:
[REPLACE_STATE]: (state, action) => {
if (action.readModelName === name) {
return action.state;
}
return state;
}
I created storage.json for Hacker News Demo
Now resolve-redux actions have merge
and replaceState
actions. They have to have consistency API. That means we have to rename or merge
or replaceState
Error: Variables must be provided as an Object where each property is a variable value. Perhaps look to see if an unparsed JSON string was provided.
at invariant (/home/mrcheater/hacker-news-demo/node_modules/graphql/jsutils/invariant.js:19:11)
at assertValidExecutionArguments (/home/mrcheater/hacker-news-demo/node_modules/graphql/execution/execute.js:173:153)
at executeImpl (/home/mrcheater/hacker-news-demo/node_modules/graphql/execution/execute.js:118:3)
at execute (/home/mrcheater/hacker-news-demo/node_modules/graphql/execution/execute.js:113:150)
at _callee3$ (/home/mrcheater/hacker-news-demo/node_modules/resolve-query/dist/index.js:188:57)
at tryCatch (/home/mrcheater/hacker-news-demo/node_modules/regenerator-runtime/runtime.js:65:40)
at Generator.invoke [as _invoke] (/home/mrcheater/hacker-news-demo/node_modules/regenerator-runtime/runtime.js:303:22)
at Generator.prototype.(anonymous function) [as next] (/home/mrcheater/hacker-news-demo/node_modules/regenerator-runtime/runtime.js:117:21)
at step (/home/mrcheater/hacker-news-demo/node_modules/resolve-query/dist/index.js:15:191)
at /home/mrcheater/hacker-news-demo/node_modules/resolve-query/dist/index.js:15:361
Replace:
const subscribe = bus.onEvent;
to
const subscribe = store.onEvent;
I think it is unnecessary to use SSR in dev mode. I start server, then change some component but it is cached on the server side. Right now the only way is to restart server. So it neutralizes hot reloading.
I need support for subdirectories for deploying multiple applications on a single domain
/static/ -> /${subdirectory}/static
/api/commands/ -> /${subdirectory}/api/commands
/api/:queryName/ -> /${subdirectory}/api/:queryName
ws:/// -> ws://${subdirectory}/
html-markup-template <script src="/bundle.js"> -> <script src="/${subdirectory}/bundle.js">
resolve.config.js
module.exports = {
//...
subdirectory: "some-app-name"
}
Now every GraphQL schema and appropriate resolvers are bound to each read-model separately, so, even custom resolver can't reach access to current state of another read-model.
Such behaviour should be refactored - graphql schema and resolvers should work around all read-models in current resolve-query instance.
After refactoring behaviour of on-demand read-models should stay.
Error: ENOENT: no such file or directory, stat '/some-application/static'
Add it for dev mode.
Now configuration in output-stats-config.js
prevents all output from webpack.
In case of error in application's source code, there no ability to find error.
MUST be configured by environment variable or command line flag
NOW:
const state = query('User');
AFTER:
query('User').then(state => {
///...
})
It's possible to pass storage driver to event store without creation resolve-storage. At fact, resolve storage is the same as his drivers only with additional function onEventSaved that used only in tests.
Also, need to think about removing resolve-bus for consistency. In this case, resolve-es will accept only bus and storage drivers.
Lerna
does not perform correct bootstrapping for dependent modules, so when launching examples from it's appropriate directories, node_modules
will not installed, so webpack/babel plugins can't be foundSocket.io
server part library perform including dependent library in run-time, which is incompatible with bundling mechanism. Should be researched, how to fix it in general case, and socket.io
, in particular.In sendCommandMiddleware from resolve-redux there is an error handing. This error is thrown if there is no connection. Other case is when server response with error. The fetch interpriates this as success and put all info to the response. So command execution is failed but request is executed successfully. In this case I can't handle error (e.g. sending info from form being unauthorized).
Now create-resolve-app perform bundling for server and client code by isomorphic webpack configs.
Such schema allows easily attach React plugins, like CSS stylizers, both for client and server-side rendering. If server side will not be bundled by webpack, it will cause some issues, including absence for some CSS plugins for Babel, and thus impossibility of server-side rendering.
But bundling server-side code also affects other issues, like problems with npm-packages, which perform loading code in runtime, for example, socket.io. In case of socket.io there is known solution (https://stackoverflow.com/questions/46098113/socket-io-and-server-side-webpack-bundling#comment79160961_46098113 ), but issue with server-side bundling should be investigate for common case.
Storage file contains none-valid JSON format, so you can't actually change it properly.
test
src
It is not used anymore
File: resolve.build.config.js
Implement raw event saver in event store to provide ability for saving event with custom timestamp. It's necessary when using import scripts.
Now resolve-script has debug output with information about connecting new sockets.io clients, i.e. new browser session. But this message appears also when one non-closing tab in browser existed, so maybe performed reconnection are caused some bugs in code.
More than, after investigation debug output should be removed
loadEventsByAggregateId receives an Array of aggregateIds.
It should be renamed to loadEventsByAggregateIds.
const bundleCssSource =
process.env.NODE_ENV === 'production'
? `${BASEDIR}/static/bundle.css`
: 'http://localhost:3001/bundle.css';
<div className="app">
<Helmet>
<link rel="stylesheet" type="text/css" href={bundleCssSource} />
</Helmet>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.