Hi everybody,
I would like to start a new project with DoneJS and I’m diving in the in-depth guide, but i’m stuck because i don’t understand how the routing works.
In the example (using done-serve) the route.register is called without setting the route.data before:
const AppViewModel = DefineMap.extend({
page: 'string',
slug: 'string',
action: 'string',
// env: {
// default: () => { return {NODE_ENV:'development'}; },
// serialize: false
//},
title: {
default: 'place-my-order',
serialize: false
}
});
route.register('{page}', { page: 'home' });
route.register('{page}/{slug}', { slug: null });
route.register('{page}/{slug}/{action}', { slug: null, action: null });
export default AppViewModel;
And it works well but i cannot figure out how.
But, it I don’t use the done-serve, and i set up a Express server using done-ssr-middleware I get that the prop page is not defined in the the viewModel.
In addition, I got problem with the env status added in the viewModel. When I uncomment the env definition, i get the following error:
TypeError: Cannot define property statusCode, object is not extensible
at Function.defineProperty ()
at Object_defineNamedPrototypeProperty (file:/home/fra/Projects/donejs_indepth/place-my-order/node_modules/can-define/can-define.js:51:16)
at Function.define.property (file:/home/fra/Projects/donejs_indepth/place-my-order/node_modules/can-define/can-define.js:352:2)
at Object.defineExpando (file:/home/fra/Projects/donejs_indepth/place-my-order/node_modules/can-define/define-helpers/define-helpers.js:31:11)
at DefineMap.setKeyValue (file:/home/fra/Projects/donejs_indepth/place-my-order/node_modules/can-define/map/map.js:52:30)
at Object.setKeyValue (file:/home/fra/Projects/donejs_indepth/place-my-order/node_modules/can-reflect/reflections/get-set/get-set.js:49:23)
at createViewModelAndRender (file:/home/fra/Projects/donejs_indepth/place-my-order/src/index.stache:425:16)
at /home/fra/Projects/donejs_indepth/place-my-order/node_modules/done-ssr/zones/steal/load.js:67:9
at /home/fra/Projects/donejs_indepth/place-my-order/node_modules/can-zone/lib/tasks.js:162:15
at Task.run (/home/fra/Projects/donejs_indepth/place-my-order/node_modules/can-zone/lib/zone.js:38:17)
at Zone.runTask (/home/fra/Projects/donejs_indepth/place-my-order/node_modules/can-zone/lib/zone.js:181:14)
Any suggestions?
Thanks