|
1 |
| -# napi |
| 1 | +<p align="center"> |
| 2 | + <img src="https://raw.githubusercontent.com/nanoapi-io/napi/refs/heads/main/media/logo-192.png" alt="NanoAPI Logo" width="200" /> |
| 3 | +</p> |
2 | 4 |
|
3 |
| -Powerful CLI + UI for inspecting and refactoring an API codebase in any language and web framework. |
| 5 | +# `napi` - Next-Level Visual Tooling For API Codebases |
4 | 6 |
|
5 |
| -> This project is under ongoing development. Check the [status section](#status) for more information on supported languages and frameworks. |
| 7 | +`napi` is a versatile tool designed to automatically refactor large microlith codebases into smaller, more manageable microservices. With both a powerful CLI and an intuitive UI, `napi` is compatible with all major CI/CD platforms, allowing seamless integration into your development and deployment pipelines. |
6 | 8 |
|
7 |
| -## Features |
| 9 | + |
8 | 10 |
|
9 |
| -- **Inspect**: Analyze your codebase and understand the API endpoints, middleware, and other API-specific code |
10 |
| -- **Refactor**: Refactor your codebase into smaller, more manageable pieces through the UI or annotations |
11 |
| -- **Build**: Transform your codebase into smaller, more manageable pieces at build time |
| 11 | +## Features |
12 | 12 |
|
13 |
| -## Motivation |
| 13 | +- **🔍 Inspect**: Analyze your codebase to identify API endpoints, middleware, and other API-specific components. |
| 14 | +- **📝 Refactor**: Split your monolith into microservices using the UI or annotations in the code. |
| 15 | +- **🏗️ Build**: Generate modular microservices ready for deployment. |
| 16 | +- **⚙️ Integrate**: Use CLI commands compatible with all CI/CD workflows for automation. |
14 | 17 |
|
15 |
| -- Quickly refactor large/monolith codebases into smaller, more manageable pieces at build time |
16 |
| -- Increase robustness by reducing the downtime through isolating |
17 |
| -- Don't waste time with consultants or contractors to refactor your codebase |
18 |
| -- Better understand what your codebase is doing today |
19 |
| -- Create a new development paradigm (develop monolith, deploy microservice) for projects moving fast |
| 18 | +## Why `napi`? |
20 | 19 |
|
21 |
| -To understand better what we mean by the above, please take a look at our [documentation](https://nanoapi.io/docs/nanoapi). |
| 20 | +- Simplifies the process of breaking down monoliths into microservices. |
| 21 | +- Reduces dependency on consultants or contractors for complex refactoring tasks. |
| 22 | +- Enhances codebase understanding and robustness. |
| 23 | +- Accelerates development with a "develop monolith, deploy microservice" approach. |
22 | 24 |
|
23 |
| -## Design goals |
| 25 | +## Supported Languages and Frameworks |
24 | 26 |
|
25 |
| -- Zero configuration |
26 |
| -- Support for all languages and web frameworks |
27 |
| -- Auto-detect endpoint definitions, middleware, and other API-specific code without manual annotations |
28 |
| -- Clean, simple, and easy to use UI |
| 27 | +`napi` aims to support all major programming languages and web frameworks. Here is the current status: |
29 | 28 |
|
30 |
| -## Quick Start |
| 29 | +| Language/Framework | Status | Related Issues | |
| 30 | +| ------------------ | -------------- | --------------------------------------------------- | |
| 31 | +| JavaScript | ✅ Supported | Early Core Feature | |
| 32 | +| TypeScript | ✅ Supported | Early Core Feature | |
| 33 | +| Python | ✅ Supported | [#28](https://github.com/nanoapi-io/napi/issues/28) | |
| 34 | +| PHP | 🚧 In Progress | [#30](https://github.com/nanoapi-io/napi/issues/30) | |
| 35 | +| C# | 🚧 In Progress | [#31](https://github.com/nanoapi-io/napi/issues/31) | |
| 36 | +| Java | 🚧 In Progress | [#32](https://github.com/nanoapi-io/napi/issues/32) | |
| 37 | +| C | 🚧 In Progress | Not Tracked Yet | |
| 38 | +| C++ | 🚧 In Progress | Not Tracked Yet | |
31 | 39 |
|
32 |
| -Ensure you have NodeJS >= 18 and NPM installed on your machine. |
| 40 | +For the latest updates, visit our [project board](https://github.com/nanoapi-io/napi/projects). |
33 | 41 |
|
34 |
| -```bash |
35 |
| -$ npm install -g @nanoapi.io/napi |
36 |
| -``` |
37 |
| - |
38 |
| -To open the UI for your codebase, run the following commands: |
39 |
| - |
40 |
| -```bash |
41 |
| -$ napi init |
42 |
| -$ napi ui |
43 |
| -``` |
| 42 | +## Documentation |
44 | 43 |
|
45 |
| -## Examples |
| 44 | +Comprehensive documentation is available on our [documentation website](https://nanoapi.io/docs/nanoapi). |
46 | 45 |
|
47 |
| -We are building a collection of example API repositories in each language so you can explore the project. This list will grow over time. |
48 |
| - |
49 |
| -[examples](/examples/README.md) |
| 46 | +## Quick Start |
50 | 47 |
|
51 |
| -## Usage |
| 48 | +Ensure you have Node.js (>=18) and npm installed. |
52 | 49 |
|
53 | 50 | ### Installation
|
54 | 51 |
|
55 |
| -We are working on a binary release, but for now, you can install it via this github repository: |
56 |
| - |
57 | 52 | ```bash
|
58 |
| -$ git clone https://github.com/nanoapi-io/napi.git |
59 |
| -$ cd napi |
60 |
| -$ npm install |
| 53 | +npm install -g @nanoapi.io/napi |
61 | 54 | ```
|
62 | 55 |
|
63 |
| -### Usage |
64 |
| - |
65 |
| -To open the UI and inspect your codebase, run the following commands: |
| 56 | +### Getting Started |
66 | 57 |
|
67 | 58 | ```bash
|
68 |
| -$ napi init |
69 |
| -$ napi ui |
| 59 | +napi init |
| 60 | +napi ui |
70 | 61 | ```
|
71 | 62 |
|
72 |
| -### Commands: |
| 63 | +This will initialize a new NanoAPI project and open the UI for inspecting and refactoring your codebase. |
73 | 64 |
|
74 |
| -``` |
75 |
| - init Initialize the NanoAPI project |
76 |
| - ui [entrypoint] Inspect the codebase and understand the API endpoints, middleware, and other API-specific code |
77 |
| - split <entrypoint> Transform the codebase into smaller, more manageable pieces at build time |
78 |
| -``` |
| 65 | +## CLI Usage |
79 | 66 |
|
80 |
| -## Using the UI |
| 67 | +`napi` provides the following commands: |
81 | 68 |
|
82 |
| -The easiest way to refactor your API endpoints is to do it through our UI. You can group endpoints and create builds from here. |
| 69 | +```bash |
| 70 | +init Initialize the NanoAPI project |
| 71 | +ui [entrypoint] Open the UI to inspect and refactor the codebase |
| 72 | +split <entrypoint> Transform the codebase into microservices |
| 73 | +napi <platform> annotate <entrypoint> [--token=<key>] Automatically generate annotations for the codebase via OpenAI |
| 74 | +``` |
| 75 | + |
| 76 | +For more detailed information about the CLI and what each command does, refer to our [CLI guide](https://nanoapi.io/docs/cli/). |
83 | 77 |
|
84 |
| -## Building with Annotations |
| 78 | +## Refactoring with Annotations |
85 | 79 |
|
86 |
| -You can also refactor your codebase by adding annotations to your code. Here is an example of how you can do it: |
| 80 | +You can use annotations to specify how to split your code. Here’s an example: |
87 | 81 |
|
88 | 82 | ```typescript
|
89 | 83 | // src/api.js
|
90 | 84 |
|
91 |
| -import * as express from "express"; |
92 |
| - |
93 |
| -import * as service from "./service.js"; |
94 |
| - |
95 |
| -const app = express(); |
96 |
| -const port = 3000; |
97 |
| - |
98 |
| -app.use(express.json()); |
99 |
| - |
100 |
| -// @nanoapi endpoint:/api/v2/maths/time method:GET group:Time |
101 |
| -app.get("/api/v2/maths/time", (req, res) => { |
102 |
| - const result = service.time(); |
103 |
| - return res.json({ |
104 |
| - result, |
105 |
| - }); |
106 |
| -}); |
107 |
| - |
108 |
| -// @nanoapi endpoint:/api/v2/maths/addition method:POST group:Maths |
109 |
| -app.post("/api/v2/maths/addition", (req, res) => { |
110 |
| - const { body } = req; |
111 |
| - const result = service.addition(body.a, body.b); |
112 |
| - return res.json({ |
113 |
| - result, |
114 |
| - }); |
| 85 | +// @nanoapi endpoint:/api/v1/users method:GET group:Users |
| 86 | +app.get("/api/v1/users", (req, res) => { |
| 87 | + res.send("User data"); |
115 | 88 | });
|
116 | 89 |
|
117 |
| -// @nanoapi endpoint:/api/v2/maths/subtraction method:POST group:Maths |
118 |
| -app.post("/api/v2/maths/subtraction", (req, res) => { |
119 |
| - const { body } = req; |
120 |
| - const result = service.subtraction(body.a, body.b); |
121 |
| - return res.json({ |
122 |
| - result, |
123 |
| - }); |
124 |
| -}); |
125 |
| - |
126 |
| -app.listen(port, () => { |
127 |
| - console.log(`App listening on port: ${port}`); |
| 90 | +// @nanoapi endpoint:/api/v1/orders method:POST group:Orders |
| 91 | +app.post("/api/v1/orders", (req, res) => { |
| 92 | + res.send("Order created"); |
128 | 93 | });
|
129 | 94 | ```
|
130 | 95 |
|
131 |
| -## Output |
| 96 | +Running `napi split` will generate modular services based on these annotations. You'll have a `Users` service and an `Orders` service, each containing the respective endpoint. |
132 | 97 |
|
133 |
| -From the exmaple above, you will get the following output from running a build: |
134 |
| - |
135 |
| -```typescript |
136 |
| -// dist/Time/src/api.js |
| 98 | +## Using the UI |
137 | 99 |
|
138 |
| -import * as express from "express"; |
| 100 | +The UI provides an interactive interface to: |
139 | 101 |
|
140 |
| -import * as service from "./service.js"; |
| 102 | +- Group and organize endpoints. |
| 103 | +- Preview the generated microservices. |
| 104 | +- Export refactored code for deployment. |
141 | 105 |
|
142 |
| -const app = express(); |
143 |
| -const port = 3000; |
| 106 | + |
144 | 107 |
|
145 |
| -app.use(express.json()); |
| 108 | +## CI/CD Integration |
146 | 109 |
|
147 |
| -app.get("/api/v2/maths/time", (req, res) => { |
148 |
| - const result = service.time(); |
149 |
| - return res.json({ |
150 |
| - result, |
151 |
| - }); |
152 |
| -}); |
| 110 | +`napi` works seamlessly with CI/CD platforms like GitHub Actions, GitLab CI/CD, and Jenkins. For setup instructions, refer to our [CLI guide](https://nanoapi.io/docs/cli/). |
153 | 111 |
|
154 |
| -app.listen(port, () => { |
155 |
| - console.log(`App listening on port: ${port}`); |
156 |
| -}); |
157 |
| -``` |
| 112 | +## Contributing |
158 | 113 |
|
159 |
| -## Contributing and Development |
| 114 | +We welcome contributions from the community. Please read our [contributing guide](https://github.com/nanoapi-io/napi/blob/main/.github/CONTRIBUTING.md) for details on how to get involved. |
160 | 115 |
|
161 |
| -We welcome contributions from the community. Please read our [contributing guide](/.github/CONTRIBUTING.md) for more information. |
| 116 | +## License |
162 | 117 |
|
163 |
| -## Status |
| 118 | +`napi` is licensed under the [Sustainable Use License](https://github.com/nanoapi-io/napi/blob/main/LICENSE.md). |
164 | 119 |
|
165 |
| -This project is in the early stages of development. We are actively working on the project and will be releasing new features and improvements regularly, which may include a rewrite into a more efficient and generic language like Rust or Go. Please check our issues and project board for more information, and don't for. |
| 120 | +## Support |
166 | 121 |
|
167 |
| -- [x] Javascript support |
168 |
| -- [x] UI for configuration |
169 |
| -- [x] Typescript support |
170 |
| -- [x] Python support |
171 |
| -- [ ] PHP support |
172 |
| -- [ ] Java support |
173 |
| -- [ ] C# support |
174 |
| -- [ ] C support |
175 |
| -- [ ] C++ support |
| 122 | +<div align="center"> |
| 123 | + <p>For questions or issues, feel free to open an issue on GitHub or join us on our server on Discord.</p> |
| 124 | + <table> |
| 125 | + <tr> |
| 126 | + <td valign="center"> |
| 127 | + <a href="https://github.com/nanoapi-io/napi/issues/new/choose" target="_blank"> |
| 128 | + <img src="https://upload.wikimedia.org/wikipedia/commons/9/91/Octicons-mark-github.svg" alt="GitHub Logo" width="50" /> |
| 129 | + </a> |
| 130 | + </td> |
| 131 | + <td valign="center"> |
| 132 | + <a href="https://discord.gg/4ZaQ347ZmQ" target="_blank"> |
| 133 | + <img src="https://cdn.prod.website-files.com/6257adef93867e50d84d30e2/653714c1c2d8d50382c7df8a_636e0b5061df29d55a92d945_full_logo_blurple_RGB.svg" alt="Discord Logo" width="100" height="100" /> |
| 134 | + </a> |
| 135 | + </td> |
| 136 | + </tr> |
| 137 | + </table> |
| 138 | +</div> |
176 | 139 |
|
177 |
| -## On Donating |
| 140 | +## Donations |
178 | 141 |
|
179 | 142 | NanoAPI is a fair-source project. Because of this, we feel it would be unethical to keep any donations to ourselves. Instead, here is how we will handle donations:
|
180 | 143 |
|
|
0 commit comments