48 lines
1.6 KiB
CoffeeScript
48 lines
1.6 KiB
CoffeeScript
config = ->
|
|
@get '/dunlop/user_filters', (schema, request) ->
|
|
#q = {}
|
|
#for key, value of request.queryParams
|
|
# continue unless match = key.match /^q\[(\w+)\]$/
|
|
# q[match[1]] = value
|
|
#switch q.f_eq
|
|
# when 4 then schema.dunlopUserFilters.all()
|
|
# else schema.loadFixtures('dunlop-user-filters')
|
|
result = schema.dunlopUserFilters.all()
|
|
if filter = request.queryParams.scope_key_matches
|
|
match = new RegExp(filter.replace(/%$/, '.*$'))
|
|
result = result.filter (model) ->
|
|
model.scope_key.match match
|
|
result
|
|
@post '/dunlop/user_filters', (schema, request) ->
|
|
attributes = JSON.parse(request.requestBody)['dunlop/user_filter']
|
|
schema.dunlopUserFilters.create(attributes)
|
|
|
|
@delete '/dunlop/user_filters/:id', (schema, request) ->
|
|
model = schema.dunlopUserFilters.find(request.params.id)
|
|
null
|
|
|
|
# These comments are here to help you get started. Feel free to delete them.
|
|
|
|
###
|
|
Config (with defaults).
|
|
|
|
Note: these only affect routes defined *after* them!
|
|
###
|
|
|
|
# this.urlPrefix = ''; // make this `http://localhost:8080`, for example, if your API is on a different server
|
|
# this.namespace = ''; // make this `/api`, for example, if your API is namespaced
|
|
# this.timing = 400; // delay for each request, automatically set to 0 during testing
|
|
|
|
###
|
|
Shorthand cheatsheet:
|
|
|
|
this.get('/posts');
|
|
this.post('/posts');
|
|
this.get('/posts/:id');
|
|
this.put('/posts/:id'); // or this.patch
|
|
this.del('/posts/:id');
|
|
|
|
http://www.ember-cli-mirage.com/docs/v0.3.x/shorthands/
|
|
###
|
|
export default config
|