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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
lucasmotta/dploy:src/sftp.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
module.exports = class SFTP
sftp : null
connection : null
connected : null
failed : null
closed : null
closing : null
constructor: ->
@connected = new Signal()
@failed = new Signal()
@closed = new Signal()
@closing = false
# Create a ... | var SFTP;
module.exports = SFTP = (function() {
class SFTP {
constructor() {
this.connected = new Signal();
this.failed = new Signal();
this.closed = new Signal();
this.closing = false;
// Create a new instance of the FTP
this.sftp = new ssh2();
this.sftp.on("error", () ... | CoffeeScript | JavaScript | lucasmotta/dploy | src/sftp.coffee | MIT | b0177c2fdc3c85088d684193e725b2297eecc241 | 973 | https://github.com/lucasmotta/dploy/blob/b0177c2fdc3c85088d684193e725b2297eecc241/src/sftp.coffee | 5 | 54 |
lucasmotta/dploy:src/sftp.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var SFTP;
module.exports = SFTP = (function() {
class SFTP {
constructor() {
this.connected = new Signal();
this.failed = new Signal();
this.closed = new Signal();
this.closing = false;
// Create a new instance of the FTP
... | module.exports = class SFTP
sftp : null
connection : null
connected : null
failed : null
closed : null
closing : null
constructor: ->
@connected = new Signal()
@failed = new Signal()
@closed = new Signal()
@closing = false
# Create a new instance of the FTP
@sftp = new ssh2()
@sftp.on "... | JavaScript | CoffeeScript | lucasmotta/dploy | src/sftp.coffee | MIT | b0177c2fdc3c85088d684193e725b2297eecc241 | 973 | https://github.com/lucasmotta/dploy/blob/b0177c2fdc3c85088d684193e725b2297eecc241/src/sftp.coffee | 5 | 54 |
lucasmotta/dploy:src/sftp.coffee:1:completion | completion | module.exports = class SFTP
sftp : null
connection : null
connected : null
failed : null
closed : null
closing : null
constructor: ->
@connected = new Signal()
@failed = new Signal()
@closed = new Signal()
@closing = false
# Create a new instance of the FTP
@sftp = new ssh2()
@sftp.on "... | return @failed.dispatch() if error
@connection = connection
@connected.dispatch()
###
Connect to the FTP
@param config <object> Configuration file for your connection
###
connect: (config) ->
@sftp.connect
host : config.host
port : config.port
username : config.user
password : config.pass... | CoffeeScript | CoffeeScript | lucasmotta/dploy | src/sftp.coffee | MIT | b0177c2fdc3c85088d684193e725b2297eecc241 | 973 | https://github.com/lucasmotta/dploy/blob/b0177c2fdc3c85088d684193e725b2297eecc241/src/sftp.coffee | 5 | 54 |
lucasmotta/dploy:src/sftp.coffee:2:raw_corpus | raw_corpus | ###
Dispose
###
dispose: ->
if @connected
@connected.dispose()
@connected = null
if @failed
@failed.dispose()
@failed = null
if @closed
@closed.dispose()
@closed = null
###
Retrieve a file on the server
@param path: <string> The path of your file
@param callback: <function> Callback m... | CoffeeScript | lucasmotta/dploy | src/sftp.coffee | MIT | b0177c2fdc3c85088d684193e725b2297eecc241 | 973 | https://github.com/lucasmotta/dploy/blob/b0177c2fdc3c85088d684193e725b2297eecc241/src/sftp.coffee | 55 | 104 | ||
lucasmotta/dploy:src/sftp.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
###
Dispose
###
dispose: ->
if @connected
@connected.dispose()
@connected = null
if @failed
@failed.dispose()
@failed = null
if @closed
@closed.dispose()
@closed = null
###
Retrieve a file on the server
@param path: <string> The ... | /*
Dispose
*/
({
dispose: function() {
if (this.connected) {
this.connected.dispose();
this.connected = null;
}
if (this.failed) {
this.failed.dispose();
this.failed = null;
}
if (this.closed) {
this.closed.dispose();
return this.closed = null;
}
},
/*
... | CoffeeScript | JavaScript | lucasmotta/dploy | src/sftp.coffee | MIT | b0177c2fdc3c85088d684193e725b2297eecc241 | 973 | https://github.com/lucasmotta/dploy/blob/b0177c2fdc3c85088d684193e725b2297eecc241/src/sftp.coffee | 55 | 104 |
lucasmotta/dploy:src/sftp.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
/*
Dispose
*/
({
dispose: function() {
if (this.connected) {
this.connected.dispose();
this.connected = null;
}
if (this.failed) {
this.failed.dispose();
this.failed = null;
}
if (this.closed) {
this.closed.dispos... | ###
Dispose
###
dispose: ->
if @connected
@connected.dispose()
@connected = null
if @failed
@failed.dispose()
@failed = null
if @closed
@closed.dispose()
@closed = null
###
Retrieve a file on the server
@param path: <string> The path of your file
@param callback: <function> Callback m... | JavaScript | CoffeeScript | lucasmotta/dploy | src/sftp.coffee | MIT | b0177c2fdc3c85088d684193e725b2297eecc241 | 973 | https://github.com/lucasmotta/dploy/blob/b0177c2fdc3c85088d684193e725b2297eecc241/src/sftp.coffee | 55 | 104 |
lucasmotta/dploy:src/sftp.coffee:2:completion | completion | ###
Dispose
###
dispose: ->
if @connected
@connected.dispose()
@connected = null
if @failed
@failed.dispose()
@failed = null
if @closed
@closed.dispose()
@closed = null
###
Retrieve a file on the server
@param path: <string> The path of your file
@param callback: <function> Callback m... | ###
Upload a file to the server
@param local_path: <string> The local path of your file
@param remote_path: <string> The remote path where you want your file to be uploaded at
@param callback: <function> Callback method
###
upload: (local_path, remote_path, callback) ->
@connection.fastPut local_path, remote_p... | CoffeeScript | CoffeeScript | lucasmotta/dploy | src/sftp.coffee | MIT | b0177c2fdc3c85088d684193e725b2297eecc241 | 973 | https://github.com/lucasmotta/dploy/blob/b0177c2fdc3c85088d684193e725b2297eecc241/src/sftp.coffee | 55 | 104 |
lucasmotta/dploy:src/sftp.coffee:3:raw_corpus | raw_corpus | return callback.apply(this, [error]) if error
@_rdelete paths, callback
###
@private
Delete directories recursively
###
_rdelete: (paths, callback) ->
path = paths.shift()
@connection.opendir path, (error, handle) => # Open the directory
return callback.apply(this, [error]) if error
@connection.read... | CoffeeScript | lucasmotta/dploy | src/sftp.coffee | MIT | b0177c2fdc3c85088d684193e725b2297eecc241 | 973 | https://github.com/lucasmotta/dploy/blob/b0177c2fdc3c85088d684193e725b2297eecc241/src/sftp.coffee | 105 | 154 | ||
lucasmotta/dploy:src/sftp.coffee:3:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
return callback.apply(this, [error]) if error
@_rdelete paths, callback
###
@private
Delete directories recursively
###
_rdelete: (paths, callback) ->
path = paths.shift()
@connection.opendir path, (error, handle) => # Open the directory
return ca... | return callback.apply(this, [error])(error ? this._rdelete(paths, callback) : void 0);
({
/*
@private
Delete directories recursively
*/
_rdelete: function(paths, callback) {
var path;
path = paths.shift();
return this.connection.opendir(path, (error, handle) => { // Open the directory
if (e... | CoffeeScript | JavaScript | lucasmotta/dploy | src/sftp.coffee | MIT | b0177c2fdc3c85088d684193e725b2297eecc241 | 973 | https://github.com/lucasmotta/dploy/blob/b0177c2fdc3c85088d684193e725b2297eecc241/src/sftp.coffee | 105 | 154 |
lucasmotta/dploy:src/sftp.coffee:3:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
return callback.apply(this, [error])(error ? this._rdelete(paths, callback) : void 0);
({
/*
@private
Delete directories recursively
*/
_rdelete: function(paths, callback) {
var path;
path = paths.shift();
return this.connection.opendir(path,... | return callback.apply(this, [error]) if error
@_rdelete paths, callback
###
@private
Delete directories recursively
###
_rdelete: (paths, callback) ->
path = paths.shift()
@connection.opendir path, (error, handle) => # Open the directory
return callback.apply(this, [error]) if error
@connection.read... | JavaScript | CoffeeScript | lucasmotta/dploy | src/sftp.coffee | MIT | b0177c2fdc3c85088d684193e725b2297eecc241 | 973 | https://github.com/lucasmotta/dploy/blob/b0177c2fdc3c85088d684193e725b2297eecc241/src/sftp.coffee | 105 | 154 |
lucasmotta/dploy:src/sftp.coffee:3:completion | completion | return callback.apply(this, [error]) if error
@_rdelete paths, callback
###
@private
Delete directories recursively
###
_rdelete: (paths, callback) ->
path = paths.shift()
@connection.opendir path, (error, handle) => # Open the directory
return callback.apply(this, [error]) if error
@connection.read... | @param path: <string> The path of the directory you want to create
@param callback: <function> Callback method
###
mkdir: (path, callback) ->
i = path.length
paths = []
while i > 0
content = path.slice 0, i
paths.push content
i = content.lastIndexOf "/"
@_rmkdir paths, callback
###
@private
Cre... | CoffeeScript | CoffeeScript | lucasmotta/dploy | src/sftp.coffee | MIT | b0177c2fdc3c85088d684193e725b2297eecc241 | 973 | https://github.com/lucasmotta/dploy/blob/b0177c2fdc3c85088d684193e725b2297eecc241/src/sftp.coffee | 105 | 154 |
lucasmotta/dploy:src/sftp.coffee:2:raw_corpus | raw_corpus | ###
Dispose
###
dispose: ->
if @connected
@connected.dispose()
@connected = null
if @failed
@failed.dispose()
@failed = null
if @closed
@closed.dispose()
@closed = null
###
Retrieve a file on the server
@param path: <string> The path of your file
@param callback: <function> Callback m... | CoffeeScript | lucasmotta/dploy | src/sftp.coffee | MIT | ec1cb1add9a56e93484ec890b7e0deea9844cd8b | 973 | https://github.com/lucasmotta/dploy/blob/ec1cb1add9a56e93484ec890b7e0deea9844cd8b/src/sftp.coffee | 55 | 104 | ||
lucasmotta/dploy:src/sftp.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
###
Dispose
###
dispose: ->
if @connected
@connected.dispose()
@connected = null
if @failed
@failed.dispose()
@failed = null
if @closed
@closed.dispose()
@closed = null
###
Retrieve a file on the server
@param path: <string> The ... | /*
Dispose
*/
({
dispose: function() {
if (this.connected) {
this.connected.dispose();
this.connected = null;
}
if (this.failed) {
this.failed.dispose();
this.failed = null;
}
if (this.closed) {
this.closed.dispose();
return this.closed = null;
}
},
/*
... | CoffeeScript | JavaScript | lucasmotta/dploy | src/sftp.coffee | MIT | ec1cb1add9a56e93484ec890b7e0deea9844cd8b | 973 | https://github.com/lucasmotta/dploy/blob/ec1cb1add9a56e93484ec890b7e0deea9844cd8b/src/sftp.coffee | 55 | 104 |
lucasmotta/dploy:src/sftp.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
/*
Dispose
*/
({
dispose: function() {
if (this.connected) {
this.connected.dispose();
this.connected = null;
}
if (this.failed) {
this.failed.dispose();
this.failed = null;
}
if (this.closed) {
this.closed.dispos... | ###
Dispose
###
dispose: ->
if @connected
@connected.dispose()
@connected = null
if @failed
@failed.dispose()
@failed = null
if @closed
@closed.dispose()
@closed = null
###
Retrieve a file on the server
@param path: <string> The path of your file
@param callback: <function> Callback m... | JavaScript | CoffeeScript | lucasmotta/dploy | src/sftp.coffee | MIT | ec1cb1add9a56e93484ec890b7e0deea9844cd8b | 973 | https://github.com/lucasmotta/dploy/blob/ec1cb1add9a56e93484ec890b7e0deea9844cd8b/src/sftp.coffee | 55 | 104 |
lucasmotta/dploy:src/sftp.coffee:2:completion | completion | ###
Dispose
###
dispose: ->
if @connected
@connected.dispose()
@connected = null
if @failed
@failed.dispose()
@failed = null
if @closed
@closed.dispose()
@closed = null
###
Retrieve a file on the server
@param path: <string> The path of your file
@param callback: <function> Callback m... | ###
Upload a file to the server
@param local_path: <string> The local path of your file
@param remote_path: <string> The remote path where you want your file to be uploaded at
@param callback: <function> Callback method
###
upload: (local_path, remote_path, callback) ->
@connection.fastPut local_path, remote_p... | CoffeeScript | CoffeeScript | lucasmotta/dploy | src/sftp.coffee | MIT | ec1cb1add9a56e93484ec890b7e0deea9844cd8b | 973 | https://github.com/lucasmotta/dploy/blob/ec1cb1add9a56e93484ec890b7e0deea9844cd8b/src/sftp.coffee | 55 | 104 |
lucasmotta/dploy:src/sftp.coffee:3:raw_corpus | raw_corpus | _rdelete: (remote_path, callback) ->
###
Create a directory
@param path: <string> The path of the directory you want to create
@param callback: <function> Callback method
###
mkdir: (path, callback) ->
i = path.length
paths = []
while i > 0
content = path.slice 0, i
paths.push content
i = conten... | CoffeeScript | lucasmotta/dploy | src/sftp.coffee | MIT | ec1cb1add9a56e93484ec890b7e0deea9844cd8b | 973 | https://github.com/lucasmotta/dploy/blob/ec1cb1add9a56e93484ec890b7e0deea9844cd8b/src/sftp.coffee | 105 | 137 | ||
lucasmotta/dploy:src/sftp.coffee:3:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
_rdelete: (remote_path, callback) ->
###
Create a directory
@param path: <string> The path of the directory you want to create
@param callback: <function> Callback method
###
mkdir: (path, callback) ->
i = path.length
paths = []
while i > 0
cont... | ({
_rdelete: function(remote_path, callback) {
return {
/*
Create a directory
@param path: <string> The path of the directory you want to create
@param callback: <function> Callback method
*/
mkdir: function(path, callback) {
var content, i, paths;
i = path.len... | CoffeeScript | JavaScript | lucasmotta/dploy | src/sftp.coffee | MIT | ec1cb1add9a56e93484ec890b7e0deea9844cd8b | 973 | https://github.com/lucasmotta/dploy/blob/ec1cb1add9a56e93484ec890b7e0deea9844cd8b/src/sftp.coffee | 105 | 137 |
lucasmotta/dploy:src/sftp.coffee:3:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
({
_rdelete: function(remote_path, callback) {
return {
/*
Create a directory
@param path: <string> The path of the directory you want to create
@param callback: <function> Callback method
*/
mkdir: function(path, callback... | _rdelete: (remote_path, callback) ->
###
Create a directory
@param path: <string> The path of the directory you want to create
@param callback: <function> Callback method
###
mkdir: (path, callback) ->
i = path.length
paths = []
while i > 0
content = path.slice 0, i
paths.push content
i = conten... | JavaScript | CoffeeScript | lucasmotta/dploy | src/sftp.coffee | MIT | ec1cb1add9a56e93484ec890b7e0deea9844cd8b | 973 | https://github.com/lucasmotta/dploy/blob/ec1cb1add9a56e93484ec890b7e0deea9844cd8b/src/sftp.coffee | 105 | 137 |
lucasmotta/dploy:src/sftp.coffee:3:completion | completion | _rdelete: (remote_path, callback) ->
###
Create a directory
@param path: <string> The path of the directory you want to create
@param callback: <function> Callback method
###
mkdir: (path, callback) ->
i = path.length
paths = []
while i > 0
content = path.slice 0, i
paths.push content
i = conten... | @_rmkdir paths, callback
###
@private
Create directories recursively
###
_rmkdir: (paths, callback) ->
path = paths.pop()
@connection.opendir path, (error, handle) =>
if error
@connection.mkdir path, (error) =>
return callback.apply(this, [error]) if error or paths.length == 0
@_rmkdir paths,... | CoffeeScript | CoffeeScript | lucasmotta/dploy | src/sftp.coffee | MIT | ec1cb1add9a56e93484ec890b7e0deea9844cd8b | 973 | https://github.com/lucasmotta/dploy/blob/ec1cb1add9a56e93484ec890b7e0deea9844cd8b/src/sftp.coffee | 105 | 137 |
lucasmotta/dploy:src/sftp.coffee:2:raw_corpus | raw_corpus | ###
Dispose
###
dispose: ->
if @connected
@connected.dispose()
@connected = null
if @failed
@failed.dispose()
@failed = null
if @closed
@closed.dispose()
@closed = null
###
Retrieve a file on the server
@param path: <string> The path of your file
@param callback: <function> Callback m... | CoffeeScript | lucasmotta/dploy | src/sftp.coffee | MIT | b794e7f006fc8a7a037edcbb51a1ca0d4a7a8588 | 973 | https://github.com/lucasmotta/dploy/blob/b794e7f006fc8a7a037edcbb51a1ca0d4a7a8588/src/sftp.coffee | 55 | 104 | ||
lucasmotta/dploy:src/sftp.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
###
Dispose
###
dispose: ->
if @connected
@connected.dispose()
@connected = null
if @failed
@failed.dispose()
@failed = null
if @closed
@closed.dispose()
@closed = null
###
Retrieve a file on the server
@param path: <string> The ... | /*
Dispose
*/
({
dispose: function() {
if (this.connected) {
this.connected.dispose();
this.connected = null;
}
if (this.failed) {
this.failed.dispose();
this.failed = null;
}
if (this.closed) {
this.closed.dispose();
return this.closed = null;
}
},
/*
... | CoffeeScript | JavaScript | lucasmotta/dploy | src/sftp.coffee | MIT | b794e7f006fc8a7a037edcbb51a1ca0d4a7a8588 | 973 | https://github.com/lucasmotta/dploy/blob/b794e7f006fc8a7a037edcbb51a1ca0d4a7a8588/src/sftp.coffee | 55 | 104 |
lucasmotta/dploy:src/sftp.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
/*
Dispose
*/
({
dispose: function() {
if (this.connected) {
this.connected.dispose();
this.connected = null;
}
if (this.failed) {
this.failed.dispose();
this.failed = null;
}
if (this.closed) {
this.closed.dispos... | ###
Dispose
###
dispose: ->
if @connected
@connected.dispose()
@connected = null
if @failed
@failed.dispose()
@failed = null
if @closed
@closed.dispose()
@closed = null
###
Retrieve a file on the server
@param path: <string> The path of your file
@param callback: <function> Callback m... | JavaScript | CoffeeScript | lucasmotta/dploy | src/sftp.coffee | MIT | b794e7f006fc8a7a037edcbb51a1ca0d4a7a8588 | 973 | https://github.com/lucasmotta/dploy/blob/b794e7f006fc8a7a037edcbb51a1ca0d4a7a8588/src/sftp.coffee | 55 | 104 |
lucasmotta/dploy:src/sftp.coffee:2:completion | completion | ###
Dispose
###
dispose: ->
if @connected
@connected.dispose()
@connected = null
if @failed
@failed.dispose()
@failed = null
if @closed
@closed.dispose()
@closed = null
###
Retrieve a file on the server
@param path: <string> The path of your file
@param callback: <function> Callback m... | ###
Upload a file to the server
@param local_path: <string> The local path of your file
@param remote_path: <string> The remote path where you want your file to be uploaded at
@param callback: <function> Callback method
###
upload: (local_path, remote_path, callback) ->
@connection.fastPut local_path, remote_p... | CoffeeScript | CoffeeScript | lucasmotta/dploy | src/sftp.coffee | MIT | b794e7f006fc8a7a037edcbb51a1ca0d4a7a8588 | 973 | https://github.com/lucasmotta/dploy/blob/b794e7f006fc8a7a037edcbb51a1ca0d4a7a8588/src/sftp.coffee | 55 | 104 |
lucasmotta/dploy:src/sftp.coffee:3:raw_corpus | raw_corpus | mkdir: (path, callback) ->
i = path.length
paths = []
while i > 0
content = path.slice 0, i
paths.push content
i = content.lastIndexOf "/"
@_rmkdir paths, callback
###
@private
Create directories recursively
###
_rmkdir: (paths, callback) ->
path = paths.pop()
@connection.opendir path, (erro... | CoffeeScript | lucasmotta/dploy | src/sftp.coffee | MIT | b794e7f006fc8a7a037edcbb51a1ca0d4a7a8588 | 973 | https://github.com/lucasmotta/dploy/blob/b794e7f006fc8a7a037edcbb51a1ca0d4a7a8588/src/sftp.coffee | 105 | 128 | ||
lucasmotta/dploy:src/sftp.coffee:3:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
mkdir: (path, callback) ->
i = path.length
paths = []
while i > 0
content = path.slice 0, i
paths.push content
i = content.lastIndexOf "/"
@_rmkdir paths, callback
###
@private
Create directories recursively
###
_rmkdir: (paths, callback) ... | ({
mkdir: function(path, callback) {
var content, i, paths;
i = path.length;
paths = [];
while (i > 0) {
content = path.slice(0, i);
paths.push(content);
i = content.lastIndexOf("/");
}
return this._rmkdir(paths, callback);
},
/*
@private
Create directories recursivel... | CoffeeScript | JavaScript | lucasmotta/dploy | src/sftp.coffee | MIT | b794e7f006fc8a7a037edcbb51a1ca0d4a7a8588 | 973 | https://github.com/lucasmotta/dploy/blob/b794e7f006fc8a7a037edcbb51a1ca0d4a7a8588/src/sftp.coffee | 105 | 128 |
lucasmotta/dploy:src/sftp.coffee:3:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
({
mkdir: function(path, callback) {
var content, i, paths;
i = path.length;
paths = [];
while (i > 0) {
content = path.slice(0, i);
paths.push(content);
i = content.lastIndexOf("/");
}
return this._rmkdir(paths, callback... | mkdir: (path, callback) ->
i = path.length
paths = []
while i > 0
content = path.slice 0, i
paths.push content
i = content.lastIndexOf "/"
@_rmkdir paths, callback
###
@private
Create directories recursively
###
_rmkdir: (paths, callback) ->
path = paths.pop()
@connection.opendir path, (erro... | JavaScript | CoffeeScript | lucasmotta/dploy | src/sftp.coffee | MIT | b794e7f006fc8a7a037edcbb51a1ca0d4a7a8588 | 973 | https://github.com/lucasmotta/dploy/blob/b794e7f006fc8a7a037edcbb51a1ca0d4a7a8588/src/sftp.coffee | 105 | 128 |
lucasmotta/dploy:src/sftp.coffee:3:completion | completion | mkdir: (path, callback) ->
i = path.length
paths = []
while i > 0
content = path.slice 0, i
paths.push content
i = content.lastIndexOf "/"
@_rmkdir paths, callback
###
@private | Create directories recursively
###
_rmkdir: (paths, callback) ->
path = paths.pop()
@connection.opendir path, (error, handle) =>
if error
@connection.mkdir path, (error) =>
return callback.apply(this, [error]) if error or paths.length == 0
@_rmkdir paths, callback
else
return callback.appl... | CoffeeScript | CoffeeScript | lucasmotta/dploy | src/sftp.coffee | MIT | b794e7f006fc8a7a037edcbb51a1ca0d4a7a8588 | 973 | https://github.com/lucasmotta/dploy/blob/b794e7f006fc8a7a037edcbb51a1ca0d4a7a8588/src/sftp.coffee | 105 | 128 |
lucasmotta/dploy:src/sftp.coffee:2:raw_corpus | raw_corpus | ###
Dispose
###
dispose: ->
if @connected
@connected.dispose()
@connected = null
if @failed
@failed.dispose()
@failed = null
if @closed
@closed.dispose()
@closed = null
###
Retrieve a file on the server
@param path: <string> The path of your file
@param callback: <function> Callback m... | CoffeeScript | lucasmotta/dploy | src/sftp.coffee | MIT | e7e9d254024e64aeb95cc3a3c655c40b91294270 | 973 | https://github.com/lucasmotta/dploy/blob/e7e9d254024e64aeb95cc3a3c655c40b91294270/src/sftp.coffee | 55 | 104 | ||
lucasmotta/dploy:src/sftp.coffee:2:completion | completion | ###
Dispose
###
dispose: ->
if @connected
@connected.dispose()
@connected = null
if @failed
@failed.dispose()
@failed = null
if @closed
@closed.dispose()
@closed = null
###
Retrieve a file on the server
@param path: <string> The path of your file
@param callback: <function> Callback m... | ###
Upload a file to the server
@param local_path: <string> The local path of your file
@param remote_path: <string> The remote path where you want your file to be uploaded at
@param callback: <function> Callback method
###
upload: (local_path, remote_path, callback) ->
@connection.fastPut local_path, remote_p... | CoffeeScript | CoffeeScript | lucasmotta/dploy | src/sftp.coffee | MIT | e7e9d254024e64aeb95cc3a3c655c40b91294270 | 973 | https://github.com/lucasmotta/dploy/blob/e7e9d254024e64aeb95cc3a3c655c40b91294270/src/sftp.coffee | 55 | 104 |
lucasmotta/dploy:src/sftp.coffee:3:raw_corpus | raw_corpus | ###
mkdir: (path, callback) ->
@connection.mkdir path, callback | CoffeeScript | lucasmotta/dploy | src/sftp.coffee | MIT | e7e9d254024e64aeb95cc3a3c655c40b91294270 | 973 | https://github.com/lucasmotta/dploy/blob/e7e9d254024e64aeb95cc3a3c655c40b91294270/src/sftp.coffee | 105 | 107 | ||
lucasmotta/dploy:src/sftp.coffee:1:raw_corpus | raw_corpus | module.exports = class SFTP
sftp : null
connection : null
connected : null
failed : null
closed : null
closing : null
constructor: ->
@connected = new Signal()
@failed = new Signal()
@closed = new Signal()
@closing = false
# Create a new instance of the FTP
@connection = new ssh2()
@con... | CoffeeScript | lucasmotta/dploy | src/sftp.coffee | MIT | 1ccd503ddca9d7586e7fc498366aa518e2b32cb3 | 973 | https://github.com/lucasmotta/dploy/blob/1ccd503ddca9d7586e7fc498366aa518e2b32cb3/src/sftp.coffee | 5 | 54 | ||
lucasmotta/dploy:src/sftp.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
module.exports = class SFTP
sftp : null
connection : null
connected : null
failed : null
closed : null
closing : null
constructor: ->
@connected = new Signal()
@failed = new Signal()
@closed = new Signal()
@closing = false
# Create a ... | var SFTP;
module.exports = SFTP = (function() {
class SFTP {
constructor() {
this.connected = new Signal();
this.failed = new Signal();
this.closed = new Signal();
this.closing = false;
// Create a new instance of the FTP
this.connection = new ssh2();
this.connection.on(... | CoffeeScript | JavaScript | lucasmotta/dploy | src/sftp.coffee | MIT | 1ccd503ddca9d7586e7fc498366aa518e2b32cb3 | 973 | https://github.com/lucasmotta/dploy/blob/1ccd503ddca9d7586e7fc498366aa518e2b32cb3/src/sftp.coffee | 5 | 54 |
lucasmotta/dploy:src/sftp.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var SFTP;
module.exports = SFTP = (function() {
class SFTP {
constructor() {
this.connected = new Signal();
this.failed = new Signal();
this.closed = new Signal();
this.closing = false;
// Create a new instance of the FTP
... | module.exports = class SFTP
sftp : null
connection : null
connected : null
failed : null
closed : null
closing : null
constructor: ->
@connected = new Signal()
@failed = new Signal()
@closed = new Signal()
@closing = false
# Create a new instance of the FTP
@connection = new ssh2()
@con... | JavaScript | CoffeeScript | lucasmotta/dploy | src/sftp.coffee | MIT | 1ccd503ddca9d7586e7fc498366aa518e2b32cb3 | 973 | https://github.com/lucasmotta/dploy/blob/1ccd503ddca9d7586e7fc498366aa518e2b32cb3/src/sftp.coffee | 5 | 54 |
lucasmotta/dploy:src/sftp.coffee:1:completion | completion | module.exports = class SFTP
sftp : null
connection : null
connected : null
failed : null
closed : null
closing : null
constructor: ->
@connected = new Signal()
@failed = new Signal()
@closed = new Signal()
@closing = false
# Create a new instance of the FTP
@connection = new ssh2()
@con... | @sftp = sftp
@connected.dispatch()
###
Connect to the FTP
@param config <object> Configuration file for your connection
###
connect: (config) ->
@connection.connect
host : config.host
port : config.port
username : config.user
password : config.pass
###
Close the connection
###
close: (ca... | CoffeeScript | CoffeeScript | lucasmotta/dploy | src/sftp.coffee | MIT | 1ccd503ddca9d7586e7fc498366aa518e2b32cb3 | 973 | https://github.com/lucasmotta/dploy/blob/1ccd503ddca9d7586e7fc498366aa518e2b32cb3/src/sftp.coffee | 5 | 54 |
lucasmotta/dploy:src/sftp.coffee:2:raw_corpus | raw_corpus | ###
Dispose
###
dispose: ->
if @connected
@connected.dispose()
@connected = null
if @failed
@failed.dispose()
@failed = null
if @closed
@closed.dispose()
@closed = null
###
Retrieve a file on the server
@param path: <string> The path of your file
@param callback: <function> Callback m... | CoffeeScript | lucasmotta/dploy | src/sftp.coffee | MIT | 1ccd503ddca9d7586e7fc498366aa518e2b32cb3 | 973 | https://github.com/lucasmotta/dploy/blob/1ccd503ddca9d7586e7fc498366aa518e2b32cb3/src/sftp.coffee | 55 | 104 | ||
lucasmotta/dploy:src/sftp.coffee:2:completion | completion | ###
Dispose
###
dispose: ->
if @connected
@connected.dispose()
@connected = null
if @failed
@failed.dispose()
@failed = null
if @closed
@closed.dispose()
@closed = null
###
Retrieve a file on the server
@param path: <string> The path of your file
@param callback: <function> Callback m... | @sftp.readFile path, "utf-8", (error, data) =>
console.log error, data.toString()
###
Upload a file to the server
@param local_path: <string> The local path of your file
@param remote_path: <string> The remote path where you want your file to be uploaded at
@param callback: <function> Callback method
###
up... | CoffeeScript | CoffeeScript | lucasmotta/dploy | src/sftp.coffee | MIT | 1ccd503ddca9d7586e7fc498366aa518e2b32cb3 | 973 | https://github.com/lucasmotta/dploy/blob/1ccd503ddca9d7586e7fc498366aa518e2b32cb3/src/sftp.coffee | 55 | 104 |
lucasmotta/dploy:src/sftp.coffee:3:raw_corpus | raw_corpus | @param path: <string> The path of the directory you want to create
@param callback: <function> Callback method
###
mkdir: (path, callback) ->
@connection.mkdir path, true, callback | CoffeeScript | lucasmotta/dploy | src/sftp.coffee | MIT | 1ccd503ddca9d7586e7fc498366aa518e2b32cb3 | 973 | https://github.com/lucasmotta/dploy/blob/1ccd503ddca9d7586e7fc498366aa518e2b32cb3/src/sftp.coffee | 105 | 109 | ||
lucasmotta/dploy:src/sftp.coffee:3:completion | completion | @param path: <string> The path of the directory you want to create
@param callback: <function> Callback method | ###
mkdir: (path, callback) ->
@connection.mkdir path, true, callback | CoffeeScript | CoffeeScript | lucasmotta/dploy | src/sftp.coffee | MIT | 1ccd503ddca9d7586e7fc498366aa518e2b32cb3 | 973 | https://github.com/lucasmotta/dploy/blob/1ccd503ddca9d7586e7fc498366aa518e2b32cb3/src/sftp.coffee | 105 | 109 |
kahmali/meteor-restivus:lib/route.coffee:1:raw_corpus | raw_corpus | @Route = (@api, @path, @options, @endpoints) ->
# Check if options were provided
if not @endpoints
@endpoints = @options
@options = null | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | ae22fc9e39b32a838a45899795f15fbf6743e6ad | 541 | https://github.com/kahmali/meteor-restivus/blob/ae22fc9e39b32a838a45899795f15fbf6743e6ad/lib/route.coffee | 1 | 5 | ||
kahmali/meteor-restivus:lib/route.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
@Route = (@api, @path, @options, @endpoints) ->
# Check if options were provided
if not @endpoints
@endpoints = @options
@options = null
``` | this.Route = function(api, path, options, endpoints) {
this.api = api;
this.path = path;
this.options = options;
this.endpoints = endpoints;
// Check if options were provided
if (!this.endpoints) {
this.endpoints = this.options;
return this.options = null;
}
}; | CoffeeScript | JavaScript | kahmali/meteor-restivus | lib/route.coffee | MIT | ae22fc9e39b32a838a45899795f15fbf6743e6ad | 541 | https://github.com/kahmali/meteor-restivus/blob/ae22fc9e39b32a838a45899795f15fbf6743e6ad/lib/route.coffee | 1 | 5 |
kahmali/meteor-restivus:lib/route.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
this.Route = function(api, path, options, endpoints) {
this.api = api;
this.path = path;
this.options = options;
this.endpoints = endpoints;
// Check if options were provided
if (!this.endpoints) {
this.endpoints = this.options;
return this.opti... | @Route = (@api, @path, @options, @endpoints) ->
# Check if options were provided
if not @endpoints
@endpoints = @options
@options = null | JavaScript | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | ae22fc9e39b32a838a45899795f15fbf6743e6ad | 541 | https://github.com/kahmali/meteor-restivus/blob/ae22fc9e39b32a838a45899795f15fbf6743e6ad/lib/route.coffee | 1 | 5 |
kahmali/meteor-restivus:lib/route.coffee:1:completion | completion | @Route = (@api, @path, @options, @endpoints) ->
# Check if options were provided | if not @endpoints
@endpoints = @options
@options = null | CoffeeScript | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | ae22fc9e39b32a838a45899795f15fbf6743e6ad | 541 | https://github.com/kahmali/meteor-restivus/blob/ae22fc9e39b32a838a45899795f15fbf6743e6ad/lib/route.coffee | 1 | 5 |
kahmali/meteor-restivus:lib/route.coffee:2:raw_corpus | raw_corpus | @Route.prototype.addToApi = ->
self = this
# Throw an error if a route has already been added at this path
# TODO: Check for collisions with paths that follow same pattern with different parameter names
if _.contains @api.config.paths, @path
throw new Error "Cannot add a route at an existing path: #{@path}... | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | ae22fc9e39b32a838a45899795f15fbf6743e6ad | 541 | https://github.com/kahmali/meteor-restivus/blob/ae22fc9e39b32a838a45899795f15fbf6743e6ad/lib/route.coffee | 7 | 56 | ||
kahmali/meteor-restivus:lib/route.coffee:2:completion | completion | @Route.prototype.addToApi = ->
self = this
# Throw an error if a route has already been added at this path
# TODO: Check for collisions with paths that follow same pattern with different parameter names
if _.contains @api.config.paths, @path
throw new Error "Cannot add a route at an existing path: #{@path}... | else if method is 'POST' and self.endpoints.post
responseData = callEndpoint.call(this, self, self.endpoints.post)
else if method is 'PUT' and self.endpoints.put
responseData = callEndpoint.call(this, self, self.endpoints.put)
else if method is 'PATCH' and self.endpoints.patch
respon... | CoffeeScript | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | ae22fc9e39b32a838a45899795f15fbf6743e6ad | 541 | https://github.com/kahmali/meteor-restivus/blob/ae22fc9e39b32a838a45899795f15fbf6743e6ad/lib/route.coffee | 7 | 56 |
kahmali/meteor-restivus:lib/route.coffee:3:raw_corpus | raw_corpus | @context: IronRouter.Router.route()
@returns The endpoint response or a 401 if authentication fails
### | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | ae22fc9e39b32a838a45899795f15fbf6743e6ad | 541 | https://github.com/kahmali/meteor-restivus/blob/ae22fc9e39b32a838a45899795f15fbf6743e6ad/lib/route.coffee | 57 | 60 | ||
kahmali/meteor-restivus:lib/route.coffee:4:raw_corpus | raw_corpus | callEndpoint = (route, endpoint) ->
endpoint = resolveEndpoint endpoint
# Call the endpoint if authentication doesn't fail
if authAccepted.call this, route, endpoint
endpoint.action.call this
else
statusCode: 401
body: {success: false, message: "You must be logged in to do this."}
###
Convert t... | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | ae22fc9e39b32a838a45899795f15fbf6743e6ad | 541 | https://github.com/kahmali/meteor-restivus/blob/ae22fc9e39b32a838a45899795f15fbf6743e6ad/lib/route.coffee | 61 | 74 | ||
kahmali/meteor-restivus:lib/route.coffee:4:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
callEndpoint = (route, endpoint) ->
endpoint = resolveEndpoint endpoint
# Call the endpoint if authentication doesn't fail
if authAccepted.call this, route, endpoint
endpoint.action.call this
else
statusCode: 401
body: {success: false, messag... | var callEndpoint;
callEndpoint = function(route, endpoint) {
endpoint = resolveEndpoint(endpoint);
// Call the endpoint if authentication doesn't fail
if (authAccepted.call(this, route, endpoint)) {
return endpoint.action.call(this);
} else {
return {
statusCode: 401,
body: {
succes... | CoffeeScript | JavaScript | kahmali/meteor-restivus | lib/route.coffee | MIT | ae22fc9e39b32a838a45899795f15fbf6743e6ad | 541 | https://github.com/kahmali/meteor-restivus/blob/ae22fc9e39b32a838a45899795f15fbf6743e6ad/lib/route.coffee | 61 | 74 |
kahmali/meteor-restivus:lib/route.coffee:4:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var callEndpoint;
callEndpoint = function(route, endpoint) {
endpoint = resolveEndpoint(endpoint);
// Call the endpoint if authentication doesn't fail
if (authAccepted.call(this, route, endpoint)) {
return endpoint.action.call(this);
} else {
retur... | callEndpoint = (route, endpoint) ->
endpoint = resolveEndpoint endpoint
# Call the endpoint if authentication doesn't fail
if authAccepted.call this, route, endpoint
endpoint.action.call this
else
statusCode: 401
body: {success: false, message: "You must be logged in to do this."}
###
Convert t... | JavaScript | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | ae22fc9e39b32a838a45899795f15fbf6743e6ad | 541 | https://github.com/kahmali/meteor-restivus/blob/ae22fc9e39b32a838a45899795f15fbf6743e6ad/lib/route.coffee | 61 | 74 |
kahmali/meteor-restivus:lib/route.coffee:4:completion | completion | callEndpoint = (route, endpoint) ->
endpoint = resolveEndpoint endpoint
# Call the endpoint if authentication doesn't fail
if authAccepted.call this, route, endpoint
endpoint.action.call this
else | statusCode: 401
body: {success: false, message: "You must be logged in to do this."}
###
Convert the given endpoint into our expected endpoint object if it is a bare function
### | CoffeeScript | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | ae22fc9e39b32a838a45899795f15fbf6743e6ad | 541 | https://github.com/kahmali/meteor-restivus/blob/ae22fc9e39b32a838a45899795f15fbf6743e6ad/lib/route.coffee | 61 | 74 |
kahmali/meteor-restivus:lib/route.coffee:5:raw_corpus | raw_corpus | resolveEndpoint = (endpoint) ->
if _.isFunction(endpoint)
endpoint = {action: endpoint}
endpoint
###
Authenticate the given endpoint if required
Once it's globally configured in the API, authentication can be required on an entire route or individual
endpoints. If required on an entire endpoint, that se... | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | ae22fc9e39b32a838a45899795f15fbf6743e6ad | 541 | https://github.com/kahmali/meteor-restivus/blob/ae22fc9e39b32a838a45899795f15fbf6743e6ad/lib/route.coffee | 75 | 89 | ||
kahmali/meteor-restivus:lib/route.coffee:5:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
resolveEndpoint = (endpoint) ->
if _.isFunction(endpoint)
endpoint = {action: endpoint}
endpoint
###
Authenticate the given endpoint if required
Once it's globally configured in the API, authentication can be required on an entire route or individua... | var resolveEndpoint;
resolveEndpoint = function(endpoint) {
if (_.isFunction(endpoint)) {
endpoint = {
action: endpoint
};
}
return endpoint;
};
/*
Authenticate the given endpoint if required
Once it's globally configured in the API, authentication can be required on an entire route or indivi... | CoffeeScript | JavaScript | kahmali/meteor-restivus | lib/route.coffee | MIT | ae22fc9e39b32a838a45899795f15fbf6743e6ad | 541 | https://github.com/kahmali/meteor-restivus/blob/ae22fc9e39b32a838a45899795f15fbf6743e6ad/lib/route.coffee | 75 | 89 |
kahmali/meteor-restivus:lib/route.coffee:5:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var resolveEndpoint;
resolveEndpoint = function(endpoint) {
if (_.isFunction(endpoint)) {
endpoint = {
action: endpoint
};
}
return endpoint;
};
/*
Authenticate the given endpoint if required
Once it's globally configured in the API, auth... | resolveEndpoint = (endpoint) ->
if _.isFunction(endpoint)
endpoint = {action: endpoint}
endpoint
###
Authenticate the given endpoint if required
Once it's globally configured in the API, authentication can be required on an entire route or individual
endpoints. If required on an entire endpoint, that se... | JavaScript | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | ae22fc9e39b32a838a45899795f15fbf6743e6ad | 541 | https://github.com/kahmali/meteor-restivus/blob/ae22fc9e39b32a838a45899795f15fbf6743e6ad/lib/route.coffee | 75 | 89 |
kahmali/meteor-restivus:lib/route.coffee:5:completion | completion | resolveEndpoint = (endpoint) ->
if _.isFunction(endpoint)
endpoint = {action: endpoint}
endpoint
###
Authenticate the given endpoint if required | Once it's globally configured in the API, authentication can be required on an entire route or individual
endpoints. If required on an entire endpoint, that serves as the default. If required in any individual endpoints, that
will override the default.
@context: IronRouter.Router.route()
@returns False if auth... | CoffeeScript | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | ae22fc9e39b32a838a45899795f15fbf6743e6ad | 541 | https://github.com/kahmali/meteor-restivus/blob/ae22fc9e39b32a838a45899795f15fbf6743e6ad/lib/route.coffee | 75 | 89 |
kahmali/meteor-restivus:lib/route.coffee:6:raw_corpus | raw_corpus | authAccepted = (route, endpoint) ->
accept = true
if route.api.config.useAuth
if endpoint.authRequired is undefined
accept = authenticate.call(this, route) if route.options?.authRequired
else if endpoint.authRequired
accept = authenticate.call this, route
accept
###
Verify the request is b... | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | ae22fc9e39b32a838a45899795f15fbf6743e6ad | 541 | https://github.com/kahmali/meteor-restivus/blob/ae22fc9e39b32a838a45899795f15fbf6743e6ad/lib/route.coffee | 90 | 107 | ||
kahmali/meteor-restivus:lib/route.coffee:6:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
authAccepted = (route, endpoint) ->
accept = true
if route.api.config.useAuth
if endpoint.authRequired is undefined
accept = authenticate.call(this, route) if route.options?.authRequired
else if endpoint.authRequired
accept = authenticate.... | var authAccepted;
authAccepted = function(route, endpoint) {
var accept, ref;
accept = true;
if (route.api.config.useAuth) {
if (endpoint.authRequired === void 0) {
if ((ref = route.options) != null ? ref.authRequired : void 0) {
accept = authenticate.call(this, route);
}
} else if (e... | CoffeeScript | JavaScript | kahmali/meteor-restivus | lib/route.coffee | MIT | ae22fc9e39b32a838a45899795f15fbf6743e6ad | 541 | https://github.com/kahmali/meteor-restivus/blob/ae22fc9e39b32a838a45899795f15fbf6743e6ad/lib/route.coffee | 90 | 107 |
kahmali/meteor-restivus:lib/route.coffee:6:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var authAccepted;
authAccepted = function(route, endpoint) {
var accept, ref;
accept = true;
if (route.api.config.useAuth) {
if (endpoint.authRequired === void 0) {
if ((ref = route.options) != null ? ref.authRequired : void 0) {
accept = a... | authAccepted = (route, endpoint) ->
accept = true
if route.api.config.useAuth
if endpoint.authRequired is undefined
accept = authenticate.call(this, route) if route.options?.authRequired
else if endpoint.authRequired
accept = authenticate.call this, route
accept
###
Verify the request is b... | JavaScript | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | ae22fc9e39b32a838a45899795f15fbf6743e6ad | 541 | https://github.com/kahmali/meteor-restivus/blob/ae22fc9e39b32a838a45899795f15fbf6743e6ad/lib/route.coffee | 90 | 107 |
kahmali/meteor-restivus:lib/route.coffee:6:completion | completion | authAccepted = (route, endpoint) ->
accept = true
if route.api.config.useAuth
if endpoint.authRequired is undefined
accept = authenticate.call(this, route) if route.options?.authRequired
else if endpoint.authRequired
accept = authenticate.call this, route
accept | ###
Verify the request is being made by an actively logged in user
If verified, attach the authenticated user to the context.
@context: IronRouter.Router.route()
@returns {Boolean} True if the authentication was successful
### | CoffeeScript | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | ae22fc9e39b32a838a45899795f15fbf6743e6ad | 541 | https://github.com/kahmali/meteor-restivus/blob/ae22fc9e39b32a838a45899795f15fbf6743e6ad/lib/route.coffee | 90 | 107 |
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}
# Attach the user a... | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | ae22fc9e39b32a838a45899795f15fbf6743e6ad | 541 | https://github.com/kahmali/meteor-restivus/blob/ae22fc9e39b32a838a45899795f15fbf6743e6ad/lib/route.coffee | 108 | 129 | ||
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 | ae22fc9e39b32a838a45899795f15fbf6743e6ad | 541 | https://github.com/kahmali/meteor-restivus/blob/ae22fc9e39b32a838a45899795f15fbf6743e6ad/lib/route.coffee | 108 | 129 |
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}
# Attach the user a... | JavaScript | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | ae22fc9e39b32a838a45899795f15fbf6743e6ad | 541 | https://github.com/kahmali/meteor-restivus/blob/ae22fc9e39b32a838a45899795f15fbf6743e6ad/lib/route.coffee | 108 | 129 |
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}
# Attach the user a... | @user = user
@userId = user._id
true
else false
###
Respond to an HTTP request
@context: IronRouter.Router.route()
### | CoffeeScript | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | ae22fc9e39b32a838a45899795f15fbf6743e6ad | 541 | https://github.com/kahmali/meteor-restivus/blob/ae22fc9e39b32a838a45899795f15fbf6743e6ad/lib/route.coffee | 108 | 129 |
kahmali/meteor-restivus:lib/route.coffee:8:raw_corpus | raw_corpus | respond = (route, 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 typ... | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | ae22fc9e39b32a838a45899795f15fbf6743e6ad | 541 | https://github.com/kahmali/meteor-restivus/blob/ae22fc9e39b32a838a45899795f15fbf6743e6ad/lib/route.coffee | 130 | 147 | ||
kahmali/meteor-restivus:lib/route.coffee:8:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
respond = (route, 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)
... | var respond;
respond = function(route, body, statusCode = 200, headers) {
var bodyAsJson;
// 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... | CoffeeScript | JavaScript | kahmali/meteor-restivus | lib/route.coffee | MIT | ae22fc9e39b32a838a45899795f15fbf6743e6ad | 541 | https://github.com/kahmali/meteor-restivus/blob/ae22fc9e39b32a838a45899795f15fbf6743e6ad/lib/route.coffee | 130 | 147 |
kahmali/meteor-restivus:lib/route.coffee:8:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var respond;
respond = function(route, body, statusCode = 200, headers) {
var bodyAsJson;
// 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 ... | respond = (route, 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 typ... | JavaScript | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | ae22fc9e39b32a838a45899795f15fbf6743e6ad | 541 | https://github.com/kahmali/meteor-restivus/blob/ae22fc9e39b32a838a45899795f15fbf6743e6ad/lib/route.coffee | 130 | 147 |
kahmali/meteor-restivus:lib/route.coffee:8:completion | completion | respond = (route, 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 typ... | if route.api.config.prettyJson
bodyAsJson = JSON.stringify body, undefined, 2
else
bodyAsJson = JSON.stringify body
# Send response
@response.writeHead statusCode, headers
@response.write bodyAsJson
@response.end() | CoffeeScript | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | ae22fc9e39b32a838a45899795f15fbf6743e6ad | 541 | https://github.com/kahmali/meteor-restivus/blob/ae22fc9e39b32a838a45899795f15fbf6743e6ad/lib/route.coffee | 130 | 147 |
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}
# Attach the user t... | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | 2a398a200f485f6ec0d350f8f80eb12f7ca77e27 | 541 | https://github.com/kahmali/meteor-restivus/blob/2a398a200f485f6ec0d350f8f80eb12f7ca77e27/lib/route.coffee | 108 | 128 | ||
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 | 2a398a200f485f6ec0d350f8f80eb12f7ca77e27 | 541 | https://github.com/kahmali/meteor-restivus/blob/2a398a200f485f6ec0d350f8f80eb12f7ca77e27/lib/route.coffee | 108 | 128 |
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}
# Attach the user t... | JavaScript | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | 2a398a200f485f6ec0d350f8f80eb12f7ca77e27 | 541 | https://github.com/kahmali/meteor-restivus/blob/2a398a200f485f6ec0d350f8f80eb12f7ca77e27/lib/route.coffee | 108 | 128 |
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}
# Attach the user t... | if user
@user = user
true
else false
###
Respond to an HTTP request
@context: IronRouter.Router.route()
### | CoffeeScript | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | 2a398a200f485f6ec0d350f8f80eb12f7ca77e27 | 541 | https://github.com/kahmali/meteor-restivus/blob/2a398a200f485f6ec0d350f8f80eb12f7ca77e27/lib/route.coffee | 108 | 128 |
kahmali/meteor-restivus:lib/route.coffee:2:raw_corpus | raw_corpus | @Route.prototype.addToApi = ->
self = this
# Throw an error if a route has already been added at this path
# TODO: Check for collisions with paths that follow same pattern with different parameter names
if _.contains @api.config.paths, @path
throw new Error "Cannot add a route at an existing path: #{@path... | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | 1ae43df2883fa1b32b2e483e8012f9267f87d236 | 541 | https://github.com/kahmali/meteor-restivus/blob/1ae43df2883fa1b32b2e483e8012f9267f87d236/lib/route.coffee | 7 | 56 | ||
kahmali/meteor-restivus:lib/route.coffee:2:completion | completion | @Route.prototype.addToApi = ->
self = this
# Throw an error if a route has already been added at this path
# TODO: Check for collisions with paths that follow same pattern with different parameter names
if _.contains @api.config.paths, @path
throw new Error "Cannot add a route at an existing path: #{@path... | else if method is 'POST' and self.endpoints.post
responseData = callEndpoint.call(this, self, self.endpoints.post)
else if method is 'PUT' and self.endpoints.put
responseData = callEndpoint.call(this, self, self.endpoints.put)
else if method is 'PATCH' and self.endpoints.patch
respon... | CoffeeScript | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | 1ae43df2883fa1b32b2e483e8012f9267f87d236 | 541 | https://github.com/kahmali/meteor-restivus/blob/1ae43df2883fa1b32b2e483e8012f9267f87d236/lib/route.coffee | 7 | 56 |
kahmali/meteor-restivus:lib/route.coffee:4:raw_corpus | raw_corpus | callEndpoint = (route, endpoint) ->
endpoint = resolveEndpoint endpoint
authenticateIfRequired.call this, route, endpoint
endpoint.action.call this
###
Convert the given endpoint into our expected endpoint object if it is a bare function
### | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | 1ae43df2883fa1b32b2e483e8012f9267f87d236 | 541 | https://github.com/kahmali/meteor-restivus/blob/1ae43df2883fa1b32b2e483e8012f9267f87d236/lib/route.coffee | 60 | 67 | ||
kahmali/meteor-restivus:lib/route.coffee:4:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
callEndpoint = (route, endpoint) ->
endpoint = resolveEndpoint endpoint
authenticateIfRequired.call this, route, endpoint
endpoint.action.call this
###
Convert the given endpoint into our expected endpoint object if it is a bare function
###
``` | var callEndpoint;
callEndpoint = function(route, endpoint) {
endpoint = resolveEndpoint(endpoint);
authenticateIfRequired.call(this, route, endpoint);
return endpoint.action.call(this);
};
/*
Convert the given endpoint into our expected endpoint object if it is a bare function
*/ | CoffeeScript | JavaScript | kahmali/meteor-restivus | lib/route.coffee | MIT | 1ae43df2883fa1b32b2e483e8012f9267f87d236 | 541 | https://github.com/kahmali/meteor-restivus/blob/1ae43df2883fa1b32b2e483e8012f9267f87d236/lib/route.coffee | 60 | 67 |
kahmali/meteor-restivus:lib/route.coffee:4:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var callEndpoint;
callEndpoint = function(route, endpoint) {
endpoint = resolveEndpoint(endpoint);
authenticateIfRequired.call(this, route, endpoint);
return endpoint.action.call(this);
};
/*
Convert the given endpoint into our expected endpoint object if... | callEndpoint = (route, endpoint) ->
endpoint = resolveEndpoint endpoint
authenticateIfRequired.call this, route, endpoint
endpoint.action.call this
###
Convert the given endpoint into our expected endpoint object if it is a bare function
### | JavaScript | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | 1ae43df2883fa1b32b2e483e8012f9267f87d236 | 541 | https://github.com/kahmali/meteor-restivus/blob/1ae43df2883fa1b32b2e483e8012f9267f87d236/lib/route.coffee | 60 | 67 |
kahmali/meteor-restivus:lib/route.coffee:4:completion | completion | callEndpoint = (route, endpoint) ->
endpoint = resolveEndpoint endpoint
authenticateIfRequired.call this, route, endpoint
endpoint.action.call this | ###
Convert the given endpoint into our expected endpoint object if it is a bare function
### | CoffeeScript | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | 1ae43df2883fa1b32b2e483e8012f9267f87d236 | 541 | https://github.com/kahmali/meteor-restivus/blob/1ae43df2883fa1b32b2e483e8012f9267f87d236/lib/route.coffee | 60 | 67 |
kahmali/meteor-restivus:lib/route.coffee:5:raw_corpus | raw_corpus | resolveEndpoint = (endpoint) ->
if _.isFunction(endpoint)
endpoint = {action: endpoint}
endpoint
###
Authenticate the given endpoint if required
Once it's globally configured in the API, authentication can be required on an entire route or individual
endpoints. If required on an entire endpoint, that se... | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | 1ae43df2883fa1b32b2e483e8012f9267f87d236 | 541 | https://github.com/kahmali/meteor-restivus/blob/1ae43df2883fa1b32b2e483e8012f9267f87d236/lib/route.coffee | 68 | 81 | ||
kahmali/meteor-restivus:lib/route.coffee:5:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
resolveEndpoint = (endpoint) ->
if _.isFunction(endpoint)
endpoint = {action: endpoint}
endpoint
###
Authenticate the given endpoint if required
Once it's globally configured in the API, authentication can be required on an entire route or individua... | var resolveEndpoint;
resolveEndpoint = function(endpoint) {
if (_.isFunction(endpoint)) {
endpoint = {
action: endpoint
};
}
return endpoint;
};
/*
Authenticate the given endpoint if required
Once it's globally configured in the API, authentication can be required on an entire route or indivi... | CoffeeScript | JavaScript | kahmali/meteor-restivus | lib/route.coffee | MIT | 1ae43df2883fa1b32b2e483e8012f9267f87d236 | 541 | https://github.com/kahmali/meteor-restivus/blob/1ae43df2883fa1b32b2e483e8012f9267f87d236/lib/route.coffee | 68 | 81 |
kahmali/meteor-restivus:lib/route.coffee:5:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var resolveEndpoint;
resolveEndpoint = function(endpoint) {
if (_.isFunction(endpoint)) {
endpoint = {
action: endpoint
};
}
return endpoint;
};
/*
Authenticate the given endpoint if required
Once it's globally configured in the API, auth... | resolveEndpoint = (endpoint) ->
if _.isFunction(endpoint)
endpoint = {action: endpoint}
endpoint
###
Authenticate the given endpoint if required
Once it's globally configured in the API, authentication can be required on an entire route or individual
endpoints. If required on an entire endpoint, that se... | JavaScript | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | 1ae43df2883fa1b32b2e483e8012f9267f87d236 | 541 | https://github.com/kahmali/meteor-restivus/blob/1ae43df2883fa1b32b2e483e8012f9267f87d236/lib/route.coffee | 68 | 81 |
kahmali/meteor-restivus:lib/route.coffee:5:completion | completion | resolveEndpoint = (endpoint) ->
if _.isFunction(endpoint)
endpoint = {action: endpoint}
endpoint
###
Authenticate the given endpoint if required | Once it's globally configured in the API, authentication can be required on an entire route or individual
endpoints. If required on an entire endpoint, that serves as the default. If required in any individual endpoints, that
will override the default.
@context: IronRouter.Router.route()
### | CoffeeScript | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | 1ae43df2883fa1b32b2e483e8012f9267f87d236 | 541 | https://github.com/kahmali/meteor-restivus/blob/1ae43df2883fa1b32b2e483e8012f9267f87d236/lib/route.coffee | 68 | 81 |
kahmali/meteor-restivus:lib/route.coffee:6:raw_corpus | raw_corpus | authenticateIfRequired = (route, endpoint) ->
# Authenticate the request if necessary
if route.api.config.useAuth
if endpoint.authRequired is undefined
authenticate.call(this, route) if route.options?.authRequired
else if endpoint.authRequired
authenticate.call this, route
###
Verify the req... | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | 1ae43df2883fa1b32b2e483e8012f9267f87d236 | 541 | https://github.com/kahmali/meteor-restivus/blob/1ae43df2883fa1b32b2e483e8012f9267f87d236/lib/route.coffee | 82 | 95 | ||
kahmali/meteor-restivus:lib/route.coffee:6:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
authenticateIfRequired = (route, endpoint) ->
# Authenticate the request if necessary
if route.api.config.useAuth
if endpoint.authRequired is undefined
authenticate.call(this, route) if route.options?.authRequired
else if endpoint.authRequired
... | var authenticateIfRequired;
authenticateIfRequired = function(route, endpoint) {
var ref;
// Authenticate the request if necessary
if (route.api.config.useAuth) {
if (endpoint.authRequired === void 0) {
if ((ref = route.options) != null ? ref.authRequired : void 0) {
return authenticate.call(th... | CoffeeScript | JavaScript | kahmali/meteor-restivus | lib/route.coffee | MIT | 1ae43df2883fa1b32b2e483e8012f9267f87d236 | 541 | https://github.com/kahmali/meteor-restivus/blob/1ae43df2883fa1b32b2e483e8012f9267f87d236/lib/route.coffee | 82 | 95 |
kahmali/meteor-restivus:lib/route.coffee:6:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var authenticateIfRequired;
authenticateIfRequired = function(route, endpoint) {
var ref;
// Authenticate the request if necessary
if (route.api.config.useAuth) {
if (endpoint.authRequired === void 0) {
if ((ref = route.options) != null ? ref.authR... | authenticateIfRequired = (route, endpoint) ->
# Authenticate the request if necessary
if route.api.config.useAuth
if endpoint.authRequired is undefined
authenticate.call(this, route) if route.options?.authRequired
else if endpoint.authRequired
authenticate.call this, route
###
Verify the req... | JavaScript | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | 1ae43df2883fa1b32b2e483e8012f9267f87d236 | 541 | https://github.com/kahmali/meteor-restivus/blob/1ae43df2883fa1b32b2e483e8012f9267f87d236/lib/route.coffee | 82 | 95 |
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, route) if route.options?.authRequired
else if endpoint.authRequired
authenticate.call this, route | ###
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 | 1ae43df2883fa1b32b2e483e8012f9267f87d236 | 541 | https://github.com/kahmali/meteor-restivus/blob/1ae43df2883fa1b32b2e483e8012f9267f87d236/lib/route.coffee | 82 | 95 |
kahmali/meteor-restivus:lib/route.coffee:7:raw_corpus | raw_corpus | authenticate = (route) ->
# 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... | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | 1ae43df2883fa1b32b2e483e8012f9267f87d236 | 541 | https://github.com/kahmali/meteor-restivus/blob/1ae43df2883fa1b32b2e483e8012f9267f87d236/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 = (route) ->
# 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, 'serv... | var authenticate;
authenticate = function(route) {
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({
... | CoffeeScript | JavaScript | kahmali/meteor-restivus | lib/route.coffee | MIT | 1ae43df2883fa1b32b2e483e8012f9267f87d236 | 541 | https://github.com/kahmali/meteor-restivus/blob/1ae43df2883fa1b32b2e483e8012f9267f87d236/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(route) {
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 ... | authenticate = (route) ->
# 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... | JavaScript | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | 1ae43df2883fa1b32b2e483e8012f9267f87d236 | 541 | https://github.com/kahmali/meteor-restivus/blob/1ae43df2883fa1b32b2e483e8012f9267f87d236/lib/route.coffee | 96 | 116 |
kahmali/meteor-restivus:lib/route.coffee:7:completion | completion | authenticate = (route) ->
# 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... | if not user
respond.call this, route, {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 | 1ae43df2883fa1b32b2e483e8012f9267f87d236 | 541 | https://github.com/kahmali/meteor-restivus/blob/1ae43df2883fa1b32b2e483e8012f9267f87d236/lib/route.coffee | 96 | 116 |
kahmali/meteor-restivus:lib/route.coffee:8:raw_corpus | raw_corpus | respond = (route, 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 typ... | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | 1ae43df2883fa1b32b2e483e8012f9267f87d236 | 541 | https://github.com/kahmali/meteor-restivus/blob/1ae43df2883fa1b32b2e483e8012f9267f87d236/lib/route.coffee | 117 | 136 | ||
kahmali/meteor-restivus:lib/route.coffee:8:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
respond = (route, 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)
... | var respond;
respond = function(route, body, statusCode = 200, headers) {
var bodyAsJson;
// 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... | CoffeeScript | JavaScript | kahmali/meteor-restivus | lib/route.coffee | MIT | 1ae43df2883fa1b32b2e483e8012f9267f87d236 | 541 | https://github.com/kahmali/meteor-restivus/blob/1ae43df2883fa1b32b2e483e8012f9267f87d236/lib/route.coffee | 117 | 136 |
kahmali/meteor-restivus:lib/route.coffee:8:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var respond;
respond = function(route, body, statusCode = 200, headers) {
var bodyAsJson;
// 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 ... | respond = (route, 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 typ... | JavaScript | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | 1ae43df2883fa1b32b2e483e8012f9267f87d236 | 541 | https://github.com/kahmali/meteor-restivus/blob/1ae43df2883fa1b32b2e483e8012f9267f87d236/lib/route.coffee | 117 | 136 |
kahmali/meteor-restivus:lib/route.coffee:8:completion | completion | respond = (route, 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 typ... | bodyAsJson = JSON.stringify body, undefined, 2
else
bodyAsJson = JSON.stringify body
console.log bodyAsJson
# Send response
@response.writeHead statusCode, headers
@response.write bodyAsJson
@response.end() | CoffeeScript | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | 1ae43df2883fa1b32b2e483e8012f9267f87d236 | 541 | https://github.com/kahmali/meteor-restivus/blob/1ae43df2883fa1b32b2e483e8012f9267f87d236/lib/route.coffee | 117 | 136 |
kahmali/meteor-restivus:lib/route.coffee:2:raw_corpus | raw_corpus | @Route.prototype.addToApi = ->
self = this
# Throw an error if a route has already been added at this path
# TODO: Check for collisions with paths that follow same pattern with different parameter names
if _.contains @api.config.paths, @path
throw new Error "Cannot add a route at an existing path: #{@path... | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | e4e3eca6fef95ca4782122520a8f4b4fc0db0eb7 | 541 | https://github.com/kahmali/meteor-restivus/blob/e4e3eca6fef95ca4782122520a8f4b4fc0db0eb7/lib/route.coffee | 7 | 56 | ||
kahmali/meteor-restivus:lib/route.coffee:2:completion | completion | @Route.prototype.addToApi = ->
self = this
# Throw an error if a route has already been added at this path
# TODO: Check for collisions with paths that follow same pattern with different parameter names
if _.contains @api.config.paths, @path
throw new Error "Cannot add a route at an existing path: #{@path... | else if method is 'POST' and self.endpoints.post
responseData = callEndpoint.call(this, self, self.endpoints.post)
else if method is 'PUT' and self.endpoints.put
responseData = callEndpoint.call(this, self, self.endpoints.put)
else if method is 'PATCH' and self.endpoints.patch
respon... | CoffeeScript | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | e4e3eca6fef95ca4782122520a8f4b4fc0db0eb7 | 541 | https://github.com/kahmali/meteor-restivus/blob/e4e3eca6fef95ca4782122520a8f4b4fc0db0eb7/lib/route.coffee | 7 | 56 |
kahmali/meteor-restivus:lib/route.coffee:5:raw_corpus | raw_corpus | resolveEndpoint = (endpoint) ->
if _.isFunction(endpoint)
endpoint = {action: endpoint}
endpoint
###
Authenticate the given method if required
Once it's globally configured in the API, authentication can be required on an entire route or individual
endpoints. If required on an entire endpoint, that serv... | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | e4e3eca6fef95ca4782122520a8f4b4fc0db0eb7 | 541 | https://github.com/kahmali/meteor-restivus/blob/e4e3eca6fef95ca4782122520a8f4b4fc0db0eb7/lib/route.coffee | 68 | 81 | ||
kahmali/meteor-restivus:lib/route.coffee:5:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
resolveEndpoint = (endpoint) ->
if _.isFunction(endpoint)
endpoint = {action: endpoint}
endpoint
###
Authenticate the given method if required
Once it's globally configured in the API, authentication can be required on an entire route or individual
... | var resolveEndpoint;
resolveEndpoint = function(endpoint) {
if (_.isFunction(endpoint)) {
endpoint = {
action: endpoint
};
}
return endpoint;
};
/*
Authenticate the given method if required
Once it's globally configured in the API, authentication can be required on an entire route or individu... | CoffeeScript | JavaScript | kahmali/meteor-restivus | lib/route.coffee | MIT | e4e3eca6fef95ca4782122520a8f4b4fc0db0eb7 | 541 | https://github.com/kahmali/meteor-restivus/blob/e4e3eca6fef95ca4782122520a8f4b4fc0db0eb7/lib/route.coffee | 68 | 81 |
kahmali/meteor-restivus:lib/route.coffee:5:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var resolveEndpoint;
resolveEndpoint = function(endpoint) {
if (_.isFunction(endpoint)) {
endpoint = {
action: endpoint
};
}
return endpoint;
};
/*
Authenticate the given method if required
Once it's globally configured in the API, authen... | resolveEndpoint = (endpoint) ->
if _.isFunction(endpoint)
endpoint = {action: endpoint}
endpoint
###
Authenticate the given method if required
Once it's globally configured in the API, authentication can be required on an entire route or individual
endpoints. If required on an entire endpoint, that serv... | JavaScript | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | e4e3eca6fef95ca4782122520a8f4b4fc0db0eb7 | 541 | https://github.com/kahmali/meteor-restivus/blob/e4e3eca6fef95ca4782122520a8f4b4fc0db0eb7/lib/route.coffee | 68 | 81 |
kahmali/meteor-restivus:lib/route.coffee:5:completion | completion | resolveEndpoint = (endpoint) ->
if _.isFunction(endpoint)
endpoint = {action: endpoint}
endpoint
###
Authenticate the given method if required | Once it's globally configured in the API, authentication can be required on an entire route or individual
endpoints. If required on an entire endpoint, that serves as the default. If required in any individual endpoints, that
will override the default.
@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 | 68 | 81 |
kahmali/meteor-restivus:lib/route.coffee:6:raw_corpus | raw_corpus | 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 ... | 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:6:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
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
au... | var authenticateIfRequired;
authenticateIfRequired = function(route, endpoint) {
var ref;
// Authenticate the request if necessary
if (route.api.config.useAuth) {
if (endpoint.authRequired === void 0) {
if ((ref = route.options) != null ? ref.authRequired : void 0) {
return authenticate.call(th... | CoffeeScript | JavaScript | 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:6:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var authenticateIfRequired;
authenticateIfRequired = function(route, endpoint) {
var ref;
// Authenticate the request if necessary
if (route.api.config.useAuth) {
if (endpoint.authRequired === void 0) {
if ((ref = route.options) != null ? ref.authR... | 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 ... | JavaScript | CoffeeScript | kahmali/meteor-restivus | lib/route.coffee | MIT | e4e3eca6fef95ca4782122520a8f4b4fc0db0eb7 | 541 | https://github.com/kahmali/meteor-restivus/blob/e4e3eca6fef95ca4782122520a8f4b4fc0db0eb7/lib/route.coffee | 82 | 95 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.