mirror of
https://github.com/sasjs/server.git
synced 2026-01-15 18:00:05 +00:00
feat(api-utility): create getWebBuildFolderPath utility
This commit is contained in:
@@ -1,10 +1,11 @@
|
|||||||
import express from 'express'
|
import express from 'express'
|
||||||
import indexRouter from './routes'
|
import indexRouter from './routes'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
import { getWebBuildFolderPath } from './utils'
|
||||||
const app = express()
|
const app = express()
|
||||||
|
|
||||||
app.use(express.json({ limit: '50mb' }))
|
app.use(express.json({ limit: '50mb' }))
|
||||||
app.use('/', indexRouter)
|
app.use('/', indexRouter)
|
||||||
app.use(express.static(path.join(__dirname, '..', '..', 'web', 'build')))
|
app.use(express.static(getWebBuildFolderPath()))
|
||||||
|
|
||||||
export default app
|
export default app
|
||||||
|
|||||||
@@ -8,16 +8,18 @@ import {
|
|||||||
FileUploadController
|
FileUploadController
|
||||||
} from '../controllers'
|
} from '../controllers'
|
||||||
import { isExecutionQuery, isFileQuery, isFileTree } from '../types'
|
import { isExecutionQuery, isFileQuery, isFileTree } from '../types'
|
||||||
import { getTmpFilesFolderPath, makeFilesNamesMap } from '../utils'
|
import {
|
||||||
|
getTmpFilesFolderPath,
|
||||||
|
getWebBuildFolderPath,
|
||||||
|
makeFilesNamesMap
|
||||||
|
} from '../utils'
|
||||||
|
|
||||||
const router = express.Router()
|
const router = express.Router()
|
||||||
|
|
||||||
const fileUploadController = new FileUploadController()
|
const fileUploadController = new FileUploadController()
|
||||||
|
|
||||||
router.get('/', async (_, res) => {
|
router.get('/', async (_, res) => {
|
||||||
res.sendFile(
|
res.sendFile(path.join(getWebBuildFolderPath(), 'index.html'))
|
||||||
path.join(__dirname, '..', '..', '..', 'web', 'build', 'index.html')
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
router.post('/deploy', async (req, res) => {
|
router.post('/deploy', async (req, res) => {
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
import { getRealPath, generateTimestamp } from '@sasjs/utils'
|
import { getRealPath } from '@sasjs/utils'
|
||||||
|
|
||||||
|
export const getWebBuildFolderPath = () =>
|
||||||
|
getRealPath(path.join(__dirname, '..', '..', '..', 'web', 'build'))
|
||||||
|
|
||||||
export const getTmpFolderPath = () =>
|
export const getTmpFolderPath = () =>
|
||||||
getRealPath(path.join(__dirname, '..', '..', 'tmp'))
|
getRealPath(path.join(__dirname, '..', '..', 'tmp'))
|
||||||
|
|||||||
Reference in New Issue
Block a user