Skip to content

Commit

Permalink
feat: drop .env & add config.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
antonreshetov committed Mar 31, 2022
1 parent dfe08d6 commit 1ad8639
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
1 change: 0 additions & 1 deletion .env

This file was deleted.

1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const API_PORT = 3033
8 changes: 3 additions & 5 deletions src/main/services/api/server.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'dotenv/config'
import * as jsonServer from 'json-server'
import { store } from '../../store'
import type { Server } from 'http'
import type { Socket } from 'net'
import { nanoid } from 'nanoid'
import { API_PORT } from '../../../config'
interface ServerWithDestroy extends Server {
destroy: Function
}
Expand Down Expand Up @@ -59,10 +59,8 @@ export const createApiServer = () => {

app.use(router)

const server = app.listen(process.env.VITE_APP_API_PORT, () => {
console.log(
`API server is running on port ${process.env.VITE_APP_API_PORT}`
)
const server = app.listen(API_PORT, () => {
console.log(`API server is running on port ${API_PORT}`)
}) as ServerWithDestroy

enableDestroy(server)
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/composable/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { createFetch } from '@vueuse/core'
import mitt from 'mitt'
import type { Events } from './types'
import { API_PORT } from '../../config'

export const useApi = createFetch({
baseUrl: `http://localhost:${import.meta.env.VITE_APP_API_PORT}`
baseUrl: `http://localhost:${API_PORT}`
})

export const emitter = mitt<Events>()

0 comments on commit 1ad8639

Please sign in to comment.