forked from massCodeIO/massCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi-generate.js
More file actions
23 lines (20 loc) · 720 Bytes
/
api-generate.js
File metadata and controls
23 lines (20 loc) · 720 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const child_process = require('node:child_process')
const { styleText } = require('node:util')
const Store = require('electron-store')
const store = new Store({ name: 'preferences', cwd: 'v2' })
const apiPort = store.get('apiPort', 4321)
const url = `http://localhost:${apiPort}/swagger/json`
async function generateApi() {
try {
console.log(styleText('blue', 'Generating API...'))
child_process.execSync(
`npx swagger-typescript-api@13.0.23 -p ${url} -o ./src/renderer/services/api/generated -n index.ts`,
)
console.log(styleText('green', 'API is successfully generated'))
}
catch (err) {
console.log(styleText('red', 'Error generating API'))
console.log(err)
}
}
generateApi()