# In-depth Guide - setting application route and env

**URL:** <https://forums.bitovi.com/t/in-depth-guide-setting-application-route-and-env/862>\
**Category:** DoneJS\
**Created:** [April 18, 2018, 6:37am UTC](https://forums.bitovi.com/t/in-depth-guide-setting-application-route-and-env/862 "2018-04-18T06:37:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fp\_dev](https://avatars.discourse-cdn.com/v4/letter/f/13edae/32.png) [@fp\_dev](https://forums.bitovi.com/u/fp_dev)\
**Post date:** [April 18, 2018, 6:37am UTC](https://forums.bitovi.com/t/in-depth-guide-setting-application-route-and-env/862/1 "2018-04-18T06:37:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![chasen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/chasen/32/402_2.png) [@chasen](https://forums.bitovi.com/u/chasen)\
**Post date:** [April 18, 2018, 9:13pm UTC](https://forums.bitovi.com/t/in-depth-guide-setting-application-route-and-env/862/2 "2018-04-18T21:13:35Z")

</div>

Hi @fp_dev,

> route.register is called without setting the route.data before

This is done [automatically by done-autorender](https://github.com/donejs/autorender/blob/8a592c63e0b21435554e43d4e66ee8d7d5f77cb1/src/template.txt#L57) which is why you don’t have to do it yourself.

> `TypeError: Cannot define property statusCode, object is not extensible`

This error happens when trying to set a property on a sealed object, which `can-define/map/map` is [by default](https://canjs.com/doc/can-define/map/map.html#Sealedinstancesandstrictmode). I think it’ll work correctly if you define `statusCode` on your AppViewModel.
