apitally 0.15.0 → 0.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -7,8 +7,8 @@
7
7
  </picture>
8
8
  </a>
9
9
  </p>
10
- <p align="center"><b>Simple, privacy-focused API monitoring & analytics</b></p>
11
- <p align="center" style="color: #ccc;">Apitally gives you the visibility you need to build better APIs – with just a few lines of code.</p>
10
+ <p align="center"><b>API monitoring & analytics made simple</b></p>
11
+ <p align="center" style="color: #ccc;">Real-time metrics, request logs, and alerts for your APIs — with just a few lines of code.</p>
12
12
  <br>
13
13
  <img alt="Apitally screenshots" src="https://assets.apitally.io/screenshots/overview.png">
14
14
  <br>
@@ -205,43 +205,26 @@ _Note:_ Apitally only works with H3 v2 and currently doesn't support nested apps
205
205
 
206
206
  ### AdonisJS
207
207
 
208
- This is an example of how to use the Apitally middleware with a AdonisJS application.
209
- For further instructions, see our
210
- [setup guide for AdonisJS](https://docs.apitally.io/frameworks/adonisjs).
211
-
212
- Create a configuration file at `config/apitally.ts`:
213
-
214
- ```javascript
215
- import { defineConfig } from "apitally/adonisjs";
208
+ You can use the built-in Ace command to set up Apitally in your AdonisJS application:
216
209
 
217
- const apitallyConfig = defineConfig({
218
- clientId: "your-client-id",
219
- env: "dev", // or "prod" etc.
220
- });
221
-
222
- export default apitallyConfig;
210
+ ```bash
211
+ node ace add apitally
223
212
  ```
224
213
 
225
- Register the Apitally provider in your `adonisrc.ts` file:
214
+ This command will automatically:
226
215
 
227
- ```javascript
228
- export default defineConfig({
229
- // ... existing code ...
230
- providers: [
231
- // ... existing providers ...
232
- () => import("apitally/adonisjs/provider"),
233
- ],
234
- });
235
- ```
216
+ - Create the configuration file at `config/apitally.ts`
217
+ - Register the Apitally provider in `adonisrc.ts`
218
+ - Add the Apitally middleware to your `start/kernel.ts` file
219
+ - Add environment variables to `.env` and validation to `start/env.ts`
236
220
 
237
- Register the Apitally middleware in your `start/kernel.ts` file:
221
+ After running the command, you'll need to:
238
222
 
239
- ```javascript
240
- router.use([
241
- () => import("apitally/adonisjs/middleware"),
242
- // ... other middleware ...
243
- ]);
244
- ```
223
+ - Set your `APITALLY_CLIENT_ID` in the `.env` file
224
+ - Modify our exception handler in `app/exceptions/handler.ts` to capture validation and server errors in Apitally
225
+
226
+ For further instructions, see our
227
+ [setup guide for AdonisJS](https://docs.apitally.io/frameworks/adonisjs).
245
228
 
246
229
  ## Getting help
247
230
 
package/configure.ts ADDED
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Allows users to add Apitally to their AdonisJS application using the built-in Ace command.
3
+ */
4
+
5
+ import type Configure from "@adonisjs/core/commands/configure";
6
+ import { stubsRoot } from "./stubs/main.js";
7
+
8
+ export async function configure(command: Configure) {
9
+ const codemods = await command.createCodemods();
10
+
11
+ await codemods.makeUsingStub(stubsRoot, "config/apitally.stub", {});
12
+
13
+ await codemods.registerMiddleware("router", [
14
+ {
15
+ path: "apitally/adonisjs/middleware",
16
+ },
17
+ ]);
18
+
19
+ await codemods.updateRcFile((rcFile) => {
20
+ rcFile.addProvider("apitally/adonisjs/provider");
21
+ });
22
+
23
+ await codemods.defineEnvVariables({
24
+ APITALLY_CLIENT_ID: "",
25
+ APITALLY_ENV: "dev",
26
+ });
27
+
28
+ await codemods.defineEnvValidations({
29
+ leadingComment: "Variables for configuring the apitally package",
30
+ variables: {
31
+ APITALLY_CLIENT_ID: "Env.schema.string()",
32
+ APITALLY_ENV: "Env.schema.string.optional()",
33
+ },
34
+ });
35
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apitally",
3
- "version": "0.15.0",
3
+ "version": "0.15.1",
4
4
  "description": "Simple API monitoring & analytics for REST APIs built with Express, Fastify, Hono, H3, Koa, and NestJS.",
5
5
  "author": "Apitally <hello@apitally.io>",
6
6
  "license": "MIT",
@@ -42,8 +42,10 @@
42
42
  },
43
43
  "files": [
44
44
  "dist/",
45
- "README.md",
46
- "LICENSE"
45
+ "stubs/",
46
+ "configure.ts",
47
+ "LICENSE",
48
+ "README.md"
47
49
  ],
48
50
  "exports": {
49
51
  "./adonisjs": {
@@ -255,7 +257,7 @@
255
257
  "fastify": "^5.0.0",
256
258
  "fastify-plugin": "^5.0.1",
257
259
  "globals": "^16.2.0",
258
- "h3": "^2.0.0-beta.0",
260
+ "h3": "2.0.0-beta.0",
259
261
  "hono": "^4.6.5",
260
262
  "koa": "^3.0.0",
261
263
  "koa-bodyparser": "^4.4.1",
@@ -0,0 +1,15 @@
1
+ {{{
2
+ exports({
3
+ to: app.configPath('apitally.ts')
4
+ })
5
+ }}}
6
+ import env from '#start/env'
7
+ import app from '@adonisjs/core/services/app'
8
+ import { defineConfig } from 'apitally/adonisjs'
9
+
10
+ const apitallyConfig = defineConfig({
11
+ clientId: env.get('APITALLY_CLIENT_ID'),
12
+ env: env.get('APITALLY_ENV', app.inProduction ? 'prod' : 'dev'),
13
+ })
14
+
15
+ export default apitallyConfig
package/stubs/main.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { getDirname } from "@adonisjs/core/helpers";
2
+
3
+ export const stubsRoot = getDirname(import.meta.url);