Spaces:
Sleeping
Sleeping
| import dotenv from 'dotenv'; | |
| import express from 'express'; | |
| import { existsSync } from 'node:fs'; | |
| import { dirname, resolve } from 'node:path'; | |
| import { fileURLToPath } from 'node:url'; | |
| import { createApp } from './app.js'; | |
| const serverDirectory = dirname(fileURLToPath(import.meta.url)); | |
| dotenv.config(); | |
| dotenv.config({ path: resolve(serverDirectory, '..', '..', '.env') }); | |
| const port = Number(process.env.PORT ?? 3000); | |
| const app = createApp(); | |
| const staticDirectory = resolve(serverDirectory, '..', '..', 'dist', 'mplus-studio', 'browser'); | |
| if (existsSync(staticDirectory)) { | |
| app.use(express.static(staticDirectory)); | |
| app.get(/^(?!\/api\/).*/, (_request, response) => { | |
| response.sendFile(resolve(staticDirectory, 'index.html')); | |
| }); | |
| } | |
| app.listen(port, () => { | |
| console.log(`Mplus Studio backend listening on http://localhost:${port}`); | |
| }); | |