1
0
mirror of https://github.com/sasjs/server.git synced 2025-12-10 11:24:35 +00:00

chore: fix for development docker-compose

This commit is contained in:
Saad Jutt
2021-11-14 21:12:10 +05:00
parent 4792f15c40
commit 5e7cecf3ea
7 changed files with 14 additions and 18 deletions

View File

@@ -27,10 +27,6 @@ app.use('/', webRouter)
app.use('/SASjsApi', apiRouter)
app.use(express.json({ limit: '50mb' }))
try {
app.use(express.static(getWebBuildFolderPath()))
} catch (err) {
console.error('Unable to get web build')
}
app.use(express.static(getWebBuildFolderPath()))
export default connectDB().then(() => app)

View File

@@ -1,7 +1,6 @@
import path from 'path'
import { readFileSync } from 'fs'
import * as https from 'https'
import { configuration } from '../package.json'
import appPromise from './app'
const keyPath = path.join('..', 'certificates', 'privkey.pem')
@@ -13,9 +12,10 @@ const cert = readFileSync(certPath)
appPromise.then((app) => {
const httpsServer = https.createServer({ key, cert }, app)
httpsServer.listen(configuration.sasJsPort, () => {
const sasJsPort = process.env.PORT ?? 5000
httpsServer.listen(sasJsPort, () => {
console.log(
`⚡️[server]: Server is running at https://localhost:${configuration.sasJsPort}`
`⚡️[server]: Server is running at https://localhost:${sasJsPort}`
)
})
})

View File

@@ -12,11 +12,8 @@ const codeToInject = `
</script>`
webRouter.get('/', async (_, res) => {
let indexHtmlPath: string
try {
indexHtmlPath = path.join(getWebBuildFolderPath(), 'index.html')
} catch (err) {
const indexHtmlPath = path.join(getWebBuildFolderPath(), 'index.html')
if (!(await fileExists(indexHtmlPath))) {
return res.send('Web Build is not present')
}

View File

@@ -1,10 +1,10 @@
import appPromise from './app'
import { configuration } from '../package.json'
appPromise.then((app) => {
app.listen(configuration.sasJsPort, () => {
const sasJsPort = process.env.PORT ?? 5000
app.listen(sasJsPort, () => {
console.log(
`⚡️[server]: Server is running at http://localhost:${configuration.sasJsPort}`
`⚡️[server]: Server is running at http://localhost:${sasJsPort}`
)
})
})

View File

@@ -2,7 +2,7 @@ import path from 'path'
import { getRealPath } from '@sasjs/utils'
export const getWebBuildFolderPath = () =>
getRealPath(path.join(__dirname, '..', '..', '..', 'web', 'build'))
path.join(__dirname, '..', '..', '..', 'web', 'build')
export const getTmpFolderPath = () =>
process.driveLoc ?? getRealPath(path.join(process.cwd(), 'tmp'))

View File

@@ -5,6 +5,9 @@ services:
image: sasjs_server_api
build: ./api
environment:
MODE: server
CORS: enable
PORT: 5000
DB_CONNECT: mongodb://mongodb:27017/sasjs
ports:
- 5000:5000

View File

@@ -1,3 +1,3 @@
build
node_modules
Dockerfile
Dockerfile