Skip to content

Instantly share code, notes, and snippets.

@asci
Created October 18, 2013 21:23
Show Gist options
  • Save asci/7048480 to your computer and use it in GitHub Desktop.
Save asci/7048480 to your computer and use it in GitHub Desktop.
JSON Driven Development
var app = {
name: 'Contact list',
version: '0.1',
db: 'mysql',
transports: ['http', 'websocket'],
auth: {
controllers: 'Contact',
types: {
vk: {
appCode: 1231341,
appSecret: 'sdp8we7rhtw7ebr98tbw7erv'
}
}
},
routes: {
'/': {redirect: '/user'},
'/contacts': {
get: {controller: 'Contact', method: 'index'},
post: {controller: 'Contact', method: 'create'}
},
'/contacts/:id': {
get: {controller: 'Contact', method: 'show'},
put: {controller: 'Contact', method: 'update'},
'delete': {controller: 'Contact', method: 'remove'}
}
},
controllers: {
Contact: {
userRequired: true,
methods: {
index: {
params: ['limit', 'offset'],
model: 'Contact',
method: 'find',
template: {type: 'contact', name: 'index'}
},
create: {},
show: {},
remove: {},
update: {}
}
}
},
models: {
Contact: {
pagination: 'offset',
ownerModel: 'User',
fields: {
name: {type: 'string', length: 10},
age: {type: 'number', max: 200},
}
},
User: {/* user description*/}
},
templates: {
contact: {
index: {
parent: 'common-page',
content: {
tag: 'ul',
content: {
field: 'contacts',
each: {
content: [
{tag: 'h1', content: {field: 'name'}},
{tag: 'a', content: {field: 'website'}}
]
}
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment