File tree Expand file tree Collapse file tree 2 files changed +28
-9
lines changed Expand file tree Collapse file tree 2 files changed +28
-9
lines changed Original file line number Diff line number Diff line change @@ -205,7 +205,7 @@ _Note:_ Apitally only works with H3 v2 and currently doesn't support nested apps
205
205
206
206
### AdonisJS
207
207
208
- You can use the built-in Ace command to configure Apitally in your AdonisJS application:
208
+ You can use the below Ace command to configure Apitally in your AdonisJS application:
209
209
210
210
``` bash
211
211
node ace configure apitally/adonisjs
@@ -216,12 +216,7 @@ This command will automatically:
216
216
- Create a config file at ` config/apitally.ts `
217
217
- Register the Apitally provider in ` adonisrc.ts `
218
218
- Add the Apitally middleware to ` start/kernel.ts `
219
- - Add environment variables to ` .env ` and ` start/env.ts `
220
-
221
- After running the command, you'll need to:
222
-
223
- - Set your ` APITALLY_CLIENT_ID ` in the ` .env ` file
224
- - Modify your exception handler in ` app/exceptions/handler.ts ` to capture validation and server errors
219
+ - Add required environment variables to ` .env ` and ` start/env.ts `
225
220
226
221
For further instructions, see our
227
222
[ setup guide for AdonisJS] ( https://docs.apitally.io/frameworks/adonisjs ) .
Original file line number Diff line number Diff line change 5
5
import type Configure from "@adonisjs/core/commands/configure" ;
6
6
import { fileURLToPath } from "url" ;
7
7
8
+ import { isValidClientId , isValidEnv } from "../common/paramValidation.js" ;
9
+
8
10
const STUBS_ROOT = fileURLToPath ( new URL ( "./stubs/" , import . meta. url ) ) ;
9
11
10
12
export async function configure ( command : Configure ) {
13
+ const clientId = await command . prompt . ask ( "Apitally client ID" , {
14
+ result ( value ) {
15
+ return value . trim ( ) . toLowerCase ( ) ;
16
+ } ,
17
+ validate ( value ) {
18
+ return isValidClientId ( value ) ;
19
+ } ,
20
+ } ) ;
21
+ const env = await command . prompt . ask ( "Environment name" , {
22
+ default : "dev" ,
23
+ result ( value ) {
24
+ return value
25
+ . trim ( )
26
+ . toLowerCase ( )
27
+ . replaceAll ( "_" , "-" )
28
+ . replaceAll ( " " , "-" ) ;
29
+ } ,
30
+ validate ( value ) {
31
+ return isValidEnv ( value ) ;
32
+ } ,
33
+ } ) ;
34
+
11
35
const codemods = await command . createCodemods ( ) ;
12
36
13
37
await codemods . makeUsingStub ( STUBS_ROOT , "config/apitally.stub" , { } ) ;
@@ -23,8 +47,8 @@ export async function configure(command: Configure) {
23
47
} ) ;
24
48
25
49
await codemods . defineEnvVariables ( {
26
- APITALLY_CLIENT_ID : "" ,
27
- APITALLY_ENV : "dev" ,
50
+ APITALLY_CLIENT_ID : clientId ,
51
+ APITALLY_ENV : env ,
28
52
} ) ;
29
53
30
54
await codemods . defineEnvValidations ( {
You can’t perform that action at this time.
0 commit comments