Skip to content

Commit 1ad8639

Browse files
committed
feat: drop .env & add config.ts
1 parent dfe08d6 commit 1ad8639

4 files changed

Lines changed: 6 additions & 7 deletions

File tree

.env

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const API_PORT = 3033

src/main/services/api/server.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import 'dotenv/config'
21
import * as jsonServer from 'json-server'
32
import { store } from '../../store'
43
import type { Server } from 'http'
54
import type { Socket } from 'net'
65
import { nanoid } from 'nanoid'
6+
import { API_PORT } from '../../../config'
77
interface ServerWithDestroy extends Server {
88
destroy: Function
99
}
@@ -59,10 +59,8 @@ export const createApiServer = () => {
5959

6060
app.use(router)
6161

62-
const server = app.listen(process.env.VITE_APP_API_PORT, () => {
63-
console.log(
64-
`API server is running on port ${process.env.VITE_APP_API_PORT}`
65-
)
62+
const server = app.listen(API_PORT, () => {
63+
console.log(`API server is running on port ${API_PORT}`)
6664
}) as ServerWithDestroy
6765

6866
enableDestroy(server)

src/renderer/composable/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { createFetch } from '@vueuse/core'
22
import mitt from 'mitt'
33
import type { Events } from './types'
4+
import { API_PORT } from '../../config'
45

56
export const useApi = createFetch({
6-
baseUrl: `http://localhost:${import.meta.env.VITE_APP_API_PORT}`
7+
baseUrl: `http://localhost:${API_PORT}`
78
})
89

910
export const emitter = mitt<Events>()

0 commit comments

Comments
 (0)