Skip to content

Commit 429f1bc

Browse files
release 2.2.7
1 parent 4c2636e commit 429f1bc

File tree

90 files changed

+15334
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+15334
-3
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ node_modules
3636
# visual studio code
3737
.vscode
3838

39-
# Babel.js
40-
lib/
41-
4239
# cache folder
4340
.cache
4441

lib/Adapters/AdapterLoader.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"use strict";
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
exports.loadAdapter = loadAdapter;
7+
function loadAdapter(adapter, defaultAdapter, options) {
8+
if (!adapter) {
9+
if (!defaultAdapter) {
10+
return options;
11+
}
12+
// Load from the default adapter when no adapter is set
13+
return loadAdapter(defaultAdapter, undefined, options);
14+
} else if (typeof adapter === "function") {
15+
try {
16+
return adapter(options);
17+
} catch (e) {
18+
if (e.name === 'TypeError') {
19+
var Adapter = adapter;
20+
return new Adapter(options);
21+
} else {
22+
throw e;
23+
}
24+
}
25+
} else if (typeof adapter === "string") {
26+
adapter = require(adapter);
27+
// If it's define as a module, get the default
28+
if (adapter.default) {
29+
adapter = adapter.default;
30+
}
31+
return loadAdapter(adapter, undefined, options);
32+
} else if (adapter.module) {
33+
return loadAdapter(adapter.module, undefined, adapter.options);
34+
} else if (adapter.class) {
35+
return loadAdapter(adapter.class, undefined, adapter.options);
36+
} else if (adapter.adapter) {
37+
return loadAdapter(adapter.adapter, undefined, adapter.options);
38+
}
39+
// return the adapter as provided
40+
return adapter;
41+
}
42+
43+
exports.default = loadAdapter;

lib/Adapters/Email/MailAdapter.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
"use strict";
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
7+
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
8+
9+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10+
11+
/*
12+
Mail Adapter prototype
13+
A MailAdapter should implement at least sendMail()
14+
*/
15+
16+
var MailAdapter = exports.MailAdapter = function () {
17+
function MailAdapter() {
18+
_classCallCheck(this, MailAdapter);
19+
}
20+
21+
_createClass(MailAdapter, [{
22+
key: "sendMail",
23+
24+
/*
25+
* A method for sending mail
26+
* @param options would have the parameters
27+
* - to: the recipient
28+
* - text: the raw text of the message
29+
* - subject: the subject of the email
30+
*/
31+
value: function sendMail(options) {}
32+
33+
/* You can implement those methods if you want
34+
* to provide HTML templates etc...
35+
*/
36+
// sendVerificationEmail({ link, appName, user }) {}
37+
// sendPasswordResetEmail({ link, appName, user }) {}
38+
39+
}]);
40+
41+
return MailAdapter;
42+
}();
43+
44+
exports.default = MailAdapter;

