Feature Releases

Skygear 1.0 Released: API Regrouping to Improve Discoverability

Posted by skygearblog on
Skygear 1.0 Released: API Regrouping to Improve Discoverability

We are excited to announce the release of Skygear v1.0. In this release, we’ve improved the discoverability of APIs to help developers build web and mobile apps more quickly on our serverless platform.

Existing apps will stay on Skygear v0.24. Please remember to pin your SDK at v0.24 or lower as well. Migration documentation for apps developed with v0.24 are coming soon!

Skygear v1.0’s regrouped APIs are the groundwork for many new features and Skygear v1.1 will be released a week after v1.0 with improved user profile discovery. The Skygear portal will reflect the latest v1.1.0 upgrade. All new apps created on Skygear.io will be created with Skygear v1.1.0. You can confirm your version in the Settings page of your Skygear developer portal.

serverless baas dashboard open source

Go to your developer portal Settings page to verify your Skygear version.

How we have regrouped the APIs

Serverless solutions are designed to help developers build products more efficiently. Knowing what grouped APIs are available will save you hours of creating additional features from scratch. We have regrouped Skygear’s APIs into smaller containers so that you can discover them more easily.

We have split our previous container into smaller containers according to the Skygear SDK’s 6 key features. This regrouping provides consistency in our API naming for both documentation and for code editors with autocomplete.

For example, If you want to learn about auth related APIs for JS, you can get the whole list from the auth container documentation.

Under the new grouping, APIs are now updated to include the container name. For example, the sign up method “skygear.signupWithUsername” is now updated to “skygear.auth.signupWithUsername”.

Skygear SDK APIs are now grouped under the following 6 containers:

  1. PublicDB
  2. PrivateDB
  3. Auth
  4. Pubsub
  5. Push
  6. Relation

The implications of this regrouping can affect several features. For example, all things to do with passwords and authentication are now grouped consistently under the auth container.

You can find the API references here: JS, iOS, and Android

Two additional features that are not included in the SDK can be found on Skygear.io’s GitHub repository:

We will continue to support v0.24 mainly for bug fixing.

For v0.24 or below users, you can access the v0 documentation and the API references here.

Create a new app with Skygear v1.0 and tell us what you think!

Skygear is an open-source serverless platform. Check out our docs and set up your free account today!

You can download the open-source repo here: https://github.com/SkygearIO

Release Notes

Skygear v0.24.0

Posted by David Ng on

Version 0.24.0 of Skygear is released in May 2017. There are various update for the Server and SDKs. You can find more information in each section below.

