id
stringlengths
34
124
type
stringclasses
4 values
prompt
stringlengths
0
4.95k
response
stringlengths
21
4.89k
source_lang
stringclasses
3 values
target_lang
stringclasses
2 values
repo
stringclasses
75 values
path
stringlengths
10
88
license
stringclasses
1 value
commit
stringlengths
40
40
stars
int64
431
18.7k
source_url
stringlengths
86
176
line_start
int64
1
214
line_end
int64
3
253
kahmali/meteor-restivus:lib/route.coffee:6:completion
completion
authenticateIfRequired = (route, endpoint) -> # Authenticate the request if necessary if route.api.config.useAuth if endpoint.authRequired is undefined authenticate.call(this) if route.options?.authRequired else if endpoint.authRequired authenticate.call this
### Verify the request is being made by an actively logged in user @context: IronRouter.Router.route() ###
CoffeeScript
CoffeeScript
kahmali/meteor-restivus
lib/route.coffee
MIT
e4e3eca6fef95ca4782122520a8f4b4fc0db0eb7
541
https://github.com/kahmali/meteor-restivus/blob/e4e3eca6fef95ca4782122520a8f4b4fc0db0eb7/lib/route.coffee
82
95
kahmali/meteor-restivus:lib/route.coffee:7:raw_corpus
raw_corpus
authenticate = -> # Get the auth info from header userId = @request.headers['x-user-id'] authToken = @request.headers['x-auth-token'] # Get the user from the database if userId and authToken user = Meteor.users.findOne {'_id': userId, 'services.resume.loginTokens.token': authToken} # Return an error i...
CoffeeScript
kahmali/meteor-restivus
lib/route.coffee
MIT
e4e3eca6fef95ca4782122520a8f4b4fc0db0eb7
541
https://github.com/kahmali/meteor-restivus/blob/e4e3eca6fef95ca4782122520a8f4b4fc0db0eb7/lib/route.coffee
96
116
kahmali/meteor-restivus:lib/route.coffee:7:coffee_to_js
coffee_to_js
Convert this CoffeeScript to JavaScript. ```coffeescript authenticate = -> # Get the auth info from header userId = @request.headers['x-user-id'] authToken = @request.headers['x-auth-token'] # Get the user from the database if userId and authToken user = Meteor.users.findOne {'_id': userId, 'services.res...
var authenticate; authenticate = function() { var authToken, user, userId; // Get the auth info from header userId = this.request.headers['x-user-id']; authToken = this.request.headers['x-auth-token']; // Get the user from the database if (userId && authToken) { user = Meteor.users.findOne({ '_id...
CoffeeScript
JavaScript
kahmali/meteor-restivus
lib/route.coffee
MIT
e4e3eca6fef95ca4782122520a8f4b4fc0db0eb7
541
https://github.com/kahmali/meteor-restivus/blob/e4e3eca6fef95ca4782122520a8f4b4fc0db0eb7/lib/route.coffee
96
116
kahmali/meteor-restivus:lib/route.coffee:7:js_to_coffee
js_to_coffee
Convert this JavaScript to CoffeeScript. ```javascript var authenticate; authenticate = function() { var authToken, user, userId; // Get the auth info from header userId = this.request.headers['x-user-id']; authToken = this.request.headers['x-auth-token']; // Get the user from the database if (userId && au...
authenticate = -> # Get the auth info from header userId = @request.headers['x-user-id'] authToken = @request.headers['x-auth-token'] # Get the user from the database if userId and authToken user = Meteor.users.findOne {'_id': userId, 'services.resume.loginTokens.token': authToken} # Return an error i...
JavaScript
CoffeeScript
kahmali/meteor-restivus
lib/route.coffee
MIT
e4e3eca6fef95ca4782122520a8f4b4fc0db0eb7
541
https://github.com/kahmali/meteor-restivus/blob/e4e3eca6fef95ca4782122520a8f4b4fc0db0eb7/lib/route.coffee
96
116
kahmali/meteor-restivus:lib/route.coffee:7:completion
completion
authenticate = -> # Get the auth info from header userId = @request.headers['x-user-id'] authToken = @request.headers['x-auth-token'] # Get the user from the database if userId and authToken user = Meteor.users.findOne {'_id': userId, 'services.resume.loginTokens.token': authToken} # Return an error i...
if not user respond.call this, {success: false, message: "You must be logged in to do this."}, 401 @user = user ### Respond to an HTTP request @context: IronRouter.Router.route() ###
CoffeeScript
CoffeeScript
kahmali/meteor-restivus
lib/route.coffee
MIT
e4e3eca6fef95ca4782122520a8f4b4fc0db0eb7
541
https://github.com/kahmali/meteor-restivus/blob/e4e3eca6fef95ca4782122520a8f4b4fc0db0eb7/lib/route.coffee
96
116
kahmali/meteor-restivus:lib/route.coffee:8:raw_corpus
raw_corpus
respond = (body, statusCode=200, headers) -> # Allow cross-domain requests to be made from the browser @response.setHeader 'Access-Control-Allow-Origin', '*' # Ensure that a content type is set (will be overridden if also included in given headers) # TODO: Consider enforcing a text/json-only content type (over...
CoffeeScript
kahmali/meteor-restivus
lib/route.coffee
MIT
e4e3eca6fef95ca4782122520a8f4b4fc0db0eb7
541
https://github.com/kahmali/meteor-restivus/blob/e4e3eca6fef95ca4782122520a8f4b4fc0db0eb7/lib/route.coffee
117
128
kahmali/meteor-restivus:lib/route.coffee:8:coffee_to_js
coffee_to_js
Convert this CoffeeScript to JavaScript. ```coffeescript respond = (body, statusCode=200, headers) -> # Allow cross-domain requests to be made from the browser @response.setHeader 'Access-Control-Allow-Origin', '*' # Ensure that a content type is set (will be overridden if also included in given headers) # TOD...
var respond; respond = function(body, statusCode = 200, headers) { // Allow cross-domain requests to be made from the browser this.response.setHeader('Access-Control-Allow-Origin', '*'); // Ensure that a content type is set (will be overridden if also included in given headers) // TODO: Consider enforcing a te...
CoffeeScript
JavaScript
kahmali/meteor-restivus
lib/route.coffee
MIT
e4e3eca6fef95ca4782122520a8f4b4fc0db0eb7
541
https://github.com/kahmali/meteor-restivus/blob/e4e3eca6fef95ca4782122520a8f4b4fc0db0eb7/lib/route.coffee
117
128
kahmali/meteor-restivus:lib/route.coffee:8:js_to_coffee
js_to_coffee
Convert this JavaScript to CoffeeScript. ```javascript var respond; respond = function(body, statusCode = 200, headers) { // Allow cross-domain requests to be made from the browser this.response.setHeader('Access-Control-Allow-Origin', '*'); // Ensure that a content type is set (will be overridden if also includ...
respond = (body, statusCode=200, headers) -> # Allow cross-domain requests to be made from the browser @response.setHeader 'Access-Control-Allow-Origin', '*' # Ensure that a content type is set (will be overridden if also included in given headers) # TODO: Consider enforcing a text/json-only content type (over...
JavaScript
CoffeeScript
kahmali/meteor-restivus
lib/route.coffee
MIT
e4e3eca6fef95ca4782122520a8f4b4fc0db0eb7
541
https://github.com/kahmali/meteor-restivus/blob/e4e3eca6fef95ca4782122520a8f4b4fc0db0eb7/lib/route.coffee
117
128
kahmali/meteor-restivus:lib/route.coffee:8:completion
completion
respond = (body, statusCode=200, headers) -> # Allow cross-domain requests to be made from the browser @response.setHeader 'Access-Control-Allow-Origin', '*' # Ensure that a content type is set (will be overridden if also included in given headers) # TODO: Consider enforcing a text/json-only content type (over...
@response.setHeader 'Content-Type', 'text/json' # Send response @response.writeHead statusCode, headers @response.write JSON.stringify(body) @response.end()
CoffeeScript
CoffeeScript
kahmali/meteor-restivus
lib/route.coffee
MIT
e4e3eca6fef95ca4782122520a8f4b4fc0db0eb7
541
https://github.com/kahmali/meteor-restivus/blob/e4e3eca6fef95ca4782122520a8f4b4fc0db0eb7/lib/route.coffee
117
128
jianliaoim/talk-os:talk-web/client/util/dev.coffee:1:raw_corpus
raw_corpus
TALK = require '../config' ['log', 'info', 'warn', 'error', 'trace', 'group', 'groupEnd'].forEach (option) -> exports[option] = (args...) -> if TALK.env is 'dev' console[option] args...
CoffeeScript
jianliaoim/talk-os
talk-web/client/util/dev.coffee
MIT
2545c4497865779a55762e03963a39237df9046b
2,703
https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/util/dev.coffee
1
6
jianliaoim/talk-os:talk-web/client/util/dev.coffee:1:coffee_to_js
coffee_to_js
Convert this CoffeeScript to JavaScript. ```coffeescript TALK = require '../config' ['log', 'info', 'warn', 'error', 'trace', 'group', 'groupEnd'].forEach (option) -> exports[option] = (args...) -> if TALK.env is 'dev' console[option] args... ```
var TALK; TALK = require('../config'); ['log', 'info', 'warn', 'error', 'trace', 'group', 'groupEnd'].forEach(function(option) { return exports[option] = function(...args) { if (TALK.env === 'dev') { return console[option](...args); } }; });
CoffeeScript
JavaScript
jianliaoim/talk-os
talk-web/client/util/dev.coffee
MIT
2545c4497865779a55762e03963a39237df9046b
2,703
https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/util/dev.coffee
1
6
jianliaoim/talk-os:talk-web/client/util/dev.coffee:1:js_to_coffee
js_to_coffee
Convert this JavaScript to CoffeeScript. ```javascript var TALK; TALK = require('../config'); ['log', 'info', 'warn', 'error', 'trace', 'group', 'groupEnd'].forEach(function(option) { return exports[option] = function(...args) { if (TALK.env === 'dev') { return console[option](...args); } }; }); ```
TALK = require '../config' ['log', 'info', 'warn', 'error', 'trace', 'group', 'groupEnd'].forEach (option) -> exports[option] = (args...) -> if TALK.env is 'dev' console[option] args...
JavaScript
CoffeeScript
jianliaoim/talk-os
talk-web/client/util/dev.coffee
MIT
2545c4497865779a55762e03963a39237df9046b
2,703
https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/util/dev.coffee
1
6
jianliaoim/talk-os:talk-web/client/util/dev.coffee:1:completion
completion
TALK = require '../config' ['log', 'info', 'warn', 'error', 'trace', 'group', 'groupEnd'].forEach (option) ->
exports[option] = (args...) -> if TALK.env is 'dev' console[option] args...
CoffeeScript
CoffeeScript
jianliaoim/talk-os
talk-web/client/util/dev.coffee
MIT
2545c4497865779a55762e03963a39237df9046b
2,703
https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/util/dev.coffee
1
6
rs/pushd:lib/api.coffee:1:raw_corpus
raw_corpus
filterFields = (params) -> fields = {} fields[key] = val for own key, val of params when key in ['proto', 'token', 'lang', 'badge', 'version', 'category', 'contentAvailable'] return fields
CoffeeScript
rs/pushd
lib/api.coffee
MIT
9dc56de9da2a64903cad510d22d4d0e078a8ba0a
1,157
https://github.com/rs/pushd/blob/9dc56de9da2a64903cad510d22d4d0e078a8ba0a/lib/api.coffee
5
8
rs/pushd:lib/api.coffee:1:coffee_to_js
coffee_to_js
Convert this CoffeeScript to JavaScript. ```coffeescript filterFields = (params) -> fields = {} fields[key] = val for own key, val of params when key in ['proto', 'token', 'lang', 'badge', 'version', 'category', 'contentAvailable'] return fields ```
var filterFields, hasProp = {}.hasOwnProperty; filterFields = function(params) { var fields, key, val; fields = {}; for (key in params) { if (!hasProp.call(params, key)) continue; val = params[key]; if (key === 'proto' || key === 'token' || key === 'lang' || key === 'badge' || key === 'version' || ...
CoffeeScript
JavaScript
rs/pushd
lib/api.coffee
MIT
9dc56de9da2a64903cad510d22d4d0e078a8ba0a
1,157
https://github.com/rs/pushd/blob/9dc56de9da2a64903cad510d22d4d0e078a8ba0a/lib/api.coffee
5
8
rs/pushd:lib/api.coffee:1:js_to_coffee
js_to_coffee
Convert this JavaScript to CoffeeScript. ```javascript var filterFields, hasProp = {}.hasOwnProperty; filterFields = function(params) { var fields, key, val; fields = {}; for (key in params) { if (!hasProp.call(params, key)) continue; val = params[key]; if (key === 'proto' || key === 'token' || key...
filterFields = (params) -> fields = {} fields[key] = val for own key, val of params when key in ['proto', 'token', 'lang', 'badge', 'version', 'category', 'contentAvailable'] return fields
JavaScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
9dc56de9da2a64903cad510d22d4d0e078a8ba0a
1,157
https://github.com/rs/pushd/blob/9dc56de9da2a64903cad510d22d4d0e078a8ba0a/lib/api.coffee
5
8
rs/pushd:lib/api.coffee:1:completion
completion
filterFields = (params) -> fields = {}
fields[key] = val for own key, val of params when key in ['proto', 'token', 'lang', 'badge', 'version', 'category', 'contentAvailable'] return fields
CoffeeScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
9dc56de9da2a64903cad510d22d4d0e078a8ba0a
1,157
https://github.com/rs/pushd/blob/9dc56de9da2a64903cad510d22d4d0e078a8ba0a/lib/api.coffee
5
8
rs/pushd:lib/api.coffee:2:raw_corpus
raw_corpus
exports.setupRestApi = (app, createSubscriber, getEventFromId, authorize, testSubscriber, eventPublisher, checkStatus) -> authorize ?= (realm) -> # subscriber registration app.post '/subscribers', authorize('register'), (req, res) -> logger.verbose "Registering subscriber: " + JSON.stringify req.bo...
CoffeeScript
rs/pushd
lib/api.coffee
MIT
9dc56de9da2a64903cad510d22d4d0e078a8ba0a
1,157
https://github.com/rs/pushd/blob/9dc56de9da2a64903cad510d22d4d0e078a8ba0a/lib/api.coffee
10
59
rs/pushd:lib/api.coffee:2:completion
completion
exports.setupRestApi = (app, createSubscriber, getEventFromId, authorize, testSubscriber, eventPublisher, checkStatus) -> authorize ?= (realm) -> # subscriber registration app.post '/subscribers', authorize('register'), (req, res) -> logger.verbose "Registering subscriber: " + JSON.stringify req.bo...
# Edit subscriber info app.post '/subscriber/:subscriber_id', authorize('register'), (req, res) -> logger.verbose "Setting new properties for #{req.subscriber.id}: " + JSON.stringify(req.body) fields = filterFields(req.body) req.subscriber.set fields, (edited) -> if not edited ...
CoffeeScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
9dc56de9da2a64903cad510d22d4d0e078a8ba0a
1,157
https://github.com/rs/pushd/blob/9dc56de9da2a64903cad510d22d4d0e078a8ba0a/lib/api.coffee
10
59
rs/pushd:lib/api.coffee:3:raw_corpus
raw_corpus
subsAndOptions = {} for sub in subs subsAndOptions[sub.event.name] = {ignore_message: (sub.options & sub.event.OPTION_IGNORE_MESSAGE) isnt 0} logger.verbose "Status of #{req.subscriber.id}: " + JSON.stringify(subsAndOptions) res.json subsAndOptions ...
CoffeeScript
rs/pushd
lib/api.coffee
MIT
9dc56de9da2a64903cad510d22d4d0e078a8ba0a
1,157
https://github.com/rs/pushd/blob/9dc56de9da2a64903cad510d22d4d0e078a8ba0a/lib/api.coffee
60
109
rs/pushd:lib/api.coffee:3:completion
completion
subsAndOptions = {} for sub in subs subsAndOptions[sub.event.name] = {ignore_message: (sub.options & sub.event.OPTION_IGNORE_MESSAGE) isnt 0} logger.verbose "Status of #{req.subscriber.id}: " + JSON.stringify(subsAndOptions) res.json subsAndOptions ...
req.subscriber.getSubscriptions (subs) -> if not subs? logger.error "No subscriber #{req.subscriber.id}" res.send 404 return tasks = [] for sub in subs if sub.event.name of subsToAdd subToAdd = subs...
CoffeeScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
9dc56de9da2a64903cad510d22d4d0e078a8ba0a
1,157
https://github.com/rs/pushd/blob/9dc56de9da2a64903cad510d22d4d0e078a8ba0a/lib/api.coffee
60
109
rs/pushd:lib/api.coffee:4:raw_corpus
raw_corpus
else if action == 'del' req.subscriber.removeSubscription event, (deleted) -> callback(deleted) else if action == 'set' req.subscriber.addSubscription event, options, (added) -> callback(!added) # should return false...
CoffeeScript
rs/pushd
lib/api.coffee
MIT
9dc56de9da2a64903cad510d22d4d0e078a8ba0a
1,157
https://github.com/rs/pushd/blob/9dc56de9da2a64903cad510d22d4d0e078a8ba0a/lib/api.coffee
110
159
rs/pushd:lib/api.coffee:4:completion
completion
else if action == 'del' req.subscriber.removeSubscription event, (deleted) -> callback(deleted) else if action == 'set' req.subscriber.addSubscription event, options, (added) -> callback(!added) # should return false...
req.subscriber.addSubscription req.event, options, (added) -> if added? # added is null if subscriber doesn't exist res.send if added then 201 else 204 else logger.error "No subscriber #{req.subscriber.id}" res.send 404 # Unsubscribe a subscri...
CoffeeScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
9dc56de9da2a64903cad510d22d4d0e078a8ba0a
1,157
https://github.com/rs/pushd/blob/9dc56de9da2a64903cad510d22d4d0e078a8ba0a/lib/api.coffee
110
159
rs/pushd:lib/api.coffee:5:raw_corpus
raw_corpus
# Publish an event app.post '/event/:event_id', authorize('publish'), (req, res) -> res.send 204 eventPublisher.publish(req.event, req.body) # Delete an event app.delete '/event/:event_id', authorize('publish'), (req, res) -> req.event.delete (deleted) -> if not deleted ...
CoffeeScript
rs/pushd
lib/api.coffee
MIT
9dc56de9da2a64903cad510d22d4d0e078a8ba0a
1,157
https://github.com/rs/pushd/blob/9dc56de9da2a64903cad510d22d4d0e078a8ba0a/lib/api.coffee
160
181
rs/pushd:lib/api.coffee:5:coffee_to_js
coffee_to_js
Convert this CoffeeScript to JavaScript. ```coffeescript # Publish an event app.post '/event/:event_id', authorize('publish'), (req, res) -> res.send 204 eventPublisher.publish(req.event, req.body) # Delete an event app.delete '/event/:event_id', authorize('publish'), (req, res) -> ...
// Publish an event app.post('/event/:event_id', authorize('publish'), function(req, res) { res.send(204); return eventPublisher.publish(req.event, req.body); }); // Delete an event app.delete('/event/:event_id', authorize('publish'), function(req, res) { return req.event.delete(function(deleted) { if (!dele...
CoffeeScript
JavaScript
rs/pushd
lib/api.coffee
MIT
9dc56de9da2a64903cad510d22d4d0e078a8ba0a
1,157
https://github.com/rs/pushd/blob/9dc56de9da2a64903cad510d22d4d0e078a8ba0a/lib/api.coffee
160
181
rs/pushd:lib/api.coffee:5:js_to_coffee
js_to_coffee
Convert this JavaScript to CoffeeScript. ```javascript // Publish an event app.post('/event/:event_id', authorize('publish'), function(req, res) { res.send(204); return eventPublisher.publish(req.event, req.body); }); // Delete an event app.delete('/event/:event_id', authorize('publish'), function(req, res) { re...
# Publish an event app.post '/event/:event_id', authorize('publish'), (req, res) -> res.send 204 eventPublisher.publish(req.event, req.body) # Delete an event app.delete '/event/:event_id', authorize('publish'), (req, res) -> req.event.delete (deleted) -> if not deleted ...
JavaScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
9dc56de9da2a64903cad510d22d4d0e078a8ba0a
1,157
https://github.com/rs/pushd/blob/9dc56de9da2a64903cad510d22d4d0e078a8ba0a/lib/api.coffee
160
181
rs/pushd:lib/api.coffee:5:completion
completion
# Publish an event app.post '/event/:event_id', authorize('publish'), (req, res) -> res.send 204 eventPublisher.publish(req.event, req.body) # Delete an event app.delete '/event/:event_id', authorize('publish'), (req, res) -> req.event.delete (deleted) -> if not deleted ...
if deleted res.send 204 else res.send 404 # Server status app.get '/status', authorize('register'), (req, res) -> if checkStatus() res.send 204 else res.send 503
CoffeeScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
9dc56de9da2a64903cad510d22d4d0e078a8ba0a
1,157
https://github.com/rs/pushd/blob/9dc56de9da2a64903cad510d22d4d0e078a8ba0a/lib/api.coffee
160
181
rs/pushd:lib/api.coffee:4:raw_corpus
raw_corpus
else if action == 'del' req.subscriber.removeSubscription event, (deleted) -> callback(deleted) else if action == 'set' req.subscriber.addSubscription event, options, (added) -> callback(!added) # should return false...
CoffeeScript
rs/pushd
lib/api.coffee
MIT
9ea25ba41b0b1784430b8a9302c2d5345ef6c510
1,157
https://github.com/rs/pushd/blob/9ea25ba41b0b1784430b8a9302c2d5345ef6c510/lib/api.coffee
110
159
rs/pushd:lib/api.coffee:4:completion
completion
else if action == 'del' req.subscriber.removeSubscription event, (deleted) -> callback(deleted) else if action == 'set' req.subscriber.addSubscription event, options, (added) -> callback(!added) # should return false...
options |= req.event.OPTION_IGNORE_MESSAGE req.subscriber.addSubscription req.event, options, (added) -> if added? # added is null if subscriber doesn't exist res.send if added then 201 else 204 else logger.error "No subscriber #{req.subscriber.id}" ...
CoffeeScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
9ea25ba41b0b1784430b8a9302c2d5345ef6c510
1,157
https://github.com/rs/pushd/blob/9ea25ba41b0b1784430b8a9302c2d5345ef6c510/lib/api.coffee
110
159
rs/pushd:lib/api.coffee:2:raw_corpus
raw_corpus
exports.setupRestApi = (app, createSubscriber, getEventFromId, authorize, testSubscriber, eventPublisher) -> authorize ?= (realm) -> # subscriber registration app.post '/subscribers', authorize('register'), (req, res) -> logger.verbose "Registering subscriber: " + JSON.stringify req.body tr...
CoffeeScript
rs/pushd
lib/api.coffee
MIT
d69b453eaacc2964d67515ebaecc12bb80927606
1,157
https://github.com/rs/pushd/blob/d69b453eaacc2964d67515ebaecc12bb80927606/lib/api.coffee
10
59
rs/pushd:lib/api.coffee:2:completion
completion
exports.setupRestApi = (app, createSubscriber, getEventFromId, authorize, testSubscriber, eventPublisher) -> authorize ?= (realm) -> # subscriber registration app.post '/subscribers', authorize('register'), (req, res) -> logger.verbose "Registering subscriber: " + JSON.stringify req.body tr...
# Edit subscriber info app.post '/subscriber/:subscriber_id', authorize('register'), (req, res) -> logger.verbose "Setting new properties for #{req.subscriber.id}: " + JSON.stringify(req.body) fields = filterFields(req.body) req.subscriber.set fields, (edited) -> if not edited ...
CoffeeScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
d69b453eaacc2964d67515ebaecc12bb80927606
1,157
https://github.com/rs/pushd/blob/d69b453eaacc2964d67515ebaecc12bb80927606/lib/api.coffee
10
59
rs/pushd:lib/api.coffee:5:raw_corpus
raw_corpus
# Publish an event app.post '/event/:event_id', authorize('publish'), (req, res) -> res.send 204 eventPublisher.publish(req.event, req.body) # Delete an event app.delete '/event/:event_id', authorize('publish'), (req, res) -> req.event.delete (deleted) -> if not deleted ...
CoffeeScript
rs/pushd
lib/api.coffee
MIT
d69b453eaacc2964d67515ebaecc12bb80927606
1,157
https://github.com/rs/pushd/blob/d69b453eaacc2964d67515ebaecc12bb80927606/lib/api.coffee
160
173
rs/pushd:lib/api.coffee:5:coffee_to_js
coffee_to_js
Convert this CoffeeScript to JavaScript. ```coffeescript # Publish an event app.post '/event/:event_id', authorize('publish'), (req, res) -> res.send 204 eventPublisher.publish(req.event, req.body) # Delete an event app.delete '/event/:event_id', authorize('publish'), (req, res) -> ...
// Publish an event app.post('/event/:event_id', authorize('publish'), function(req, res) { res.send(204); return eventPublisher.publish(req.event, req.body); }); // Delete an event app.delete('/event/:event_id', authorize('publish'), function(req, res) { return req.event.delete(function(deleted) { if (!dele...
CoffeeScript
JavaScript
rs/pushd
lib/api.coffee
MIT
d69b453eaacc2964d67515ebaecc12bb80927606
1,157
https://github.com/rs/pushd/blob/d69b453eaacc2964d67515ebaecc12bb80927606/lib/api.coffee
160
173
rs/pushd:lib/api.coffee:5:js_to_coffee
js_to_coffee
Convert this JavaScript to CoffeeScript. ```javascript // Publish an event app.post('/event/:event_id', authorize('publish'), function(req, res) { res.send(204); return eventPublisher.publish(req.event, req.body); }); // Delete an event app.delete('/event/:event_id', authorize('publish'), function(req, res) { re...
# Publish an event app.post '/event/:event_id', authorize('publish'), (req, res) -> res.send 204 eventPublisher.publish(req.event, req.body) # Delete an event app.delete '/event/:event_id', authorize('publish'), (req, res) -> req.event.delete (deleted) -> if not deleted ...
JavaScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
d69b453eaacc2964d67515ebaecc12bb80927606
1,157
https://github.com/rs/pushd/blob/d69b453eaacc2964d67515ebaecc12bb80927606/lib/api.coffee
160
173
rs/pushd:lib/api.coffee:5:completion
completion
# Publish an event app.post '/event/:event_id', authorize('publish'), (req, res) -> res.send 204 eventPublisher.publish(req.event, req.body) # Delete an event app.delete '/event/:event_id', authorize('publish'), (req, res) ->
req.event.delete (deleted) -> if not deleted logger.error "No event #{req.event.name}" if deleted res.send 204 else res.send 404
CoffeeScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
d69b453eaacc2964d67515ebaecc12bb80927606
1,157
https://github.com/rs/pushd/blob/d69b453eaacc2964d67515ebaecc12bb80927606/lib/api.coffee
160
173
rs/pushd:lib/api.coffee:1:raw_corpus
raw_corpus
filterFields = (params) -> fields = {} fields[key] = val for own key, val of params when key in ['proto', 'token', 'lang', 'badge', 'version', 'category','contentAvailable'] return fields
CoffeeScript
rs/pushd
lib/api.coffee
MIT
e6124dc3cd21fb1a67702e92c169ca1ccc757469
1,157
https://github.com/rs/pushd/blob/e6124dc3cd21fb1a67702e92c169ca1ccc757469/lib/api.coffee
5
8
rs/pushd:lib/api.coffee:1:coffee_to_js
coffee_to_js
Convert this CoffeeScript to JavaScript. ```coffeescript filterFields = (params) -> fields = {} fields[key] = val for own key, val of params when key in ['proto', 'token', 'lang', 'badge', 'version', 'category','contentAvailable'] return fields ```
var filterFields, hasProp = {}.hasOwnProperty; filterFields = function(params) { var fields, key, val; fields = {}; for (key in params) { if (!hasProp.call(params, key)) continue; val = params[key]; if (key === 'proto' || key === 'token' || key === 'lang' || key === 'badge' || key === 'version' || ...
CoffeeScript
JavaScript
rs/pushd
lib/api.coffee
MIT
e6124dc3cd21fb1a67702e92c169ca1ccc757469
1,157
https://github.com/rs/pushd/blob/e6124dc3cd21fb1a67702e92c169ca1ccc757469/lib/api.coffee
5
8
rs/pushd:lib/api.coffee:1:js_to_coffee
js_to_coffee
Convert this JavaScript to CoffeeScript. ```javascript var filterFields, hasProp = {}.hasOwnProperty; filterFields = function(params) { var fields, key, val; fields = {}; for (key in params) { if (!hasProp.call(params, key)) continue; val = params[key]; if (key === 'proto' || key === 'token' || key...
filterFields = (params) -> fields = {} fields[key] = val for own key, val of params when key in ['proto', 'token', 'lang', 'badge', 'version', 'category','contentAvailable'] return fields
JavaScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
e6124dc3cd21fb1a67702e92c169ca1ccc757469
1,157
https://github.com/rs/pushd/blob/e6124dc3cd21fb1a67702e92c169ca1ccc757469/lib/api.coffee
5
8
rs/pushd:lib/api.coffee:1:completion
completion
filterFields = (params) -> fields = {}
fields[key] = val for own key, val of params when key in ['proto', 'token', 'lang', 'badge', 'version', 'category','contentAvailable'] return fields
CoffeeScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
e6124dc3cd21fb1a67702e92c169ca1ccc757469
1,157
https://github.com/rs/pushd/blob/e6124dc3cd21fb1a67702e92c169ca1ccc757469/lib/api.coffee
5
8
rs/pushd:lib/api.coffee:1:raw_corpus
raw_corpus
filterFields = (params) -> fields = {} fields[key] = val for own key, val of params when key in ['proto', 'token', 'lang', 'badge', 'version'] return fields
CoffeeScript
rs/pushd
lib/api.coffee
MIT
5c670f59162d10b6d3073300fc069cb6a0ddc8ec
1,157
https://github.com/rs/pushd/blob/5c670f59162d10b6d3073300fc069cb6a0ddc8ec/lib/api.coffee
5
8
rs/pushd:lib/api.coffee:1:coffee_to_js
coffee_to_js
Convert this CoffeeScript to JavaScript. ```coffeescript filterFields = (params) -> fields = {} fields[key] = val for own key, val of params when key in ['proto', 'token', 'lang', 'badge', 'version'] return fields ```
var filterFields, hasProp = {}.hasOwnProperty; filterFields = function(params) { var fields, key, val; fields = {}; for (key in params) { if (!hasProp.call(params, key)) continue; val = params[key]; if (key === 'proto' || key === 'token' || key === 'lang' || key === 'badge' || key === 'version') { ...
CoffeeScript
JavaScript
rs/pushd
lib/api.coffee
MIT
5c670f59162d10b6d3073300fc069cb6a0ddc8ec
1,157
https://github.com/rs/pushd/blob/5c670f59162d10b6d3073300fc069cb6a0ddc8ec/lib/api.coffee
5
8
rs/pushd:lib/api.coffee:1:js_to_coffee
js_to_coffee
Convert this JavaScript to CoffeeScript. ```javascript var filterFields, hasProp = {}.hasOwnProperty; filterFields = function(params) { var fields, key, val; fields = {}; for (key in params) { if (!hasProp.call(params, key)) continue; val = params[key]; if (key === 'proto' || key === 'token' || key...
filterFields = (params) -> fields = {} fields[key] = val for own key, val of params when key in ['proto', 'token', 'lang', 'badge', 'version'] return fields
JavaScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
5c670f59162d10b6d3073300fc069cb6a0ddc8ec
1,157
https://github.com/rs/pushd/blob/5c670f59162d10b6d3073300fc069cb6a0ddc8ec/lib/api.coffee
5
8
rs/pushd:lib/api.coffee:1:completion
completion
filterFields = (params) -> fields = {}
fields[key] = val for own key, val of params when key in ['proto', 'token', 'lang', 'badge', 'version'] return fields
CoffeeScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
5c670f59162d10b6d3073300fc069cb6a0ddc8ec
1,157
https://github.com/rs/pushd/blob/5c670f59162d10b6d3073300fc069cb6a0ddc8ec/lib/api.coffee
5
8
rs/pushd:lib/api.coffee:4:raw_corpus
raw_corpus
else if action == 'del' req.subscriber.removeSubscription event, (deleted) -> callback(deleted) else if action == 'set' req.subscriber.addSubscription event, options, (added) -> callback(!added) # should return false...
CoffeeScript
rs/pushd
lib/api.coffee
MIT
0188f6feb3fbaf22d5d0e624ec7e7ee924fccd71
1,157
https://github.com/rs/pushd/blob/0188f6feb3fbaf22d5d0e624ec7e7ee924fccd71/lib/api.coffee
110
159
rs/pushd:lib/api.coffee:4:completion
completion
else if action == 'del' req.subscriber.removeSubscription event, (deleted) -> callback(deleted) else if action == 'set' req.subscriber.addSubscription event, options, (added) -> callback(!added) # should return false...
options |= req.event.OPTION_IGNORE_MESSAGE req.subscriber.addSubscription req.event, options, (added) -> if added? # added is null if subscriber doesn't exist res.send if added then 201 else 204 else logger.error "No subscriber #{req.subscriber.id}" ...
CoffeeScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
0188f6feb3fbaf22d5d0e624ec7e7ee924fccd71
1,157
https://github.com/rs/pushd/blob/0188f6feb3fbaf22d5d0e624ec7e7ee924fccd71/lib/api.coffee
110
159
rs/pushd:lib/api.coffee:3:raw_corpus
raw_corpus
subsAndOptions = {} for sub in subs subsAndOptions[sub.event.name] = {ignore_message: (sub.options & sub.event.OPTION_IGNORE_MESSAGE) isnt 0} logger.verbose "Status of #{req.subscriber.id}: " + JSON.stringify(subsAndOptions) res.json subsAndOptions ...
CoffeeScript
rs/pushd
lib/api.coffee
MIT
394c3c913fa3b01dd539410e44ade84910d911eb
1,157
https://github.com/rs/pushd/blob/394c3c913fa3b01dd539410e44ade84910d911eb/lib/api.coffee
60
109
rs/pushd:lib/api.coffee:3:completion
completion
subsAndOptions = {} for sub in subs subsAndOptions[sub.event.name] = {ignore_message: (sub.options & sub.event.OPTION_IGNORE_MESSAGE) isnt 0} logger.verbose "Status of #{req.subscriber.id}: " + JSON.stringify(subsAndOptions) res.json subsAndOptions ...
req.subscriber.getSubscriptions (subs) -> tasks = [] for sub in subs if sub.event.name of subsToAdd subToAdd = subsToAdd[sub.event.name] if subToAdd.options != sub.options tasks.push ['set', subToAdd.event, subToAdd...
CoffeeScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
394c3c913fa3b01dd539410e44ade84910d911eb
1,157
https://github.com/rs/pushd/blob/394c3c913fa3b01dd539410e44ade84910d911eb/lib/api.coffee
60
109
rs/pushd:lib/api.coffee:4:raw_corpus
raw_corpus
callback(!added) # should return false , (result) -> if not result logger.error "Failed to set properties for #{req.subscriber.id}" res.send if result then 200 else 400 # Get subscriber subscription options app.get '/subscriber/:subscriber_id/subs...
CoffeeScript
rs/pushd
lib/api.coffee
MIT
394c3c913fa3b01dd539410e44ade84910d911eb
1,157
https://github.com/rs/pushd/blob/394c3c913fa3b01dd539410e44ade84910d911eb/lib/api.coffee
110
159
rs/pushd:lib/api.coffee:4:completion
completion
callback(!added) # should return false , (result) -> if not result logger.error "Failed to set properties for #{req.subscriber.id}" res.send if result then 200 else 400 # Get subscriber subscription options app.get '/subscriber/:subscriber_id/subs...
logger.error "No subscriber #{req.subscriber.id}" res.send 404 # Unsubscribe a subscriber from an event app.delete '/subscriber/:subscriber_id/subscriptions/:event_id', authorize('register'), (req, res) -> req.subscriber.removeSubscription req.event, (deleted) -> if not dele...
CoffeeScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
394c3c913fa3b01dd539410e44ade84910d911eb
1,157
https://github.com/rs/pushd/blob/394c3c913fa3b01dd539410e44ade84910d911eb/lib/api.coffee
110
159
rs/pushd:lib/api.coffee:5:raw_corpus
raw_corpus
# Delete an event app.delete '/event/:event_id', authorize('publish'), (req, res) -> req.event.delete (deleted) -> if not deleted logger.error "No event #{req.event.name}" if deleted res.send 204 else res.send 404
CoffeeScript
rs/pushd
lib/api.coffee
MIT
394c3c913fa3b01dd539410e44ade84910d911eb
1,157
https://github.com/rs/pushd/blob/394c3c913fa3b01dd539410e44ade84910d911eb/lib/api.coffee
160
168
rs/pushd:lib/api.coffee:5:coffee_to_js
coffee_to_js
Convert this CoffeeScript to JavaScript. ```coffeescript # Delete an event app.delete '/event/:event_id', authorize('publish'), (req, res) -> req.event.delete (deleted) -> if not deleted logger.error "No event #{req.event.name}" if deleted res.send 204...
// Delete an event app.delete('/event/:event_id', authorize('publish'), function(req, res) { return req.event.delete(function(deleted) { if (!deleted) { logger.error(`No event ${req.event.name}`); } if (deleted) { return res.send(204); } else { return res.send(404); } }); });
CoffeeScript
JavaScript
rs/pushd
lib/api.coffee
MIT
394c3c913fa3b01dd539410e44ade84910d911eb
1,157
https://github.com/rs/pushd/blob/394c3c913fa3b01dd539410e44ade84910d911eb/lib/api.coffee
160
168
rs/pushd:lib/api.coffee:5:js_to_coffee
js_to_coffee
Convert this JavaScript to CoffeeScript. ```javascript // Delete an event app.delete('/event/:event_id', authorize('publish'), function(req, res) { return req.event.delete(function(deleted) { if (!deleted) { logger.error(`No event ${req.event.name}`); } if (deleted) { return res.send(204); ...
# Delete an event app.delete '/event/:event_id', authorize('publish'), (req, res) -> req.event.delete (deleted) -> if not deleted logger.error "No event #{req.event.name}" if deleted res.send 204 else res.send 404
JavaScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
394c3c913fa3b01dd539410e44ade84910d911eb
1,157
https://github.com/rs/pushd/blob/394c3c913fa3b01dd539410e44ade84910d911eb/lib/api.coffee
160
168
rs/pushd:lib/api.coffee:5:completion
completion
# Delete an event app.delete '/event/:event_id', authorize('publish'), (req, res) -> req.event.delete (deleted) -> if not deleted
logger.error "No event #{req.event.name}" if deleted res.send 204 else res.send 404
CoffeeScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
394c3c913fa3b01dd539410e44ade84910d911eb
1,157
https://github.com/rs/pushd/blob/394c3c913fa3b01dd539410e44ade84910d911eb/lib/api.coffee
160
168
rs/pushd:lib/api.coffee:2:raw_corpus
raw_corpus
exports.setupRestApi = (app, createSubscriber, getEventFromId, authorize, testSubscriber, eventPublisher) -> authorize ?= (realm) -> # subscriber registration app.post '/subscribers', authorize('register'), (req, res) -> try fields = filterFields(req.body) createSubscriber f...
CoffeeScript
rs/pushd
lib/api.coffee
MIT
40cc1594f102d10db35288825b86de42f9d2917c
1,157
https://github.com/rs/pushd/blob/40cc1594f102d10db35288825b86de42f9d2917c/lib/api.coffee
9
58
rs/pushd:lib/api.coffee:2:completion
completion
exports.setupRestApi = (app, createSubscriber, getEventFromId, authorize, testSubscriber, eventPublisher) -> authorize ?= (realm) -> # subscriber registration app.post '/subscribers', authorize('register'), (req, res) -> try fields = filterFields(req.body) createSubscriber f...
# Unregister subscriber app.delete '/subscriber/:subscriber_id', authorize('register'), (req, res) -> req.subscriber.delete (deleted) -> res.send if deleted then 204 else 404 app.post '/subscriber/:subscriber_id/test', authorize('register'), (req, res) -> testSubscriber(req.subscrib...
CoffeeScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
40cc1594f102d10db35288825b86de42f9d2917c
1,157
https://github.com/rs/pushd/blob/40cc1594f102d10db35288825b86de42f9d2917c/lib/api.coffee
9
58
rs/pushd:lib/api.coffee:3:raw_corpus
raw_corpus
try event = getEventFromId(eventId) options = 0 if optionsDict? and typeof(optionsDict) is 'object' and optionsDict.ignore_message options |= event.OPTION_IGNORE_MESSAGE subsToAdd[event.name] = event: event, options: options ...
CoffeeScript
rs/pushd
lib/api.coffee
MIT
40cc1594f102d10db35288825b86de42f9d2917c
1,157
https://github.com/rs/pushd/blob/40cc1594f102d10db35288825b86de42f9d2917c/lib/api.coffee
59
108
rs/pushd:lib/api.coffee:3:coffee_to_js
coffee_to_js
Convert this CoffeeScript to JavaScript. ```coffeescript try event = getEventFromId(eventId) options = 0 if optionsDict? and typeof(optionsDict) is 'object' and optionsDict.ignore_message options |= event.OPTION_IGNORE_MESSAGE subsToAdd...
var error, event, options; try { event = getEventFromId(eventId); options = 0; if ((typeof optionsDict !== "undefined" && optionsDict !== null) && typeof optionsDict === 'object' && optionsDict.ignore_message) { options |= event.OPTION_IGNORE_MESSAGE; } subsToAdd[event.name] = { event: event, opt...
CoffeeScript
JavaScript
rs/pushd
lib/api.coffee
MIT
40cc1594f102d10db35288825b86de42f9d2917c
1,157
https://github.com/rs/pushd/blob/40cc1594f102d10db35288825b86de42f9d2917c/lib/api.coffee
59
108
rs/pushd:lib/api.coffee:3:js_to_coffee
js_to_coffee
Convert this JavaScript to CoffeeScript. ```javascript var error, event, options; try { event = getEventFromId(eventId); options = 0; if ((typeof optionsDict !== "undefined" && optionsDict !== null) && typeof optionsDict === 'object' && optionsDict.ignore_message) { options |= event.OPTION_IGNORE_MESSAGE; ...
try event = getEventFromId(eventId) options = 0 if optionsDict? and typeof(optionsDict) is 'object' and optionsDict.ignore_message options |= event.OPTION_IGNORE_MESSAGE subsToAdd[event.name] = event: event, options: options ...
JavaScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
40cc1594f102d10db35288825b86de42f9d2917c
1,157
https://github.com/rs/pushd/blob/40cc1594f102d10db35288825b86de42f9d2917c/lib/api.coffee
59
108
rs/pushd:lib/api.coffee:3:completion
completion
try event = getEventFromId(eventId) options = 0 if optionsDict? and typeof(optionsDict) is 'object' and optionsDict.ignore_message options |= event.OPTION_IGNORE_MESSAGE subsToAdd[event.name] = event: event, options: options ...
async.every tasks, (task, callback) -> [action, event, options] = task if action == 'add' req.subscriber.addSubscription event, options, (added) -> callback(added) else if action == 'del' req.subscriber.remov...
CoffeeScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
40cc1594f102d10db35288825b86de42f9d2917c
1,157
https://github.com/rs/pushd/blob/40cc1594f102d10db35288825b86de42f9d2917c/lib/api.coffee
59
108
rs/pushd:lib/api.coffee:4:raw_corpus
raw_corpus
if parseInt req.body.ignore_message options |= req.event.OPTION_IGNORE_MESSAGE req.subscriber.addSubscription req.event, options, (added) -> if added? # added is null if subscriber doesn't exist res.send if added then 201 else 204 else res.send...
CoffeeScript
rs/pushd
lib/api.coffee
MIT
40cc1594f102d10db35288825b86de42f9d2917c
1,157
https://github.com/rs/pushd/blob/40cc1594f102d10db35288825b86de42f9d2917c/lib/api.coffee
109
138
rs/pushd:lib/api.coffee:4:coffee_to_js
coffee_to_js
Convert this CoffeeScript to JavaScript. ```coffeescript if parseInt req.body.ignore_message options |= req.event.OPTION_IGNORE_MESSAGE req.subscriber.addSubscription req.event, options, (added) -> if added? # added is null if subscriber doesn't exist res.send if added th...
if (parseInt(req.body.ignore_message)) { options |= req.event.OPTION_IGNORE_MESSAGE; } req.subscriber.addSubscription(req.event, options, function(added) { if (added != null) { return res.send(added ? 201 : 204); } else { return res.send(404); // added is null if subscriber doesn't exist } }); // Unsu...
CoffeeScript
JavaScript
rs/pushd
lib/api.coffee
MIT
40cc1594f102d10db35288825b86de42f9d2917c
1,157
https://github.com/rs/pushd/blob/40cc1594f102d10db35288825b86de42f9d2917c/lib/api.coffee
109
138
rs/pushd:lib/api.coffee:4:js_to_coffee
js_to_coffee
Convert this JavaScript to CoffeeScript. ```javascript if (parseInt(req.body.ignore_message)) { options |= req.event.OPTION_IGNORE_MESSAGE; } req.subscriber.addSubscription(req.event, options, function(added) { if (added != null) { return res.send(added ? 201 : 204); } else { return res.send(404); // add...
if parseInt req.body.ignore_message options |= req.event.OPTION_IGNORE_MESSAGE req.subscriber.addSubscription req.event, options, (added) -> if added? # added is null if subscriber doesn't exist res.send if added then 201 else 204 else res.send...
JavaScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
40cc1594f102d10db35288825b86de42f9d2917c
1,157
https://github.com/rs/pushd/blob/40cc1594f102d10db35288825b86de42f9d2917c/lib/api.coffee
109
138
rs/pushd:lib/api.coffee:4:completion
completion
if parseInt req.body.ignore_message options |= req.event.OPTION_IGNORE_MESSAGE req.subscriber.addSubscription req.event, options, (added) -> if added? # added is null if subscriber doesn't exist res.send if added then 201 else 204 else res.send...
req.event.info (info) -> res.json info, if info? then 200 else 404 # Publish an event app.post '/event/:event_id', authorize('publish'), (req, res) -> res.send 204 eventPublisher.publish(req.event, req.body) # Delete an event app.delete '/event/:event_id', authorize('publis...
CoffeeScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
40cc1594f102d10db35288825b86de42f9d2917c
1,157
https://github.com/rs/pushd/blob/40cc1594f102d10db35288825b86de42f9d2917c/lib/api.coffee
109
138
rs/pushd:lib/api.coffee:4:raw_corpus
raw_corpus
if parseInt req.body.ignore_message options |= req.event.OPTION_IGNORE_MESSAGE req.subscriber.addSubscription req.event, options, (added) -> if added? # added is null if subscriber doesn't exist res.send if added then 201 else 204 else res.send...
CoffeeScript
rs/pushd
lib/api.coffee
MIT
073d9dce772f5a8ca5ffca3a0424edcd9f688357
1,157
https://github.com/rs/pushd/blob/073d9dce772f5a8ca5ffca3a0424edcd9f688357/lib/api.coffee
109
135
rs/pushd:lib/api.coffee:4:completion
completion
if parseInt req.body.ignore_message options |= req.event.OPTION_IGNORE_MESSAGE req.subscriber.addSubscription req.event, options, (added) -> if added? # added is null if subscriber doesn't exist res.send if added then 201 else 204 else res.send...
# Event stats app.get '/event/:event_id', authorize('register'), (req, res) -> req.event.info (info) -> res.json info, if info? then 200 else 404 # Publish an event app.post '/event/:event_id', authorize('publish'), (req, res) -> res.send 204 eventPublisher.publish(req.e...
CoffeeScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
073d9dce772f5a8ca5ffca3a0424edcd9f688357
1,157
https://github.com/rs/pushd/blob/073d9dce772f5a8ca5ffca3a0424edcd9f688357/lib/api.coffee
109
135
rs/pushd:lib/api.coffee:4:raw_corpus
raw_corpus
if req.body.ignore_message options |= req.event.OPTION_IGNORE_MESSAGE req.subscriber.addSubscription req.event, options, (added) -> if added? # added is null if subscriber doesn't exist res.send if added then 201 else 204 else res.send 404 ...
CoffeeScript
rs/pushd
lib/api.coffee
MIT
c75fba14c2139b7dd90b5a0455731975fe7a6b68
1,157
https://github.com/rs/pushd/blob/c75fba14c2139b7dd90b5a0455731975fe7a6b68/lib/api.coffee
109
135
rs/pushd:lib/api.coffee:4:completion
completion
if req.body.ignore_message options |= req.event.OPTION_IGNORE_MESSAGE req.subscriber.addSubscription req.event, options, (added) -> if added? # added is null if subscriber doesn't exist res.send if added then 201 else 204 else res.send 404 ...
# Event stats app.get '/event/:event_id', authorize('register'), (req, res) -> req.event.info (info) -> res.json info, if info? then 200 else 404 # Publish an event app.post '/event/:event_id', authorize('publish'), (req, res) -> res.send 204 eventPublisher.publish(req.e...
CoffeeScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
c75fba14c2139b7dd90b5a0455731975fe7a6b68
1,157
https://github.com/rs/pushd/blob/c75fba14c2139b7dd90b5a0455731975fe7a6b68/lib/api.coffee
109
135
rs/pushd:lib/api.coffee:4:raw_corpus
raw_corpus
if req.body.ignore_message options |= event.OPTION_IGNORE_MESSAGE req.subscriber.addSubscription req.event, options, (added) -> if added? # added is null if subscriber doesn't exist res.send if added then 201 else 204 else res.send 404 # U...
CoffeeScript
rs/pushd
lib/api.coffee
MIT
6c5a5cae436e00831c43b9acc2de48063f50b102
1,157
https://github.com/rs/pushd/blob/6c5a5cae436e00831c43b9acc2de48063f50b102/lib/api.coffee
109
135
rs/pushd:lib/api.coffee:4:completion
completion
if req.body.ignore_message options |= event.OPTION_IGNORE_MESSAGE req.subscriber.addSubscription req.event, options, (added) -> if added? # added is null if subscriber doesn't exist res.send if added then 201 else 204 else res.send 404 # U...
# Event stats app.get '/event/:event_id', authorize('register'), (req, res) -> req.event.info (info) -> res.json info, if info? then 200 else 404 # Publish an event app.post '/event/:event_id', authorize('publish'), (req, res) -> res.send 204 eventPublisher.publish(req.e...
CoffeeScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
6c5a5cae436e00831c43b9acc2de48063f50b102
1,157
https://github.com/rs/pushd/blob/6c5a5cae436e00831c43b9acc2de48063f50b102/lib/api.coffee
109
135
rs/pushd:lib/api.coffee:2:raw_corpus
raw_corpus
exports.setupRestApi = (app, createSubscriber, getEventFromId, authorize, testSubscriber) -> authorize ?= (realm) -> # subscriber registration app.post '/subscribers', authorize('register'), (req, res) -> try fields = filterFields(req.body) createSubscriber fields, (subscrib...
CoffeeScript
rs/pushd
lib/api.coffee
MIT
76fdf53cdb0ec587718f5fcf5e9c2c51cbfe6b01
1,157
https://github.com/rs/pushd/blob/76fdf53cdb0ec587718f5fcf5e9c2c51cbfe6b01/lib/api.coffee
9
58
rs/pushd:lib/api.coffee:2:completion
completion
exports.setupRestApi = (app, createSubscriber, getEventFromId, authorize, testSubscriber) -> authorize ?= (realm) -> # subscriber registration app.post '/subscribers', authorize('register'), (req, res) -> try fields = filterFields(req.body) createSubscriber fields, (subscrib...
# Unregister subscriber app.delete '/subscriber/:subscriber_id', authorize('register'), (req, res) -> req.subscriber.delete (deleted) -> res.send if deleted then 204 else 404 app.post '/subscriber/:subscriber_id/test', authorize('register'), (req, res) -> testSubscriber(req.subscrib...
CoffeeScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
76fdf53cdb0ec587718f5fcf5e9c2c51cbfe6b01
1,157
https://github.com/rs/pushd/blob/76fdf53cdb0ec587718f5fcf5e9c2c51cbfe6b01/lib/api.coffee
9
58
rs/pushd:lib/api.coffee:4:raw_corpus
raw_corpus
if req.body.ignore_message options |= event.OPTION_IGNORE_MESSAGE req.subscriber.addSubscription req.event, options, (added) -> if added? # added is null if subscriber doesn't exist res.send if added then 201 else 204 else res.send 404 # U...
CoffeeScript
rs/pushd
lib/api.coffee
MIT
76fdf53cdb0ec587718f5fcf5e9c2c51cbfe6b01
1,157
https://github.com/rs/pushd/blob/76fdf53cdb0ec587718f5fcf5e9c2c51cbfe6b01/lib/api.coffee
109
135
rs/pushd:lib/api.coffee:4:completion
completion
if req.body.ignore_message options |= event.OPTION_IGNORE_MESSAGE req.subscriber.addSubscription req.event, options, (added) -> if added? # added is null if subscriber doesn't exist res.send if added then 201 else 204 else res.send 404 # U...
# Event stats app.get '/event/:event_id', authorize('register'), (req, res) -> req.event.info (info) -> res.json info, if info? then 200 else 404 # Publish an event app.post '/event/:event_id', authorize('publish'), (req, res) -> res.send 204 req.event.publish(req.body) ...
CoffeeScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
76fdf53cdb0ec587718f5fcf5e9c2c51cbfe6b01
1,157
https://github.com/rs/pushd/blob/76fdf53cdb0ec587718f5fcf5e9c2c51cbfe6b01/lib/api.coffee
109
135
rs/pushd:lib/api.coffee:2:raw_corpus
raw_corpus
exports.setupRestApi = (app, createSubscriber, getEventFromId, authorize) -> authorize ?= (realm) -> # subscriber registration app.post '/subscribers', authorize('register'), (req, res) -> try fields = filterFields(req.body) createSubscriber fields, (subscriber, created) -> ...
CoffeeScript
rs/pushd
lib/api.coffee
MIT
cb62436ea3f0c4b9d2c3bc0a5848571250ee6826
1,157
https://github.com/rs/pushd/blob/cb62436ea3f0c4b9d2c3bc0a5848571250ee6826/lib/api.coffee
9
58
rs/pushd:lib/api.coffee:2:completion
completion
exports.setupRestApi = (app, createSubscriber, getEventFromId, authorize) -> authorize ?= (realm) -> # subscriber registration app.post '/subscribers', authorize('register'), (req, res) -> try fields = filterFields(req.body) createSubscriber fields, (subscriber, created) -> ...
# Unregister subscriber app.delete '/subscriber/:subscriber_id', authorize('register'), (req, res) -> req.subscriber.delete (deleted) -> res.send if deleted then 204 else 404 # Get subscriber subscriptions app.get '/subscriber/:subscriber_id/subscriptions', authorize('register'), (req, ...
CoffeeScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
cb62436ea3f0c4b9d2c3bc0a5848571250ee6826
1,157
https://github.com/rs/pushd/blob/cb62436ea3f0c4b9d2c3bc0a5848571250ee6826/lib/api.coffee
9
58
rs/pushd:lib/api.coffee:3:raw_corpus
raw_corpus
options |= event.OPTION_IGNORE_MESSAGE subsToAdd[event.name] = event: event, options: options catch error res.json error: error.message, 400 return req.subscriber.getSubscriptions (subs) -> tasks = [] for sub in subs ...
CoffeeScript
rs/pushd
lib/api.coffee
MIT
cb62436ea3f0c4b9d2c3bc0a5848571250ee6826
1,157
https://github.com/rs/pushd/blob/cb62436ea3f0c4b9d2c3bc0a5848571250ee6826/lib/api.coffee
59
108
rs/pushd:lib/api.coffee:3:completion
completion
options |= event.OPTION_IGNORE_MESSAGE subsToAdd[event.name] = event: event, options: options catch error res.json error: error.message, 400 return req.subscriber.getSubscriptions (subs) -> tasks = [] for sub in subs ...
callback(added) else if action == 'del' req.subscriber.removeSubscription event, (deleted) -> callback(deleted) else if action == 'set' req.subscriber.addSubscription event, options, (added) -> callba...
CoffeeScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
cb62436ea3f0c4b9d2c3bc0a5848571250ee6826
1,157
https://github.com/rs/pushd/blob/cb62436ea3f0c4b9d2c3bc0a5848571250ee6826/lib/api.coffee
59
108
rs/pushd:lib/api.coffee:4:raw_corpus
raw_corpus
res.send if added then 201 else 204 else res.send 404 # Unsubscribe a subscriber from an event app.delete '/subscriber/:subscriber_id/subscriptions/:event_id', authorize('register'), (req, res) -> req.subscriber.removeSubscription req.event, (deleted) -> res.send...
CoffeeScript
rs/pushd
lib/api.coffee
MIT
cb62436ea3f0c4b9d2c3bc0a5848571250ee6826
1,157
https://github.com/rs/pushd/blob/cb62436ea3f0c4b9d2c3bc0a5848571250ee6826/lib/api.coffee
109
131
rs/pushd:lib/api.coffee:4:completion
completion
res.send if added then 201 else 204 else res.send 404 # Unsubscribe a subscriber from an event app.delete '/subscriber/:subscriber_id/subscriptions/:event_id', authorize('register'), (req, res) -> req.subscriber.removeSubscription req.event, (deleted) -> res.send...
req.event.info (info) -> res.json info, if info? then 200 else 404 # Publish an event app.post '/event/:event_id', authorize('publish'), (req, res) -> res.send 204 req.event.publish(req.body) # Delete an event app.delete '/event/:event_id', authorize('publish'), (req, res) ...
CoffeeScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
cb62436ea3f0c4b9d2c3bc0a5848571250ee6826
1,157
https://github.com/rs/pushd/blob/cb62436ea3f0c4b9d2c3bc0a5848571250ee6826/lib/api.coffee
109
131
rs/pushd:lib/api.coffee:2:raw_corpus
raw_corpus
exports.setupRestApi = (app, createSubscriber, authorize) -> authorize ?= (realm) -> # subscriber registration app.post '/subscribers', authorize('register'), (req, res) -> try fields = filterFields(req.body) createSubscriber fields, (subscriber, created) -> ...
CoffeeScript
rs/pushd
lib/api.coffee
MIT
8eaa4105d86d7883c8bb42a0f620773d5bf38709
1,157
https://github.com/rs/pushd/blob/8eaa4105d86d7883c8bb42a0f620773d5bf38709/lib/api.coffee
6
55
rs/pushd:lib/api.coffee:2:coffee_to_js
coffee_to_js
Convert this CoffeeScript to JavaScript. ```coffeescript exports.setupRestApi = (app, createSubscriber, authorize) -> authorize ?= (realm) -> # subscriber registration app.post '/subscribers', authorize('register'), (req, res) -> try fields = filterFields(req.body) createSub...
exports.setupRestApi = function(app, createSubscriber, authorize) { if (authorize == null) { authorize = function(realm) {}; } // subscriber registration app.post('/subscribers', authorize('register'), function(req, res) { var error, fields; try { fields = filterFields(req.body); return ...
CoffeeScript
JavaScript
rs/pushd
lib/api.coffee
MIT
8eaa4105d86d7883c8bb42a0f620773d5bf38709
1,157
https://github.com/rs/pushd/blob/8eaa4105d86d7883c8bb42a0f620773d5bf38709/lib/api.coffee
6
55
rs/pushd:lib/api.coffee:2:js_to_coffee
js_to_coffee
Convert this JavaScript to CoffeeScript. ```javascript exports.setupRestApi = function(app, createSubscriber, authorize) { if (authorize == null) { authorize = function(realm) {}; } // subscriber registration app.post('/subscribers', authorize('register'), function(req, res) { var error, fields; try...
exports.setupRestApi = (app, createSubscriber, authorize) -> authorize ?= (realm) -> # subscriber registration app.post '/subscribers', authorize('register'), (req, res) -> try fields = filterFields(req.body) createSubscriber fields, (subscriber, created) -> ...
JavaScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
8eaa4105d86d7883c8bb42a0f620773d5bf38709
1,157
https://github.com/rs/pushd/blob/8eaa4105d86d7883c8bb42a0f620773d5bf38709/lib/api.coffee
6
55
rs/pushd:lib/api.coffee:2:completion
completion
exports.setupRestApi = (app, createSubscriber, authorize) -> authorize ?= (realm) -> # subscriber registration app.post '/subscribers', authorize('register'), (req, res) -> try fields = filterFields(req.body) createSubscriber fields, (subscriber, created) -> ...
res.send if edited then 204 else 404 # Unregister subscriber app.delete '/subscriber/:subscriber_id', authorize('register'), (req, res) -> req.subscriber.delete (deleted) -> res.send if deleted then 204 else 404 # Get subscriber subscriptions app.get '/subscriber/:subscriber_id/sub...
CoffeeScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
8eaa4105d86d7883c8bb42a0f620773d5bf38709
1,157
https://github.com/rs/pushd/blob/8eaa4105d86d7883c8bb42a0f620773d5bf38709/lib/api.coffee
6
55
rs/pushd:lib/api.coffee:3:raw_corpus
raw_corpus
# Subscribe a subscriber to an event app.post '/subscriber/:subscriber_id/subscriptions/:event_id', authorize('register'), (req, res) -> options = 0 if req.body.ignore_message options |= event.OPTION_IGNORE_MESSAGE req.subscriber.addSubscription req.event, options, (added) -> ...
CoffeeScript
rs/pushd
lib/api.coffee
MIT
8eaa4105d86d7883c8bb42a0f620773d5bf38709
1,157
https://github.com/rs/pushd/blob/8eaa4105d86d7883c8bb42a0f620773d5bf38709/lib/api.coffee
56
85
rs/pushd:lib/api.coffee:3:completion
completion
# Subscribe a subscriber to an event app.post '/subscriber/:subscriber_id/subscriptions/:event_id', authorize('register'), (req, res) -> options = 0 if req.body.ignore_message options |= event.OPTION_IGNORE_MESSAGE req.subscriber.addSubscription req.event, options, (added) -> ...
# Event stats app.get '/event/:event_id', authorize('register'), (req, res) -> req.event.info (info) -> res.json info, if info? then 200 else 404 # Publish an event app.post '/event/:event_id', authorize('publish'), (req, res) -> res.send 204 req.event.publish(req.body) ...
CoffeeScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
8eaa4105d86d7883c8bb42a0f620773d5bf38709
1,157
https://github.com/rs/pushd/blob/8eaa4105d86d7883c8bb42a0f620773d5bf38709/lib/api.coffee
56
85
rs/pushd:lib/api.coffee:3:raw_corpus
raw_corpus
# Subscribe a subscriber to an event app.post '/subscriber/:subscriber_id/subscriptions/:event_id', authorize('register'), (req, res) -> options = 0 if req.body.ignore_message options |= event.OPTION_IGNORE_MESSAGE req.subscriber.addSubscription req.event, options, (added) -> ...
CoffeeScript
rs/pushd
lib/api.coffee
MIT
18d8c93a231e9351a0f6a4e1a10c22cbf5ad717a
1,157
https://github.com/rs/pushd/blob/18d8c93a231e9351a0f6a4e1a10c22cbf5ad717a/lib/api.coffee
56
85
rs/pushd:lib/api.coffee:3:completion
completion
# Subscribe a subscriber to an event app.post '/subscriber/:subscriber_id/subscriptions/:event_id', authorize('register'), (req, res) -> options = 0 if req.body.ignore_message options |= event.OPTION_IGNORE_MESSAGE req.subscriber.addSubscription req.event, options, (added) -> ...
# Event stats app.get '/event/:event_id', authorize('register'), (req, res) -> req.event.info (info) -> res.json info, if info? then 200 else 404 # Publish an event app.post '/event/:event_id', authorize('publish'), (req, res) -> res.send 204 req.event.publish(req.body) ...
CoffeeScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
18d8c93a231e9351a0f6a4e1a10c22cbf5ad717a
1,157
https://github.com/rs/pushd/blob/18d8c93a231e9351a0f6a4e1a10c22cbf5ad717a/lib/api.coffee
56
85
rs/pushd:lib/api.coffee:3:raw_corpus
raw_corpus
# Subscribe a subscriber to an event app.post '/subscriber/:subscriber_id/subscriptions/:event_id', authorize('register'), (req, res) -> options = 0 if req.body.ignore_message options |= event.OPTION_IGNORE_MESSAGE req.subscriber.addSubscription req.event, options, (added) -> ...
CoffeeScript
rs/pushd
lib/api.coffee
MIT
83d119660e4c12cd867f1184a2a672226935114f
1,157
https://github.com/rs/pushd/blob/83d119660e4c12cd867f1184a2a672226935114f/lib/api.coffee
56
85
rs/pushd:lib/api.coffee:3:completion
completion
# Subscribe a subscriber to an event app.post '/subscriber/:subscriber_id/subscriptions/:event_id', authorize('register'), (req, res) -> options = 0 if req.body.ignore_message options |= event.OPTION_IGNORE_MESSAGE req.subscriber.addSubscription req.event, options, (added) -> ...
# Event stats app.get '/event/:event_id', authorize('register'), (req, res) -> req.event.info (info) -> res.json info, if info? then 200 else 404 # Publish an event app.post '/event/:event_id', authorize('publish'), (req, res) -> res.send 204 req.event.publish(req.body) ...
CoffeeScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
83d119660e4c12cd867f1184a2a672226935114f
1,157
https://github.com/rs/pushd/blob/83d119660e4c12cd867f1184a2a672226935114f/lib/api.coffee
56
85
rs/pushd:lib/api.coffee:1:raw_corpus
raw_corpus
filterFields = (params) -> fields = {} fields[key] = val for own key, val of params when key in ['proto', 'regid', 'lang', 'badge', 'version'] return fields
CoffeeScript
rs/pushd
lib/api.coffee
MIT
c5ce15f5a762801097f8d8e2ddf523be510d3a1f
1,157
https://github.com/rs/pushd/blob/c5ce15f5a762801097f8d8e2ddf523be510d3a1f/lib/api.coffee
1
4
rs/pushd:lib/api.coffee:1:coffee_to_js
coffee_to_js
Convert this CoffeeScript to JavaScript. ```coffeescript filterFields = (params) -> fields = {} fields[key] = val for own key, val of params when key in ['proto', 'regid', 'lang', 'badge', 'version'] return fields ```
var filterFields, hasProp = {}.hasOwnProperty; filterFields = function(params) { var fields, key, val; fields = {}; for (key in params) { if (!hasProp.call(params, key)) continue; val = params[key]; if (key === 'proto' || key === 'regid' || key === 'lang' || key === 'badge' || key === 'version') { ...
CoffeeScript
JavaScript
rs/pushd
lib/api.coffee
MIT
c5ce15f5a762801097f8d8e2ddf523be510d3a1f
1,157
https://github.com/rs/pushd/blob/c5ce15f5a762801097f8d8e2ddf523be510d3a1f/lib/api.coffee
1
4
rs/pushd:lib/api.coffee:1:js_to_coffee
js_to_coffee
Convert this JavaScript to CoffeeScript. ```javascript var filterFields, hasProp = {}.hasOwnProperty; filterFields = function(params) { var fields, key, val; fields = {}; for (key in params) { if (!hasProp.call(params, key)) continue; val = params[key]; if (key === 'proto' || key === 'regid' || key...
filterFields = (params) -> fields = {} fields[key] = val for own key, val of params when key in ['proto', 'regid', 'lang', 'badge', 'version'] return fields
JavaScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
c5ce15f5a762801097f8d8e2ddf523be510d3a1f
1,157
https://github.com/rs/pushd/blob/c5ce15f5a762801097f8d8e2ddf523be510d3a1f/lib/api.coffee
1
4
rs/pushd:lib/api.coffee:1:completion
completion
filterFields = (params) -> fields = {}
fields[key] = val for own key, val of params when key in ['proto', 'regid', 'lang', 'badge', 'version'] return fields
CoffeeScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
c5ce15f5a762801097f8d8e2ddf523be510d3a1f
1,157
https://github.com/rs/pushd/blob/c5ce15f5a762801097f8d8e2ddf523be510d3a1f/lib/api.coffee
1
4
rs/pushd:lib/api.coffee:2:raw_corpus
raw_corpus
exports.setupRestApi = (app, createDevice, authorize) -> authorize ?= (realm) -> # Device registration app.post '/devices', authorize('register'), (req, res) -> try fields = filterFields(req.body) createDevice fields, (device, created) -> device.get (info) ->...
CoffeeScript
rs/pushd
lib/api.coffee
MIT
6e013dce036ea96c8e6ba41cb457470c59c5b1df
1,157
https://github.com/rs/pushd/blob/6e013dce036ea96c8e6ba41cb457470c59c5b1df/lib/api.coffee
6
55
rs/pushd:lib/api.coffee:2:coffee_to_js
coffee_to_js
Convert this CoffeeScript to JavaScript. ```coffeescript exports.setupRestApi = (app, createDevice, authorize) -> authorize ?= (realm) -> # Device registration app.post '/devices', authorize('register'), (req, res) -> try fields = filterFields(req.body) createDevice fields, ...
exports.setupRestApi = function(app, createDevice, authorize) { if (authorize == null) { authorize = function(realm) {}; } // Device registration app.post('/devices', authorize('register'), function(req, res) { var error, fields; try { fields = filterFields(req.body); return createDevice...
CoffeeScript
JavaScript
rs/pushd
lib/api.coffee
MIT
6e013dce036ea96c8e6ba41cb457470c59c5b1df
1,157
https://github.com/rs/pushd/blob/6e013dce036ea96c8e6ba41cb457470c59c5b1df/lib/api.coffee
6
55
rs/pushd:lib/api.coffee:2:js_to_coffee
js_to_coffee
Convert this JavaScript to CoffeeScript. ```javascript exports.setupRestApi = function(app, createDevice, authorize) { if (authorize == null) { authorize = function(realm) {}; } // Device registration app.post('/devices', authorize('register'), function(req, res) { var error, fields; try { fie...
exports.setupRestApi = (app, createDevice, authorize) -> authorize ?= (realm) -> # Device registration app.post '/devices', authorize('register'), (req, res) -> try fields = filterFields(req.body) createDevice fields, (device, created) -> device.get (info) ->...
JavaScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
6e013dce036ea96c8e6ba41cb457470c59c5b1df
1,157
https://github.com/rs/pushd/blob/6e013dce036ea96c8e6ba41cb457470c59c5b1df/lib/api.coffee
6
55
rs/pushd:lib/api.coffee:2:completion
completion
exports.setupRestApi = (app, createDevice, authorize) -> authorize ?= (realm) -> # Device registration app.post '/devices', authorize('register'), (req, res) -> try fields = filterFields(req.body) createDevice fields, (device, created) -> device.get (info) ->...
res.send if edited then 204 else 404 # Unregister device app.delete '/device/:device_id', authorize('register'), (req, res) -> req.device.delete (deleted) -> res.send if deleted then 204 else 404 # Get device subscriptions app.get '/device/:device_id/subscriptions', authorize('regi...
CoffeeScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
6e013dce036ea96c8e6ba41cb457470c59c5b1df
1,157
https://github.com/rs/pushd/blob/6e013dce036ea96c8e6ba41cb457470c59c5b1df/lib/api.coffee
6
55
rs/pushd:lib/api.coffee:3:raw_corpus
raw_corpus
# Subscribe a device to an event app.post '/device/:device_id/subscriptions/:event_id', authorize('register'), (req, res) -> options = 0 if req.body.ignore_message options |= event.OPTION_IGNORE_MESSAGE req.device.addSubscription req.event, options, (added) -> if adde...
CoffeeScript
rs/pushd
lib/api.coffee
MIT
6e013dce036ea96c8e6ba41cb457470c59c5b1df
1,157
https://github.com/rs/pushd/blob/6e013dce036ea96c8e6ba41cb457470c59c5b1df/lib/api.coffee
56
85
rs/pushd:lib/api.coffee:3:completion
completion
# Subscribe a device to an event app.post '/device/:device_id/subscriptions/:event_id', authorize('register'), (req, res) -> options = 0 if req.body.ignore_message options |= event.OPTION_IGNORE_MESSAGE req.device.addSubscription req.event, options, (added) -> if adde...
# Event stats app.get '/event/:event_id', authorize('register'), (req, res) -> req.event.info (info) -> res.json info, if info? then 200 else 404 # Publish an event app.post '/event/:event_id', authorize('publish'), (req, res) -> res.send 204 req.event.publish(req.body) ...
CoffeeScript
CoffeeScript
rs/pushd
lib/api.coffee
MIT
6e013dce036ea96c8e6ba41cb457470c59c5b1df
1,157
https://github.com/rs/pushd/blob/6e013dce036ea96c8e6ba41cb457470c59c5b1df/lib/api.coffee
56
85
rs/pushd:lib/api.coffee:2:raw_corpus
raw_corpus
exports.setupRestApi = (app, createDevice) -> # Device registration app.post '/devices', (req, res) -> try fields = filterFields(req.body) createDevice fields, (device, created) -> device.get (info) -> info.id = device.id re...
CoffeeScript
rs/pushd
lib/api.coffee
MIT
1023eedc22c4742d8ed1a290cd82b82b5be5cd9d
1,157
https://github.com/rs/pushd/blob/1023eedc22c4742d8ed1a290cd82b82b5be5cd9d/lib/api.coffee
6
55