lib/Adapters/Files/FilesAdapter.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
"use strict";
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
7+
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
8+
9+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10+
11+
// Files Adapter
12+
//
13+
// Allows you to change the file storage mechanism.
14+
//
15+
// Adapter classes must implement the following functions:
16+
// * createFile(config, filename, data)
17+
// * getFileData(config, filename)
18+
// * getFileLocation(config, request, filename)
19+
//
20+
// Default is GridStoreAdapter, which requires mongo
21+
// and for the API server to be using the DatabaseController with Mongo
22+
// database adapter.
23+
24+
var FilesAdapter = exports.FilesAdapter = function () {
25+
function FilesAdapter() {
26+
_classCallCheck(this, FilesAdapter);
27+
}
28+
29+
_createClass(FilesAdapter, [{
30+
key: "createFile",
31+
32+
/* this method is responsible to store the file in order to be retrived later by it's file name
33+
*
34+
* @param filename the filename to save
35+
* @param data the buffer of data from the file
36+
* @param contentType the supposed contentType
37+
* @discussion the contentType can be undefined if the controller was not able to determine it
38+
*
39+
* @return a promise that should fail if the storage didn't succeed
40+
*
41+
*/
42+
value: function createFile(filename, data, contentType) {}
43+
}, {
44+
key: "deleteFile",
45+
value: function deleteFile(filename) {}
46+
}, {
47+
key: "getFileData",
48+
value: function getFileData(filename) {}
49+
}, {
50+
key: "getFileLocation",
51+
value: function getFileLocation(config, filename) {}
52+
}]);
53+
54+
return FilesAdapter;
55+
}();
56+
57+
exports.default = FilesAdapter;
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
'use strict';
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
exports.GridStoreAdapter = undefined;
7+
8+
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
9+
10+
var _mongodb = require('mongodb');
11+
12+
var _FilesAdapter2 = require('./FilesAdapter');
13+
14+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15+
16+
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
17+
18+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
19+
GridStoreAdapter
20+
Stores files in Mongo using GridStore
21+
Requires the database adapter to be based on mongoclient
22+
23+
weak
24+
*/
25+
26+
var DefaultMongoURI = 'mongodb://localhost:27017/parse';
27+
28+
var GridStoreAdapter = exports.GridStoreAdapter = function (_FilesAdapter) {
29+
_inherits(GridStoreAdapter, _FilesAdapter);
30+
31+
function GridStoreAdapter() {
32+
var mongoDatabaseURI = arguments.length <= 0 || arguments[0] === undefined ? DefaultMongoURI : arguments[0];
33+
34+
_classCallCheck(this, GridStoreAdapter);
35+
36+
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(GridStoreAdapter).call(this));
37+
38+
_this._databaseURI = mongoDatabaseURI;
39+
_this._connect();
40+
return _this;
41+
}
42+
43+
_createClass(GridStoreAdapter, [{
44+
key: '_connect',
45+
value: function _connect() {
46+
if (!this._connectionPromise) {
47+
this._connectionPromise = _mongodb.MongoClient.connect(this._databaseURI);
48+
}
49+
return this._connectionPromise;
50+
}
51+
52+
// For a given config object, filename, and data, store a file
53+
// Returns a promise
54+
55+
}, {
56+
key: 'createFile',
57+
value: function createFile(filename, data, contentType) {
58+
return this._connect().then(function (database) {
59+
var gridStore = new _mongodb.GridStore(database, filename, 'w');
60+
return gridStore.open();
61+
}).then(function (gridStore) {
62+
return gridStore.write(data);
63+
}).then(function (gridStore) {
64+
return gridStore.close();
65+
});
66+
}
67+
}, {
68+
key: 'deleteFile',
69+
value: function deleteFile(filename) {
70+
return this._connect().then(function (database) {
71+
var gridStore = new _mongodb.GridStore(database, filename, 'w');
72+
return gridStore.open();
73+
}).then(function (gridStore) {
74+
return gridStore.unlink();
75+
}).then(function (gridStore) {
76+
return gridStore.close();
77+
});
78+
}
79+
}, {
80+
key: 'getFileData',
81+
value: function getFileData(filename) {
82+
return this._connect().then(function (database) {
83+
return _mongodb.GridStore.exist(database, filename).then(function () {
84+
var gridStore = new _mongodb.GridStore(database, filename, 'r');
85+
return gridStore.open();
86+
});
87+
}).then(function (gridStore) {
88+
return gridStore.read();
89+
});
90+
}
91+
}, {
92+
key: 'getFileLocation',
93+
value: function getFileLocation(config, filename) {
94+
return config.mount + '/files/' + config.applicationId + '/' + encodeURIComponent(filename);
95+
}
96+
}]);
97+
98+
return GridStoreAdapter;
99+
}(_FilesAdapter2.FilesAdapter);
100+
101+
exports.default = GridStoreAdapter;

0 commit comments

Comments
 (0)