# Node.js -------------------------------------------------------------------------------- title: "Introduction" description: "Create a single-page serverless web application using Catalyst Advanced I/O Function and Catalyst Data Store that allows you to report or look up alien encounters in a city." last_updated: "2026-03-18T07:41:08.669Z" source: "https://docs.catalyst.zoho.com/en/tutorials/alien-city/nodejs/introduction/" service: "All Services" related: - Project Directory Structure (/en/cli/v1/project-directory-structure/introduction/) - Java SDK (/en/sdk/java/v1/overview/) - Node.js SDK (/en/sdk/nodejs/v2/overview/) - Python SDK (/en/sdk/python/v1/overview/) -------------------------------------------------------------------------------- # Alien City ### Introduction This tutorial will help you build a simple web application, titled **Alien City**, that allows you to report and look up alien encounters in a city. Alien City is built as a single-page serverless application using Catalyst. The client application will appear as follows: You can access a working application and test its functioning here: {{%link href="https://alien-city.catalystserverlessapp.com/app/"%}}Try the App!{{%/link%}} The Alien City application utilizes components from the following Catalyst Services: {{%link href="/en/serverless/getting-started/introduction/" %}}**Catalyst Serverless**{{%/link%}}: * {{%link href="/en/serverless/help/functions/advanced-io/" %}}**Advanced I/O Function**{{%/link%}}: The Advanced I/O function is a component you can use to code your business logic in either {{%link href="/en/sdk/java/v1/overview/" %}}Java{{%/link%}}, {{%link href="/en/sdk/nodejs/v2/overview/" %}}Node.js{{%/link%}}, or {{%link href="/en/sdk/python/v1/overview/" %}}Python{{%/link%}} platform. It contains APIs that enable the user to report or check for an alien encounter in a city. {{%link href="/en/cloud-scale/getting-started/introduction/" %}}**Catalyst Cloud Scale**{{%/link%}}: * **Web Client**: The frontend of the application that is hosted on Catalyst through {{%link href="/en/cloud-scale/help/web-client-hosting/introduction/" %}}Web Client Hosting{{%/link%}}. * {{%link href="/en/cloud-scale/help/data-store/introduction/"%}}**Data Store**{{%/link%}}: To store the database of the cities where alien encounters have been reported. * {{%link href="/en/cloud-scale/help/zcql/introduction/" %}}**ZCQL**{{%/link%}}: To fetch data from the Data Store through querying. We will use the {{%link href="https://console.catalyst.zoho.com/" %}}Catalyst web console{{%/link%}} and the {{%link href="/en/cli/v1/cli-command-reference/" %}}Catalyst Command Line Interface{{%/link%}} (CLI) to build this application. You will be given the code for the files to be included in the function and client components in this tutorial. You will just need to copy the code given here and paste it into the appropriate files as directed. ### Application Architecture The Alien City application’s functioning can be described as follows: * **Reporting an alien encounter**<br />A user enters the name of a city where they experienced an alien encounter. If the city had already been reported previously, the client displays a message notifying the user of it. If the city has never been reported, the data will be added to a table in the Data Store identifying the city. * **Checking for an alien encounter**<br />A user checks for a record of an alien encounter in a particular city by providing its name. If a record of that city exists in the Data Store, the client will display a positive response. Otherwise, it will display a negative response. <br /> -------------------------------------------------------------------------------- title: "Prerequisites" description: "Create a single-page serverless web application using Catalyst Advanced I/O Function and Catalyst Data Store that allows you to report or look up alien encounters in a city." last_updated: "2026-03-18T07:41:08.670Z" source: "https://docs.catalyst.zoho.com/en/tutorials/alien-city/nodejs/prerequisites/" service: "All Services" related: - Catalyst CLI Documentation (/en/cli/v1/cli-command-reference/) -------------------------------------------------------------------------------- # Prerequisites Before you begin building the application, you must have the following prerequisites installed on your system: 1. {{%link href="/en/cli/v1/cli-command-reference/" %}}**Catalyst CLI**{{%/link%}}<br />Catalyst CLI contains a host of tools that enable you to initialize, develop, test, and deploy the components of your application from your local machine. We will be working with Catalyst CLI in this tutorial.<br /><br />You must perform the following actions: * **Install Catalyst CLI**: Catalyst CLI is installed through NPM. You must therefore have NPM and Node.js installed on your system before you install the CLI. Refer to the {{%link href="/en/getting-started/installing-catalyst-cli/" %}}Install Catalyst CLI help page{{%/link%}} for details on the pre-requisites and the steps to install it. * **Log in to Catalyst CLI**: After you install Catalyst CLI, you must authenticate the CLI with your Catalyst account before using it. Refer to the {{%link href="/en/cli/v1/login/login-from-cli/" %}}CLI Login help page{{%/link%}} for the steps to login from Catalyst CLI and the various options available for it. 2. **Any IDE tool for Node.js function and client code development**<br />You can use any IDE to work with the Advanced I/O function and the client code. Some popular choices include Visual Studio Code, IntelliJ IDEA, Eclipse, and Sublime Text. Download and install an IDE of your choice on your system. {{%info image="/images/tutorials/todo-list/vscode.png"%}}If you are a Visual Studio Code IDE user, you can install the {{%bold%}}Catalyst Tools{{%/bold%}} extension, and use your IDE itself in place of the CLI. You can find more details about the Catalyst VS Code extension from this {{%link href="/en/catalyst-extensions/vs-code-extension/introduction/" %}}help section{{%/link%}}.{{%/info%}} -------------------------------------------------------------------------------- title: "Create a Project" description: "Create a single-page serverless web application using Catalyst Advanced I/O Function and Catalyst Data Store that allows you to report or look up alien encounters in a city." last_updated: "2026-03-18T07:41:08.670Z" source: "https://docs.catalyst.zoho.com/en/tutorials/alien-city/nodejs/create-project/" service: "All Services" related: - Catalyst Console (/en/getting-started/catalyst-projects/) -------------------------------------------------------------------------------- # Create a Project Let’s {{%link href="/en/getting-started/catalyst-projects/#creating-a-catalyst-project" %}}create a Catalyst project{{%/link%}} from the Catalyst console. 1. Log in to the {{%link href="https://console.catalyst.zoho.com/baas/index" %}}Catalyst console{{%/link%}} and click **Create New Project**. <br /> 2. Enter the project’s name as "**AlienCity**" in the pop-up window, and click **Create**. <br /> Your project will be created then opened. You can access the project later, by clicking **Access Project**. <br /> <br /> -------------------------------------------------------------------------------- title: "Create a Table" description: "Create a single-page serverless web application using Catalyst Advanced I/O Function and Catalyst Data Store that allows you to report or look up alien encounters in a city." last_updated: "2026-03-18T07:41:08.671Z" source: "https://docs.catalyst.zoho.com/en/tutorials/alien-city/nodejs/create-table/" service: "All Services" related: - Data Store (/en/cloud-scale/help/data-store/introduction/) -------------------------------------------------------------------------------- # Create a Table Let’s now create a table in the Data Store of the **AlienCity** project. This table is used to store records of city names where aliens were sighted. To create a table: 1. Navigate to the *Cloud Scale* section of the console, then click **Start Exploring**. <br /> 2. Navigate to **Data Store** under *Storage* and click **Create a New Table**. <br /> 3. Enter the table’s name as "**AlienCity**" and click **Create**. <br /> {{%note%}}{{%bold%}}Note:{{%/bold%}} Ensure that you enter the name exactly as instructed, because the application's code contains the same name.{{%/note%}} The table is now created. Next, let’s create a column in the table to store the names of the cities. 1. Click **New Column** in the *Schema View* section for the table. <br /> 2. Enter the column’s name as "**CityName**". Select the data type as **Var Char** and enter the max length as "**100**". Click the **Is Unique** toggle switch to enable it. <br /> You can learn about the various data types supported by Catalyst, as well as the other properties of a column, from the {{%link href="/en/cloud-scale/help/data-store/columns/" %}}Data Store help page{{%/link%}}. {{%note%}}{{%bold%}}Note:{{%/bold%}} Ensure that you enter the name exactly as instructed, because the application's code contains the same name.{{%/note%}} 3. Click **Create**. The column is now created and listed in the *Schema View* section. <br /> <br /> -------------------------------------------------------------------------------- title: "Initialize the Project" description: "Create a single-page serverless web application using Catalyst Advanced I/O Function and Catalyst Data Store that allows you to report or look up alien encounters in a city." last_updated: "2026-03-18T07:41:08.671Z" source: "https://docs.catalyst.zoho.com/en/tutorials/alien-city/nodejs/initialize-project/" service: "All Services" related: - Initialize CLI Resources (/en/cli/v1/initialize-resources/introduction/) - Project Directory Structure (/en/cli/v1/project-directory-structure/introduction/) -------------------------------------------------------------------------------- # Initialize the Project from the CLI You can now begin working on your Catalyst project from the CLI. The first step is to initialize the project in an empty directory. This will be the home directory of your project and all of the project files will be saved in it. You can learn more about this from the {{%link href="https:/en/cli/v1/project-directory-structure/introduction/" %}}Project Directory Structure help page{{%/link%}}. You can learn about initializing a project in detail from the {{%link href="/en/cli/v1/initialize-resources/introduction/" %}}CLI help documentation{{%/link%}}. For the Alien City application, we will initialize the client and the {{%link href="/en/serverless/help/functions/advanced-io/" %}}Advanced I/O function{{%/link%}}. The Advanced I/O function will be initialized in the {{%link href="/en/sdk/python/v1/overview/" %}}Python{{%/link%}} platform. However, as mentioned {{%link href="/en/tutorials/alien-city/python/introduction" %}}earlier{{%/link%}}, you can also initialize it in the {{%link href="/en/sdk/java/v1/overview/"%}}Java{{%/link%}} or {{%link href="/en/sdk/nodejs/v2/overview/"%}}Node.js{{%/link%}} platforms. 1. Create a folder for the project on your local machine and navigate to it from the terminal. 2. Initialize a project by executing the following command from that directory: {{%cli%}}catalyst init {{%/cli%}} 3. Navigate using the **arrow keys** and select your preferred portal and press the **Enter** key. If you have no other organizations associated with the account, then the default one will be selected automatically. <br /> You can find out more about Catalyst's multi-org portal feature from this {{%link href="/en/getting-started/catalyst-organizations/#access-the-multi-org-portal" %}}help document{{%/link%}}. 4. The CLI will now ask you to associate a Catalyst project with the directory. Associate it with the project that we created earlier from the console. Select **AlienCity** from the list and press **Enter**. <br /> 5. Select **Client** and **Functions** using the **space-bar**, then press the **Enter** key to initialize. <br /> 6. The CLI will initiate the function setup. Select **AdvancedIO** as the function type. <br /> 7. Select the latest runtime of **NodeJS** as the programming environment. <br /> 8. Enter "**alien_city_function**" as the package name and "**index.js**" as the entry point, then press **Enter**. You can also just press **Enter** to use the default names generated by Catalyst, or enter any name of your preference. <br /> 9. The CLI will now initiate the client set up. Select **Basic web app** as your client type. <br /> 10. Enter "**ALcity**" as the name for the client package and press **Enter**. You can also enter any name you prefer. <br /> The client directory will be created in the standard structure. Catalyst initialization is now complete. Your {{%link href="/en/cli/v1/project-directory-structure/introduction/" %}}project directory{{%/link%}} is now set up with the client directory and the functions directory along with configuration files and dependencies. The project directory also contains the {{%link href="/en/cli/v1/project-directory-structure/catalyst-json/" %}}{{%badge%}}catalyst.json{{%/badge%}}{{%/link%}} configuration file and a hidden {{%badge%}}.catalystrc{{%/badge%}} file. This is the structure of the AlienCity project’s directory, if the Advanced I/O function is of the Python platform, and the client is set up as a Basic web app. <br /> <br /> -------------------------------------------------------------------------------- title: "Configure the Advanced I/O Function" description: "Create a single-page serverless web application using Catalyst Advanced I/O Function and Catalyst Data Store that allows you to report or look up alien encounters in a city." last_updated: "2026-03-18T07:41:08.671Z" source: "https://docs.catalyst.zoho.com/en/tutorials/alien-city/nodejs/configure-advio-function/" service: "All Services" related: - Functions (/en/serverless/help/functions/introduction/) - Advanced I/O Functions (/en/serverless/help/functions/advanced-io/) - Functions Directory Structure (/en/cli/v1/project-directory-structure/functions-directory/) -------------------------------------------------------------------------------- # Configure the Advanced I/O Function Let's begin coding the Alien City application by configuring the function component. The Node.js function directory ( {{%badge%}}{{%link href="/en/cli/v1/project-directory-structure/functions-directory/"%}} functions/alien_city_function {{%/link%}}{{%/badge%}} ) contains the following files: * The {{%badge%}}index.js{{%/badge%}} main function file * The {{%badge%}}catalyst-config.json{{%/badge%}} configuration file * Node modules * {{%badge%}}{{%link href="https://docs.npmjs.com/files/package.json"%}}package.json{{%/link%}}{{%/badge%}} and {{%badge%}}{{%link href="https://docs.npmjs.com/configuring-npm/package-lock-json.html"%}}package-lock.json{{%/link%}}{{%/badge%}} dependency files You will be adding code in the {{%badge%}}index.js{{%/badge%}} main function file. The two APIs in the Advanced I/O function that handle the routing between the server and the Data Store are: * **{{%badge%}}GET /alien{{%/badge%}}**: To check whether aliens are present in a city * **{{%badge%}}POST /alien{{%/badge%}}**: To report an alien presence in a city <br> #### Install Express Node.js Framework For the Node.js function, you will be using the {{%link href="https://expressjs.com/"%}}Express Node.js framework{{%/link%}}. To import the Express package in the code, you must install the Express dependencies in your system. To install {{%badge%}}Express.js{{%/badge%}} in your local machine, navigate to the Node function's directory ({{%badge%}}functions/alien_city_function{{%/badge%}}) in your terminal and execute the following command: {{%cli%}}npm install express --save{{%/cli%}} This will install the Express module and save the dependencies. This information will also be updated in the package.json file. Let's now add the code in the function file. <br> Copy the code given below and paste it in the {{%badge%}}index.js{{%/badge%}} in the {{%badge%}}functions/alien_city_function{{%/badge%}} directory of your project, and save the file. You can use any IDE of your choice to work with the application's files. <br> <br> {{%note%}}{{%bold class="bold-primary"%}}Note:{{%/bold%}} Please go through the code in this section to make sure you fully understand it. {{%/note%}} {{% panel_with_adjustment class="language-javascript line-numbers" header="index.js" footer="button" scroll="set-scroll" %}}'use strict'; var express = require('express'); var app = express(); var catalyst = require('zcatalyst-sdk-node'); app.use(express.json()); const tableName = 'AlienCity'; // The table created in the Data Store const columnName = 'CityName'; // The column created in the table // The POST API that reports the alien encounter for a particular city app.post('/alien', (req, res) => { var cityJson = req.body; console.log(cityJson); // Initializing Catalyst SDK var catalystApp = catalyst.initialize(req); // Queries the Catalyst Data Store table and checks whether a row is present for the given city getDataFromCatalystDataStore(catalystApp, cityJson.city_name).then(cityDetails => { if (cityDetails.length == 0) { // If the row is not present, then a new row is inserted console.log("Alien alert!"); //Written to the logs. You can view this log from Logs under the Monitor section in the console var rowData = {} rowData[columnName] = cityJson.city_name; var rowArr = []; rowArr.push(rowData); // Inserts the city name as a row in the Catalyst Data Store table catalystApp.datastore().table(tableName).insertRows(rowArr).then(cityInsertResp => { res.send({ "message": "Thanks for reporting!" }); }).catch(err => { console.log(err); sendErrorResponse(res); }) } else { // If the row is present, then a message is sent indicating duplication res.send({ "message": "Looks like you are not the first person to encounter aliens in this city! Someone has already reported an alien encounter here!" }); } }).catch(err => { console.log(err); sendErrorResponse(res); }) }); // The GET API that checks the table for an alien encounter in that city app.get('/alien', (req, res) => { var city = req.query.city_name; // Initializing Catalyst SDK var catalystApp = catalyst.initialize(req); // Queries the Catalyst Data Store table and checks whether a row is present for the given city getDataFromCatalystDataStore(catalystApp, city).then(cityDetails => { if (cityDetails.length == 0) { res.send({ "message": "Hurray! No alien encounters in this city yet!", "signal": "negative" }); } else { res.send({ "message": "Uh oh! Looks like there are aliens in this city!", "signal": "positive" }); } }).catch(err => { console.log(err); sendErrorResponse(res); }) }); /** * Checks whether an alien encounter is already reported for the given city by querying the Data Store table * @param {*} catalystApp * @param {*} cityName */ function getDataFromCatalystDataStore(catalystApp, cityName) { return new Promise((resolve, reject) => { // Queries the Catalyst Data Store table catalystApp.zcql().executeZCQLQuery("SELECT * FROM AlienCity WHERE CityName = '" + cityName + "'").then(queryResponse => { resolve(queryResponse); }).catch(err => { reject(err); }) }); } /** * Sends an error response * @param {*} res */ function sendErrorResponse(res) { res.status(500); res.send({ "error": "Internal server error occurred. Please try again in some time." }); } module.exports = app; {{% /panel_with_adjustment %}} The functions directory is now configured. We will discuss the architecture of the function and the client in the next section. -------------------------------------------------------------------------------- title: "Configure the Client" description: "Create a single-page serverless web application using Catalyst Advanced I/O Function and Catalyst Data Store that allows you to report or look up alien encounters in a city." last_updated: "2026-03-18T07:41:08.671Z" source: "https://docs.catalyst.zoho.com/en/tutorials/alien-city/nodejs/configure-client/" service: "All Services" related: - Client Directory Structure (/en/cli/v1/project-directory-structure/client-directory/) - Web Client Hosting (/en/cloud-scale/help/web-client-hosting/introduction/) -------------------------------------------------------------------------------- # Configure the Client Now, let's configure the client component. The {{%link href="/en/cli/v1/project-directory-structure/client-directory/"%}}client directory{{%/link%}} contains: * The {{%badge%}}index.html{{%/badge%}} file that contains the HTML code for the front-end application * The {{%badge%}}main.css{{%/badge%}} file that contains the CSS code for the front-end application * The {{%badge%}}main.js{{%/badge%}} file that contains the JavaScript code * The {{%badge%}}client-package.json{{%/badge%}} configuration file <br> We will be coding {{%badge%}}index.html{{%/badge%}} and {{%badge%}}main.js{{%/badge%}}. <br> <br> {{%note%}}{{%bold class="bold-primary"%}}Note:{{%/bold%}} Please go through the code in this section to make sure you fully understand it.{{%/note%}} <br> Copy the code below and paste it into the respective files located in the {{%badge%}}client/directory{{%/badge%}} of your project using an IDE and save the files. <br> <br> {{% panel_with_adjustment header="index.html" footer="button" scroll="set-scroll" class="language-xml line-numbers" %}}&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset="utf-8" /&gt; &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt; &lt;title&gt;AlientCityAppClient&lt;/title&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt; &lt;link rel="stylesheet" type="text/css" media="screen" href="main.css" /&gt; &lt;link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"&gt; &lt;script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"&gt;&lt;/script&gt; &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"&gt; &lt;/script&gt; &lt;script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"&gt; &lt;/script&gt; &lt;script src="main.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;br&gt; &lt;br&gt; &lt;center&gt; &lt;h1&gt;ALIEN CITY&lt;/h1&gt; &lt;/center&gt; &lt;div class="container"&gt; &lt;ul class="nav nav-tabs" id="myTab" role="tablist"&gt; &lt;li class="nav-item"&gt; &lt;a class="nav-link active" id="check-tab" data-toggle="tab" href="#check" role="tab" aria-controls="check" aria-selected="true"&gt;Check My City&lt;/a&gt; &lt;/li&gt; &lt;li class="nav-item"&gt; &lt;a class="nav-link" id="report-tab" data-toggle="tab" href="#report" role="tab" aria-controls="report" aria-selected="false"&gt;Report Alien Encounter&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;div class="tab-content" id="myTabContent"&gt; &lt;div class="tab-pane fade show active" id="check" role="tabpanel" aria-labelledby="check-tab"&gt; &lt;br&gt; &lt;br&gt; &lt;form&gt; &lt;div class="form-group"&gt; &lt;label for="city-get-input"&gt;&lt;b&gt;Check if your city has aliens:&lt;/b&gt;&lt;/label&gt; &lt;input type="text" class="form-control" id="city-get-input" aria-describedby="checkCity" placeholder="Enter City Name"&gt; &lt;/div&gt; &lt;button type="submit" class="btn btn-primary" onclick="getAlienEncounter();return false;"&gt;Check&lt;/button&gt; &lt;/form&gt; &lt;br&gt; &lt;br&gt; &lt;div id="result-container"&gt; &lt;div id="result-text"&gt; &lt;/div&gt; &lt;br&gt; &lt;div id="result-image"&gt; &lt;/div&gt; &lt;/div&gt; &lt;div id="loader" style="display: none;"&gt; &lt;div class="spinner-border" role="status"&gt; &lt;span class="sr-only"&gt;Loading...&lt;/span&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="tab-pane fade" id="report" role="tabpanel" aria-labelledby="report-tab"&gt; &lt;br&gt; &lt;br&gt; &lt;form&gt; &lt;div class="form-group"&gt; &lt;div class="city-post-input"&gt; &lt;label for="exampleInputEmail1"&gt;&lt;b&gt;Enter the name of the city where you encountered an alien:&lt;/b&gt;&lt;/label&gt; &lt;input type="text" class="form-control" id="city-post-input" aria-describedby="cityPost" placeholder="Enter City Name"&gt; &lt;/div&gt; &lt;/div&gt; &lt;button type="submit" class="btn btn-primary" onclick="postAlienEncounter();return false;"&gt;Report&lt;/button&gt; &lt;/form&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; {{% /panel_with_adjustment %}} {{% panel_with_adjustment class="language-javascript line-numbers" header="main.js" footer="button" scroll="set-scroll" %}}/* Fires an API call to the server and adds the reported city as an alien city */ function postAlienEncounter() { var city = $("#city-post-input").val(); // Fires an Ajax call to the URL defined in the index.js function file // All URLs to the Advanced I/O function will be of the pattern: /server/{function_name}/{url_path} $.ajax({ url: "/server/alien_city_function/alien", type: "post", contentType: "application/json", data: JSON.stringify({ "city_name": city }), success: function (data) { alert(data.message); }, error: function (error) { alert(error.message); } }); } /** * Fires an API call to the server to check whether the given city is alien city or not */ function getAlienEncounter() { showLoader(); var positive = "https://media.giphy.com/media/Y1GYiLui9NHcxVKhdo/giphy.gif"; var negative = "https://media.giphy.com/media/fsPcMdeXPxSP6zKxCA/giphy.gif"; var city = $("#city-get-input").val(); // Fires an Ajax call to the URL defined in the index.js function file // All URLs to the Advanced I/O function will be of the pattern: /server/{function_name}/{url_path} $.ajax({ url: "/server/alien_city_function/alien?city_name=" + city, type: "get", success: function (data) { console.log(data); $("#result-text").text(""); $("#result-text").text(data.message); var imagesrc = negative; if (data.signal == 'positive') { imagesrc = positive; } $("#result-image").html(""); $("#result-image").html("&lt;img src='" + imagesrc + "' /&gt;"); hideLoader(); }, errror: function (error) { alert(error.message); } }); } function showLoader() { $("#result-container").hide(); $("#loader").show(); } function hideLoader() { $("#loader").hide(); $("#result-container").show(); } {{% /panel_with_adjustment %}} <br> The client directory is now configured. Let us quickly go through the working of the function and client components of the application: {{%list class="bold"%}} 1. **GET operation** <br> * When you enter a city name in the client to check for a record of previous alien encounter, the {{%badge%}}onClick{{%/badge%}} event for the **Check** button in {{%badge%}}index.html{{%/badge%}} triggers the {{%badge%}}getAlienEncounter(){{%/badge%}} function defined in {{%badge%}}main.js{{%/badge%}}. <br> * This fires an Ajax call to the URL route defined in the Advanced I/O function. The {{%badge%}}GET{{%/badge%}} API defined in {{%badge%}}index.js{{%/badge%}} then invokes the {{%badge%}}getDataFromCatalystDataStore{{%/badge%}} function and passes the request query. <br> * This function searches for the data in the *AlienCity* table in the Data Store by executing a ZCQL query. <br> * If a record matching the city name is found in the table, a {{%badge%}}positive{{%/badge%}} signal is sent as the response. Otherwise, a {{%badge%}}negative{{%/badge%}} signal is sent as the response. <br> * The client then displays the message that matches the response. A GIF matching the response defined in {{%badge%}}main.js{{%/badge%}} is also displayed. {{%/list%}} <br> {{%list class="bold"%}} 2. **POST operation** <br> * When you enter a city name in the client to report an alien encounter, the {{%badge%}}onClick{{%/badge%}} event for the **Report** button in {{%badge%}}index.html{{%/badge%}} triggers the {{%badge%}}postAlienEncounter(){{%/badge%}} function defined in {{%badge%}}main.js{{%/badge%}}. <br> * This fires an Ajax call to the URL route defined in the Advanced I/O function. The {{%badge%}}POST{{%/badge%}} API defined in {{%badge%}}index.js{{%/badge%}} then invokes the {{%badge%}}getDataFromCatalystDataStore{{%/badge%}} function and passes a request query to check if a record with the same city name already exists. <br> * This function searches for the data in the *AlienCity* table in the Data Store by executing a ZCQL query. If the record already exists, a response is sent, which enables the client to display an appropriate message to the user. <br> * If there are no records for the city name, a new row is created in the *AlienCity* table for the city name entered by the user. A pop-up box is displayed in the client confirming the insertion of the record in the Data Store. An appropriate message is also pushed to the logs which can be checked from *Logs* under the *Monitor* section in the console. {{%/list%}} -------------------------------------------------------------------------------- title: "Test the Application" description: "Create a single-page serverless web application using Catalyst Advanced I/O Function and Catalyst Data Store that allows you to report or look up alien encounters in a city." last_updated: "2026-03-18T07:41:08.672Z" source: "https://docs.catalyst.zoho.com/en/tutorials/alien-city/nodejs/test-application/" service: "All Services" related: - Serve CLI Resources (/en/cli/v1/serve-resources/introduction/) -------------------------------------------------------------------------------- # Test the Application Before you deploy the application to the remote console, you can {{%link href="/en/cli/v1/serve-resources/introduction/" %}}test the application{{%/link%}} on a local server and check if everything works fine using the Catalyst CLI. To serve the Catalyst project locally, execute the following command from your project directory: {{%cli%}}catalyst serve{{%/cli%}} This Alien City application is now served at default port 3000. The local endpoint URLs of the components are displayed. {{%note%}}{{%bold%}}Note:{{%/bold%}} Every time you access the home page or any of the sub-pages of your client, or the function, the CLI will display a live log of the URL accessed, along with the HTTP request method.{{%/note%}} <br /> You can now open the client component’s local URL in a browser to access the Alien City application. <br /> Let’s test the application by entering a city’s name and checking for the history of an alien encounter in the city. Since we have not reported an alien encounter in a city yet, the result should be negative. Enter a city name in the text box and click **Check**. <br /> Since a matching record for this city is not found in the Data Store, the client displays a negative response. <br /> Now, let’s report an alien encounter. Click the *Report Alien Encounter* tab. Enter a city name and click **Report**. We have entered "**Amsterdam**" in our application. <br /> The application will display a pop-up box confirming that the data is added to the Data Store. <br /> You can verify this by opening your Catalyst console and navigating to **Data Store** under *Storage* **>** *CloudScale*. Click the **Data View** tab to view the record that was just inserted. <br /> Next, let's search for this city in the client and check if it fetches this record from the Data Store. Click *Check My City* in the client application and enter the name of the city that you just reported. Here, we enter "**Amsterdam**". Click **Check**. <br /> The client displays a positive response. You can also check if the client displays the duplication message by reporting the same city again. <br /> If this setup is working correctly, we can deploy the application to production. <br /> -------------------------------------------------------------------------------- title: "Deploy the Project" description: "Create a single-page serverless web application using Catalyst Advanced I/O Function and Catalyst Data Store that allows you to report or look up alien encounters in a city." last_updated: "2026-03-18T07:41:08.672Z" source: "https://docs.catalyst.zoho.com/en/tutorials/alien-city/nodejs/deploy-project/" service: "All Services" related: - Deploy CLI Resources (/en/cli/v1/deploy-resources/introduction/) - Web Client Hosting (/en/cloud-scale/help/web-client-hosting/introduction/') -------------------------------------------------------------------------------- # Deploy the Project To {{%link href="/en/cli/v1/deploy-resources/introduction/" %}}deploy your Catalyst project{{%/link%}} from the CLI, run the following command in your terminal from your project directory: {{%cli%}}catalyst deploy{{%/cli%}} The function is deployed first, followed by the client component. The production URLs of the components are displayed. <br /> You can now open the client component’s URL in a browser to access the deployed application. Alien City can be accessed now from its {{%link href="/en/cloud-scale/help/web-client-hosting/key-concepts/#default-web-application-url" %}}web app URL{{%/link%}}. <br />