Skip to content

Changes references to api.parse.com and /1/ #458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 121 additions & 1 deletion _app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,9 @@ App.Views = {};
// deal with common-lang-blocks
this.toggleCommonLangBlocks();

// setup the server/mount path editor
this.setupServerFieldCustomization();

// add toggles to code blocks if necessary
if (this.platform === "ios" || this.platform === "osx" || this.platform === "macos") {
new App.Views.Docs.Toggle({
Expand Down Expand Up @@ -729,6 +732,123 @@ App.Views = {};
}
},

setupServerFieldCustomization: function setupServerFieldCustomization() {

if(!document.getElementById('parse-server-custom-url')) {
// no customization available on this page
return;
}

if (typeof(Storage) !== "undefined") {
// apply previous values from local storage
const _url = localStorage.getItem('parse-server-custom-url');
const _mount = localStorage.getItem('parse-server-custom-mount');
const _protocol = localStorage.getItem('parse-server-custom-protocol');
const _appId = localStorage.getItem('parse-server-custom-appid');
const _clientKey = localStorage.getItem('parse-server-custom-clientkey');

// set existing entries
if (_url) {
$(".custom-parse-server-url").html(_url);
$("#parse-server-custom-url").val(_url);
}
if (_mount) {
$(".custom-parse-server-mount").html(_mount);
$("#parse-server-custom-mount").val(_mount);
}
if (_protocol) {
$(".custom-parse-server-protocol").html(_protocol);
$("#parse-server-custom-protocol").val(_protocol);
}
if (_appId) {
$(".custom-parse-server-appid").html(_appId);
$("#parse-server-custom-appid").val(_appId);
}
if (_clientKey) {
$(".custom-parse-server-clientkey").html(_clientKey);
$("#parse-server-custom-clientkey").val(_clientKey);
}
}

// set url listener
$('#parse-server-custom-url').keyup(function() {
const url = $('#parse-server-custom-url').val();
if(!url.match(/^[-_a-z0-9\.]+(?::[0-9]+)?$/i)) {
// not a valid url
return;
}
$(".custom-parse-server-url").html(url);
if (typeof(Storage) !== "undefined") {
localStorage.setItem('parse-server-custom-url', url);
}
});

// set mount listener
$('#parse-server-custom-mount').keyup(function() {
var mount = $('#parse-server-custom-mount').val();
if(!mount.match(/^[-_a-z0-9\/]+$/i) && mount !== '') {
// not a valid mount path, and not empty
return;
}
if(!mount.match(/^\//)) {
// add leading slash
mount = '/'+mount;
}
if(!mount.match(/\/$/)) {
// add trailing slash
mount = mount+'/';
}
$(".custom-parse-server-mount").html(mount);
if (typeof(Storage) !== "undefined") {
localStorage.setItem('parse-server-custom-mount', mount);
}
});

// set protocol listener
$('#parse-server-custom-protocol').change(function() {
const protocol = $('#parse-server-custom-protocol').val();
if(!protocol.match(/^[a-z]+$/)) {
// not a valid protocol
return;
}
$(".custom-parse-server-protocol").html(protocol);
if (typeof(Storage) !== "undefined") {
localStorage.setItem('parse-server-custom-protocol', protocol);
}
});

// set appId listener
$('#parse-server-custom-appid').keyup(function() {
var appId = $('#parse-server-custom-appid').val();
if(!appId.match(/^[^\s]+$/i)) {
// not a valid appId
return;
}
// encode any html
appId = appId.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
$(".custom-parse-server-appid").html(appId);
if (typeof(Storage) !== "undefined") {
localStorage.setItem('parse-server-custom-appid', appId);
}
});

// set clientKey listener
$('#parse-server-custom-clientkey').keyup(function() {
var clientKey = $('#parse-server-custom-clientkey').val();
if(!clientKey.match(/^[^\s]+$/i)) {
// not a valid appId
return;
}
// encode any html
clientKey = clientKey.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
$(".custom-parse-server-clientkey").html(clientKey);
if (typeof(Storage) !== "undefined") {
localStorage.setItem('parse-server-custom-clientkey', clientKey);
}
});

},

// we recalculate the header heights for the TOC
// highlighting when the height of the content changes
handleToggleChange: function() {
Expand All @@ -753,7 +873,7 @@ $('pre code').each(function(i, block) {
hljs.highlightBlock(block);
});

var platform = window.location.pathname.split('/')[2];
var platform = window.location.pathname.split('/')[1];
if (platform) {
new App.Views.Docs.Main({
language: 'en',
Expand Down
4 changes: 2 additions & 2 deletions _includes/android/push-notifications.md
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ curl -X GET \
-G \
--data-urlencode 'limit=1000' \
--data-urlencode 'where={ "city": "San Francisco", "deviceType": { "$in": [ "ios", "android", "winphone", "embedded" ] } }' \
https://api.parse.com/1/installations
https://YOUR.PARSE-SERVER.HERE/parse/installations
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here?

```

If you type the above into a console, you should be able to see the first 1,000 objects that match your query. Note that constraints are always ANDed, so if you want to further reduce the search scope, you can add a constraint that matches the specific installation for your device:
Expand All @@ -493,7 +493,7 @@ curl -X GET \
-G \
--data-urlencode 'limit=1' \
--data-urlencode 'where={ “objectId”: {YOUR_INSTALLATION_OBJECT_ID}, "city": "San Francisco", "deviceType": { "$in": [ "ios", "android", "winphone", "embedded" ] } }' \
https://api.parse.com/1/installations
https://YOUR.PARSE-SERVER.HERE/parse/installations
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here?

```

If the above query returns no results, it is likely that your installation does not meet the targeting criteria for your campaign.
Expand Down
2 changes: 1 addition & 1 deletion _includes/arduino/other.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Because the Arduino SDK was designed to minimize memory footprint, it doesn't pr
For example, you could sign up a user from Arduino through a REST call:

```cpp
ParseResponse response = Parse.sendRequest("POST", "/1/users", "{\"username\":\"cooldude6\",\"password\":\"p_n7!-e8\"}", "");
ParseResponse response = Parse.sendRequest("POST", "/parse/users", "{\"username\":\"cooldude6\",\"password\":\"p_n7!-e8\"}", "");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here?

```

In this case, the response will contain the objectId of the created user, assuming it was created successfully.
Expand Down
2 changes: 1 addition & 1 deletion _includes/arduino/requests.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Because the Arduino SDK was designed to minimize memory footprint, it doesn't pr
For example, you could sign up a user from Arduino through a REST call:

```cpp
ParseResponse response = Parse.sendRequest("POST", "/1/users", "{\"username\":\"cooldude6\",\"password\":\"p_n7!-e8\"}", "");
ParseResponse response = Parse.sendRequest("POST", "/parse/users", "{\"username\":\"cooldude6\",\"password\":\"p_n7!-e8\"}", "");
```

In this case, the response will contain the objectId of the created user, assuming it was created successfully.
Expand Down
2 changes: 1 addition & 1 deletion _includes/cloudcode/cloud-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ curl -X POST \
-H "X-Parse-REST-API-Key: ${REST_API_KEY}" \
-H "Content-Type: application/json" \
-d '{ "movie": "The Matrix" }' \
https://api.parse.com/1/functions/averageStars
https://YOUR.PARSE-SERVER.HERE/parse/functions/averageStars
```

And finally, to call the same function from a JavaScript app:
Expand Down
4 changes: 2 additions & 2 deletions _includes/common/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -456,9 +456,9 @@ There are some special classes in Parse that don't follow all of the same securi
|Delete|normal behavior [5]|master key only [7]|
|Add Field|normal behavior|normal behavior|

1. Logging in, or `/1/login` in the REST API, does not respect the Get CLP on the user class. Login works just based on username and password, and cannot be disabled using CLPs.
1. Logging in, or `/parse/login` in the REST API, does not respect the Get CLP on the user class. Login works just based on username and password, and cannot be disabled using CLPs.

2. Retrieving the current user, or becoming a User based on a session token, which are both `/1/users/me` in the REST API, do not respect the Get CLP on the user class.
2. Retrieving the current user, or becoming a User based on a session token, which are both `/parse/users/me` in the REST API, do not respect the Get CLP on the user class.

3. Read ACLs do not apply to the logged in user. For example, if all users have ACLs with Read disabled, then doing a find query over users will still return the logged in user. However, if the Find CLP is disabled, then trying to perform a find on users will still return an error.

Expand Down
24 changes: 24 additions & 0 deletions _includes/common/server-customize.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Your Configuration

<noscript>
<p style='padding:8px;color:#fff;background:#f06;border-radius:4px;font-weight:bold'>Customization requires Javascript to be enabled!</p>
</noscript>
Customize our docs with your server configuration.

Protocol:<br/>
<select id='parse-server-custom-protocol' class='custom-server-option' style='border:none' title='Set your access protocol here.'>
<option value='https'>https</option>
<option value='http'>http</option>
</select><br/>
Domain:
<input id='parse-server-custom-url' class='custom-server-option' type='text' placeholder='your.domain.com, your.domain.com:1337' value='YOUR.PARSE-SERVER.HERE' title='Set your parse server domain here.' autocorrect='off' spellcheck='false'>
Mount Path:
<input id='parse-server-custom-mount' class='custom-server-option' type='text' placeholder='your-mount-path, /your-mount-path/' value='parse' title='Set your mount path here.' autocorrect='off' spellcheck='false'>
App Id:
<input id='parse-server-custom-appid' class='custom-server-option' type='text' placeholder='your-app-id-here' value='APPLICATION_ID' title='Set your app id here.' autocorrect='off' spellcheck='false'>
Client Key:
<input id='parse-server-custom-clientkey' class='custom-server-option' type='text' placeholder='your-client-key-here' value='CLIENT_KEY' title='Set your client here here.' autocorrect='off' spellcheck='false'>

- serverUrl: <code class="highlighter-rouge"><span class="custom-parse-server-protocol">https</span>://<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span><span class="custom-parse-server-mount">/parse/</span></code>
- appId: <code class="highlighter-rouge"><span class="custom-parse-server-appid">APPLICATION_ID</span></code>
- clientKey: <code class="highlighter-rouge"><span class="custom-parse-server-clientkey">CLIENT_KEY</span></code>
2 changes: 1 addition & 1 deletion _includes/embedded_c/cloud-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ void myCloudFunctionCallback(ParseClient client, int error, int httpStatus, cons
// httpResponseBody holds the Cloud Function response
}
}
parseSendRequest(client, "POST", "/1/functions/hello", "{\"value\":\"echo\"}", myCloudFunctionCallback);
parseSendRequest(client, "POST", "/parse/functions/hello", "{\"value\":\"echo\"}", myCloudFunctionCallback);
```
4 changes: 2 additions & 2 deletions _includes/embedded_c/requests.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
The main way you'll be interacting with Parse is through the `parseSendRequest` function, which sends a request to the REST API. For example, here's how to save an object with some data:

```cpp
char data[] = "{ \"temperature\": 165 }"; parseSendRequest(client, "POST", "/1/classes/Temperature", data, NULL);
char data[] = "{ \"temperature\": 165 }"; parseSendRequest(client, "POST", "/parse/classes/Temperature", data, NULL);
```

For some requests you will be interested in data returned for the request. In such a case you need to setup a callback and pass it to `parseSendRequest`.
Expand All @@ -15,7 +15,7 @@ void mySaveCallback(ParseClient client, int error, int httpStatus, const char* h
}
}

parseSendRequest(client, "GET", "/1/classes/TestObject/gsMHOY3MAx", NULL, myCallback);
parseSendRequest(client, "GET", "/parse/classes/TestObject/gsMHOY3MAx", NULL, myCallback);
```

Using this function, you have full access to the REST API to create objects, delete objects, send analytics events, and more. Take a look at the [REST API Guide]({{ site.baseUrl }}/rest/guide) to find out all the details.
4 changes: 2 additions & 2 deletions _includes/ios/push-notifications.md
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ curl -X GET \
-G \
--data-urlencode 'limit=1000' \
--data-urlencode 'where={ "city": "San Francisco", "deviceType": { "$in": [ "ios", "android", "winphone", "embedded" ] } }' \
https://api.parse.com/1/installations
https://YOUR.PARSE-SERVER.HERE/parse/installations
</code></pre>

If you type the above into a console, you should be able to see the first 1,000 objects that match your query. Note that constraints are always ANDed, so if you want to further reduce the search scope, you can add a constraint that matches the specific installation for your device:
Expand All @@ -888,7 +888,7 @@ curl -X GET \
-G \
--data-urlencode 'limit=1' \
--data-urlencode 'where={ “objectId”: {YOUR_INSTALLATION_OBJECT_ID}, "city": "San Francisco", "deviceType": { "$in": [ "ios", "android", "winphone", "embedded" ] } }' \
https://api.parse.com/1/installations
https://YOUR.PARSE-SERVER.HERE/parse/installations
</code></pre>

If the above query returns no results, it is likely that your installation does not meet the targeting criteria for your campaign.
Expand Down
4 changes: 2 additions & 2 deletions _includes/js/users.md
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ Parse then verifies that the provided `authData` is valid and checks to see if a

<pre><code class="javascript">
Status: 200 OK
Location: https://api.parse.com/1/users/uMz0YZeAqc
Location: https://YOUR.PARSE-SERVER.HERE/parse/users/uMz0YZeAqc
</code></pre>

With a response body like:
Expand Down Expand Up @@ -492,7 +492,7 @@ If the user has never been linked with this account, you will instead receive a

<pre><code class="javascript">
Status: 201 Created
Location: https://api.parse.com/1/users/uMz0YZeAqc
Location: https://YOUR.PARSE-SERVER.HERE/parse/users/uMz0YZeAqc
</code></pre>
The body of the response will contain the `objectId`, `createdAt`, `sessionToken`, and an automatically-generated unique `username`. For example:

Expand Down
32 changes: 16 additions & 16 deletions _includes/rest/analytics.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ In the example below, the `at` parameter is optional. If omitted, the current se

<pre><code class="bash">
curl -X POST \
-H "X-Parse-Application-Id: ${APPLICATION_ID}" \
-H "X-Parse-Application-Id: <span class="custom-parse-server-appid">${APPLICATION_ID}</span>" \
-H "X-Parse-REST-API-Key: ${REST_API_KEY}" \
-H "Content-Type: application/json" \
-d '{
}' \
https://api.parse.com/1/events/AppOpened
<span class="custom-parse-server-protocol">https</span>://<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span><span class="custom-parse-server-mount">/parse/</span>events/AppOpened
</code></pre>
<pre><code class="python">
import json,httplib
connection = httplib.HTTPSConnection('api.parse.com', 443)
connection = httplib.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
connection.connect()
connection.request('POST', '/1/events/AppOpened', json.dumps({
connection.request('POST', '<span class="custom-parse-server-mount">/parse/</span>events/AppOpened', json.dumps({
}), {
"X-Parse-Application-Id": "${APPLICATION_ID}",
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
"X-Parse-REST-API-Key": "${REST_API_KEY}",
"Content-Type": "application/json"
})
Expand All @@ -57,7 +57,7 @@ Say your app offers search functionality for apartment listings, and you want to

<pre><code class="bash">
curl -X POST \
-H "X-Parse-Application-Id: ${APPLICATION_ID}" \
-H "X-Parse-Application-Id: <span class="custom-parse-server-appid">${APPLICATION_ID}</span>" \
-H "X-Parse-REST-API-Key: ${REST_API_KEY}" \
-H "Content-Type: application/json" \
-d '{
Expand All @@ -67,20 +67,20 @@ curl -X POST \
"dayType": "weekday"
}
}' \
https://api.parse.com/1/events/Search
<span class="custom-parse-server-protocol">https</span>://<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span><span class="custom-parse-server-mount">/parse/</span>events/Search
</code></pre>
<pre><code class="python">
import json,httplib
connection = httplib.HTTPSConnection('api.parse.com', 443)
connection = httplib.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
connection.connect()
connection.request('POST', '/1/events/Search', json.dumps({
connection.request('POST', '<span class="custom-parse-server-mount">/parse/</span>events/Search', json.dumps({
"dimensions": {
"priceRange": "1000-1500",
"source": "craigslist",
"dayType": "weekday"
}
}), {
"X-Parse-Application-Id": "${APPLICATION_ID}",
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
"X-Parse-REST-API-Key": "${REST_API_KEY}",
"Content-Type": "application/json"
})
Expand All @@ -92,31 +92,31 @@ Parse Analytics can even be used as a lightweight error tracker — simply invok

<pre><code class="bash">
curl -X POST \
-H "X-Parse-Application-Id: ${APPLICATION_ID}" \
-H "X-Parse-Application-Id: <span class="custom-parse-server-appid">${APPLICATION_ID}</span>" \
-H "X-Parse-REST-API-Key: ${REST_API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"dimensions": {
"code": "404"
}
}' \
https://api.parse.com/1/events/Error
<span class="custom-parse-server-protocol">https</span>://<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span><span class="custom-parse-server-mount">/parse/</span>events/Error
</code></pre>
<pre><code class="python">
import json,httplib
connection = httplib.HTTPSConnection('api.parse.com', 443)
connection = httplib.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
connection.connect()
connection.request('POST', '/1/events/Error', json.dumps({
connection.request('POST', '<span class="custom-parse-server-mount">/parse/</span>events/Error', json.dumps({
"dimensions": {
"code": "404"
}
}), {
"X-Parse-Application-Id": "${APPLICATION_ID}",
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
"X-Parse-REST-API-Key": "${REST_API_KEY}",
"Content-Type": "application/json"
})
result = json.loads(connection.getresponse().read())
print result
</code></pre>

Note that Parse currently only stores the first eight dimension pairs per call to `/1/events/<eventName>`.
Note that Parse currently only stores the first eight dimension pairs per call to <code class="highlighter-rouge"><span class="custom-parse-server-mount">/parse/</span>events/&lt;eventName&gt;</code>.
Loading