--- title: "Configure the functions directory" url: https://docs.catalyst.zoho.com/en/tutorials/todo-list/nodejs/configure-function/ description: "Build a Basic, React, or Angular to-do list web application using Catalyst Advanced I/O Function and Catalyst Data Store that enables you to note down tasks and delete them after they are done." last_updated: 2026-08-17T12:16:04Z service: All Services type: tutorial related_links: - name: "Advanced I/O Functions" url: /en/serverless/help/functions/advanced-io/ - name: "Functions Directory Structure" url: /en/cli/v1/project-directory-structure/functions-directory --- # Configure the Advanced I/O Function Next, we will begin coding the to-do list application by configuring the function component. The [function's directory](https://docs.catalyst.zoho.com/en/cli/v1/project-directory-structure/functions-directory), `functions/to\_do\_list\_function` contains: * The `index.js` main function file * The `catalyst-config.json` configuration file * Node modules * `[package.json](https://docs.npmjs.com/files/package.json)` and `[package-lock.json](https://docs.npmjs.com/configuring-npm/package-lock-json.html)` dependency files You will be adding code in the `index.js` file. The three APIs in the Advanced I/O function that handle the routing between the server and the Data Store are: * **GET /todo:** To obtain the to-do list items from the _TodoItems_ table in the Data Store * **POST /todo:** To create and save a new list item in the Data Store * **DELETE /todo:** To delete a list item from the Data Store #### Install Express Framework for Node.js We will need to use the [Express framework](https://expressjs.com/) to perform routing operations. To import the Express package in your function's code, you must install the Express dependency in your system. To install `Express.js` in your local machine, navigate to the function's home directory (`functions/to\_do\_list\_function`) in your terminal and execute the following command: ```sh npm install express --save ``` This will install the Express module and save the dependencies. ![catalyst_to_node_express_install](https://catalyst-docs-development.zohostratus.in/images/tutorials/todo-list/catalyst_to_node_express_install.webp) This information will also be updated in the `package.json` file. ![catalyst_todo_package_json](https://catalyst-docs-development.zohostratus.in/images/tutorials/todo-list/catalyst_todo_package_json.webp) Next, let's add the code in the function file. Copy the Node.js code and paste it in `index.js` in the `functions/to\_do\_list\_function` directory of your project, and save the file. You can use any IDE of your choice to work with the application's files. > **Note**: Please go through the code given in this section to ensure you fully understand it. We will discuss the architecture of the function and the client in the next section. **index.js** ```javascript const express = require('express'); const catalystSDK = require('zcatalyst-sdk-node'); const app = express(); app.use(express.json()); app.use((req, res, next) => { const catalyst = catalystSDK.initialize(req); res.locals.catalyst = catalyst; next(); }); //GET API. Get existing tasks if any from the server. app.get('/all', async (req, res) => { try { const { catalyst } = res.locals; const page = parseInt(req.query.page); const perPage = parseInt(req.query.perPage); const zcql = catalyst.zcql(); const hasMore = await zcql .executeZCQLQuery(`SELECT COUNT(ROWID) FROM TodoItems`) .then((rows) => parseInt(rows[0].TodoItems.ROWID) > page * perPage); const todoItems = await zcql .executeZCQLQuery( `SELECT ROWID,Notes FROM TodoItems LIMIT ${ (page - 1) * perPage + 1 },${perPage}` ) .then((rows) => rows.map((row) => ({ id: row.TodoItems.ROWID, notes: row.TodoItems.Notes })) ); res.status(200).send({ status: 'success', data: { todoItems, hasMore } }); } catch (err) { console.log(err); res.status(500).send({ status: 'failure', message: "We're unable to process the request." }); } }); // POST API. Contains the logic to create a task app.post('/add', async (req, res) => { try { const { notes } = req.body; const { catalyst } = res.locals; const table = catalyst.datastore().table('TodoItems'); const { ROWID: id } = await table.insertRow({ Notes:notes }); res.status(200).send({ status: 'success', data: { todoItem: { id, notes } } }); } catch (err) { console.log(err); res.status(500).send({ status: 'failure', message: "We're unable to process the request." }); } }); // DELETE API. Contains the logic to delete a task. app.delete('/:ROWID', async (req, res) => { try { const { ROWID } = req.params; const { catalyst } = res.locals; const table = catalyst.datastore().table('TodoItems'); await table.deleteRow(ROWID); res.status(200).send({ status: 'success', data: { todoItem: { id: ROWID } } }); } catch (err) { console.log(err); res.status(500).send({ status: 'failure', message: "We're unable to process the request." }); } }); module.exports = app; ``` The functions directory is now configured.