Features

  • Support for cancellable query (#277)
  • Make plugin transport ZMQ multiplex (#295)

    This feature will enable the bidirectional plugin transport and multiplexing.
    The protocol will introduce address-stack and bounce-count, so the
    bidirectional communication stack will be limited to the bounce-count-limit.

    It solved the problem of workers exhaust problem when plugin call back
    skygear-server.

Other Notes

  • Update releasing guide for npm + lerna
  • Fix schema:default_access inline doc

You can download the Runnable binaries for Skygear Server here.

Have fun with the new release and let us know if you have any feedback or questions in our GitHub Issue.

Release Notes

Skygear v0.23.0

Posted by David Ng on

Version 0.23.0 of Skygear is released in April 2017. There are various update for the Server and SDKs. You can find more information in each section below.

Features

  • Implement GeoJSON query using ST_Contains (#262)
  • Make default ACL server-based (#309)

Bug Fixes

  • Ensure respond channel of zmq is always consumed so channeller is not blocked (#347)
  • Fix inconsistent behavior saving to integer column (#319)

Other Notes

  • Revamp query sqlizer into its own package

You can download the Runnable binaries for Skygear Server here.

Have fun with the new release and let us know if you have any feedback or questions in our GitHub Issue.

Release Notes

Skygear v0.22.2

Posted by David Ng on

Version 0.22.2 of Skygear is released in April 2017. There are various update for the Server and SDKs. You can find more information in each section below.

Major Features

Skygear Server

  • Create user when master key is provided (#261)
  • Fetch full assets data in query
  • Return asset content type in response of record save (#327)

iOS SDK

Android SDK

  • Add user query by username request and related methods
  • Support content type for asset serialization (#92)

JS SDK

  • Add url signing function to cloud (#165)

Cloud code – Python

Bug Fixes

Server

  • Fix plugin timer request not properly initialized (#333)
  • Fix schema:fetch when record type has no fields

iOS SDK

  • Wrap error messages with NSLocalizedString (#85)

Android SDK

  • Fix the crash on parsing date string (#109)

JS SDK

  • Fix request object’s action only replace first : to /
  • Put content type from server to asset objec

Cloud code – Python

  • Update the mock interface for ZMQTransport (#122)

Other Notes

Server

  • Make RequireUser preprocessor gives a better error message
  • Add ASSET_STORE_S3_URL_PREFIX in .env.sample
  • Update godev image not using development version of glide
  • Commands for setting up skygear in Linux env

Android SDK

  • Replaced StringBuffer with StringBuilder

JS SDK

  • Add documentation on container pubsub on/off (#177)

You can download the Runnable binaries for Skygear Server here.

Have fun with the new release and let us know if you have any feedback or questions in our GitHub Issue.

Tutorials

Building a Simple Blog from Scratch with Skygear with JS

Posted by Zachary Lo on
Building a Simple Blog from Scratch with Skygear with JS

In this tutorial, we will build a simple blog with Skygear, an open-source serverless platform that has features such as a cloud database, authentication, pubsub, push, chat, and event tracking. With this tutorial, you can learn how to create your own custom blog from scratch for JS.

Skygear sets up the server for you and also provides a set of APIs to save and get data from the database. That means with Skygear, you only have to work on building the interface of the app.

Let’s take a look at the features of our web blog app:

  1. Create and save new blog post to the cloud
  2. List all blog posts stored in the cloud
  3. Display individual blog post with a unique URL

You can play around with the demo we put on CodePen to get a better idea of how the app works: http://codepen.io/anon/pen/aJaMNb

Add Skygear to the app

First, create an HTML file with any text editor. Alternatively, you can create a Codepen project.

In this step, we load Skygear in our app so that we can use it.  For this simple web project, We can simply load it from the CDN provided by the Skygear Cloud

Add the following code to your HTML file to load Skygear.

** If you are using Codepen, you should add Skygear to your project as an external resource instead. Go to Settings > Javascript > Add External Javascript, copy and paste the two URLs onto the External Javascript list.

Configure Skygear

To connect our app with the Skygear Server, we need to configure Skygear.

Make sure you already have a Skygear account. You can get one here. An app project will be created for you automatically after the sign up.

Then, get your app details in the developer portal dashboard. Configure Skygear with the Server Endpoint and API key.

skygear-portal-new

 

Now, create a new JS file in the same directory and add the following lines to it.

Replace the <Your Endpoint Here> and <Your API Key Here> with the information you get from the developer portal.

Next, add the following lines in your HTML file so that it loads our JS file.

**You don’t need this in Codepen as Skygear will be loaded as an external resource automatically.

Now, open your HTML file with a browser and go to the page inspector. If you see “skygear container is now ready for making API calls” in the console, it means Skygear has been successfully set up in the app!

Check out the quick start guide if you want to know how to set up Skygear in other web environments.

Implement the basic UI

Now, it is time to work on the UI and the functions of the app.

The UI of the app is divided into two parts.

The upper part is where we enter the title and the content of a blog post.

The lower part is where we display all the blog posts. And when we click on the blog title, the blog content will be displayed in a new page.

Add the following lines to inside the body tag in the HTML file.

Refresh your page. You should be able to see:

  1. Input fields for the post title and the post content
  2. “Create Post” button

Screen Shot 2017-03-28 at 5.47.16 PM

Sign in anonymously

After creating the interface, the next step is to save a blog post to the Skygear Cloud DB.

In Skygear, in order to create a record in the database, we have to sign in as a user first. To keep things simple, instead of building an user authentication system where people register an account with their email and password, we will use the sign up anonymously function here.

This means we do not have to sign up explicitly with a username or email. Skygear will keep the user session using the browser local storage.

Let’s add the following code in the JS file.

Then call the signupAnonymously function right after the API Configuration is completed so that we will be logged in once the app is initialised.

Add signupAnonymously() after the console.log() in the skygear.config function:

As we should only sign up a user when there is no current user, in the above codes, we have used the property skygear.currentUser to check if there is already a signed-in user.

If the currentUser equals to null, it means no user is signed in and it will run the signupAnonymously function.

Create the first blog post

In this step, we add a click event listener to the save-button. We will also use the title textfield and the content textfield to create a new record in the cloud database blogpost table.

What we have done:

  1. Create an event listener to listen for click events
  2. When the save button is clicked, the app will first get the input from the title and the content fields, then create the object BlogPost and associate it with the database table blogpost.
  3. Then, save the ‘BlogPost’ in the blogpost table with the two attributes: title and content.

Enter a few blog entries to see if the function works. You can check for a log like the one below in the developer console to confirm the record is saved successfully.

*You wouldn’t be able to see the blog posts you entered in the app yet. The above lines only help us save the blog post to the cloud. Next we have to retrieve all the blog posts saved from the database and display them in the app.

List all blog posts from the database

Our next step is to make a query to retrieve the blog posts from the database.

Add the following lines to the JS file.

What we have done:

  1. Create a query to get records from the table blogpost.
  2. Add a sorting criteria for the query. addDescending sorts the query with descending order according to the created date of each blog post (i.e. _created_at).
  3. Update the blog posts we get from the query by adding a <li> element and a <a> element with an url of the individual post.  The url of the individual post is composed of a hash and its record id. By doing so we can then display the content of the blog post in an individual page.
  4. Add the updated blog posts to the div ‘content’ we created in step 3.

*You can sort the query based on any attribute of a record. Learn more here.

Cool. We get all our blog posts now. But when should we display them?

Let’s display them after we’ve signed up and after we’ve saved a record.

First, create a function called showContent() that returns listBlogPosts()

*Looks reductant? You will know why we need this later.

Now, call showContent() after we’ve signed up anonymously and after we’ve saved a record.

Refresh your page now. If everything is in its place, you should see something similar:

retrieve-blog-post

Show a single blog post

Wait. Aren’t we done? We can already see a list of blog posts on our page now.

Now click on a blog title from the list. You are prompted to a new window but you only get the same list. Where is the content of the blog?

That’s our last step – showing a single blog post.

Remember when we set the url of a single blog post, we have used a hash and its record id?

We are going to use that unique id to get the content of the blog post and display it in the div ‘content’, the same div we display our a list of blog posts.

Now create a retrieveBlogPost() function to display the content of a blog post.

Then update the showContent()function to

As we are using the same area to display the list of blog posts and the blog content, we need to tell our page when to display the list of blog posts and when to display a single blog.

In the above lines, we use the hash on the URL to determine whether we should list all blog posts. Let’s say a URL is http://yoursite.com/blog/#abc, #abc is the hash of the URL.

If a hash exists in the URL, we will call the retrieveBlogPost() function and display the blog post. If the hash doesn’t exist, it will show the list of blog posts instead.

Now click on a blog title from the list. Do you see the content of the post?

blog-post-content

Congratulation! You made it.

More features

With Skygear Cloud Database, you can implement a lot more features for this blogging system, for example you can let people sign up with email or Google login with just a few line of code.

Beside Database and User Auth, Skygear also comes with Skygear Chat for building chat application, Push notification for iOS and Android apps, and Cloud Functions when your app need some server side code.

Check out our website Skygear, to learn more.

What do you think about this tutorial? We publish monthly tutorials. Let us know what you’d like us to write about next!

Release Notes

Skygear v0.22.0

Posted by David Ng on
Skygear v0.22.0

Version 0.22.0 of Skygear is released in February 2017. There are various updates for the Server and SDKs. You can find more information for implications on serverless deployment for the Skygear server, iOS SDK, JS SDK in each section below.

Major Features

Skygear Server

  • Implement API response timeout (#271)

iOS SDK

JS SDK

Cloud code – Python

Bug Fixes

Server

  • Fix request context not initialized (#284)
  • Check for constraint violation when deleting when deleting records

Other Notes

Server

  • Add Nix derivation for building
  • Require go1.7.4 for building

Cloud code – Python

  • Fix passing key_required to server (#117)

JS SDK


You can download the Runnable binaries for Skygear Server here.

Have fun with the new release and let us know if you have any feedback or questions in our GitHub Issue.

Release Notes

Skygear v0.21.0

Posted by David Ng on
Skygear v0.21.0

Version 0.21.0 of Skygear is released in January 2017. Various update for the Server and SDKs. You can find more information on updates to the Skygear server, Android SDK, iOS SDK, JS SDK, and Clode Code in each section below.

Major Features

Skygear Server

  • Support token based APNS (#239)

Android SDK

  •     Provide package name when register device (SkygearIO/skygear-server#239)
    • Send package name as topic parameter when registering device, it will help cloud code to send push notification to segment of device.

iOS SDK

JS SDK

  • Call includeme in index.js for user cloud code
    • Add support for LOAD_MODULES and includeme (#155)
  • Accept bundle name when register device (SkygearIO/skygear-server#239)

Cloud Code

Bug Fixes

JS SDK

  • Fix unable to start when LOAD_MODULES is not set
    • This happens because when LOAD_MODULES is not set the parsed module list will be an array with an empty string. This causes configModule to be called with an empty string.

Other Notes


You can download the Runnable binaries for Skygear Server here.

Have fun with the new release and let us know if you have any feedback or questions in our GitHub Issue.

Release Notes

Skygear v0.20.0

Posted by David Ng on
Skygear v0.20.0

We’ve released version 0.20.0 of Skygear. Various update for the Server and SDKs. You can find more information in each section below.

Major Features

  • Support s3 asset store url prefix (#254)
  • Support unregister device (#249)
  • Add configuration for timeout of plugin
  • Provide skygear config for plugin init events

Bug Fixes

  • Fix postgis-2.3 not found

Other Notes

  • More log when plugin response is invalid (#232)
  • Put access_key_type to plugin request context (#238)
  • Limit the number of bytes in request logThe existing implementation prints the response body for certain type
    this pose a problem to log collection when the response body is too big.
  • Better handling for unrecognized data type (#231)This is achieved by introducing a new skydb type called Unknown, which
    will be passed to client when the server sees a column with an
    unrecognized data type.Previous behavior will result in Skygear server throwing an error when
    it sees a column with unrecognized data type.

 

Check out our latest releases for our open-source serverless platform here:

Check out http://skygear.io and create your app for free.