- Add versioning to API endpoints. - Refactored $db and $repos as global variables. - Extracted routes into separate components with deferred registration. - Support for a different db URL for location data than the one used by the application. - Added sqlite and passport dependencies (passport will soon be used to handle authentication).
44 lines
1 KiB
TypeScript
44 lines
1 KiB
TypeScript
import { fileURLToPath, URL } from 'node:url'
|
|
|
|
import { defineConfig, loadEnv } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import vueDevTools from 'vite-plugin-vue-devtools'
|
|
|
|
// https://vite.dev/config/
|
|
export default defineConfig((env) => {
|
|
const envDir = '../';
|
|
const envars = loadEnv(env.mode, envDir);
|
|
const serverURL = new URL(
|
|
envars.VITE_API_SERVER_URL ?? 'http://localhost:3000'
|
|
);
|
|
const serverAPIPath = envars.VITE_API_PATH ?? '/api/v1';
|
|
|
|
return {
|
|
envDir: envDir,
|
|
|
|
// make the API path globally available in the client
|
|
define: {
|
|
__API_PATH__: JSON.stringify(serverAPIPath),
|
|
},
|
|
|
|
plugins: [
|
|
vue(),
|
|
vueDevTools(),
|
|
],
|
|
|
|
resolve: {
|
|
alias: {
|
|
'@': fileURLToPath(new URL('./src', import.meta.url))
|
|
},
|
|
},
|
|
|
|
server: {
|
|
port: 5173,
|
|
proxy: {
|
|
// proxy requests with the API path to the server
|
|
// <http://localhost:5173/api> -> <http://localhost:3000/api>
|
|
[serverAPIPath]: serverURL.origin,
|
|
},
|
|
},
|
|
}
|
|
})
|