skycliapp creation command and give the new app a name. It's better to prefix you app name with your name or alias like your GitHub ID, since Skygear cluster is shared among everyone who has an account and it's likely someone has already taken the app name
__APP_NAME__with your app's name:
skycliwill look for a skygear.yaml at the current directory. Once located, it will deploy the directory and the code inside to Skygear under the app name provided at line 1 in
__API_KEY__with app's endpoint and api key you have jotted down:
skygear.auth.logintake a tuple of email and password, which will be submitted Auth gear to perform sign-up and log-in operations.
gotToWriteBlogs(). Otherwise, error message will be shown.
skygear.auth.logout()as we will invalidate the current access token. This prevents us from being attacked with reused access tokens.
skygear.yamlis the primary configuration file telling Skygear how your app is formed with (micro)services, how they are declared and what resources such as Secrets and environment variables they will use.
frontend, while the same words at line 4 and 13 are the services' respective names. Them services will both be built with Skygear's pre-configured containerization templates
nodejs:12, as declared at line 7 and 16.
pathwill be the actual API endpoint others can reach the service. So the endpoint for service
https://<your_name>-nodeblog.skygearapp.com/whereas that for
MONGO_DB_URLcarrying the MongoDB's connection string is passed to the service
backendas an environment variable, as shown in line 10-12.
after_user_create, which will be triggered once a user is created on Auth gear. Code hooked to it is in
/api/after_user_createwhich we will cover later.
./backend/api.js, which we won't be covering. They interact with the MongoDB and create/return corresponding blog payloads.
backendservice is registered in the Skygear app under the path
/api. Another feature of Skygear JS SDK is the app's endpoint will automatically be prepended for you, so that you can call microservices directly by their path. The current user's access token along with some other headers and payloads will be substituted into the request for you as well.
fetch_blogsin our backend service, we can simply use the wrapped fetch method with
api/fetch_blogsas the first parameter.
curl, but in that case you will have to fill in the headers and some required information yourself.
after_user_createin the app's configuration. The user-storing functions will then get triggered when such event happens on Auth gear.