Full Tutorial with Node.js and Express

Implementation Time: 5 minutes

Prerequisites

To get started, you'll need the following:

  • Node.js and NPM
  • Git

Step 1: Clone the example repo

We've created a repository of example API codebases in Node.js. Clone the repo to your local machine:

git clone https://github.com/nanoapi-io/nodejs-example-apis.git && cd nodejs-example-apis

For this tutorial, we will be exploring the express/basic example.

cd express/basic

Step 2: Install NanoAPI

You can see more about this on the Getting Started page.

npm install -g @nanoapi.io/napi

Step 3: Initialize the CLI

napi init

Step 4: Run the UI

napi ui

Step 5: Group the endpoints in the UI

The NanoAPI UI allows you to view, move, and group the endpoints in your codebase. You can group the endpoints by clicking on the 3 dots to open the modal, then specifying the group name.

Grouping Endpoints

Note: Because of a bug in the UI, you will need to click the pencil icon to save the group name. We are working on this.

Step 6: Sync the changes

Once you exit the modal, you will see the project is out of sync with your source code in the bottom middle of the screen. Click on the orange sync button to update the changes.

Syncing Changes

Step 7: Split the codebase

Once the changes are synced, you can split the codebase by clicking on the build button in the bottom middle of the screen.

Splitting the Codebase

Alternatively, you can run the following command in your terminal:

napi split

Conclusion

You've now split your codebase into smaller, more manageable pieces! You can now run the split codebases as you would the original one.

If you have any questions, errors, or need help, feel free to reach out to us on Github by opening an issue.