-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: revert cli server to express only
- Loading branch information
Showing
5 changed files
with
40 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { createRequestHandler } from '@expo/server/adapter/express'; | ||
import compression from 'compression'; | ||
import express from 'express'; | ||
import morgan from 'morgan'; | ||
|
||
import { type Options } from './resolveOptions'; | ||
import { StatsFileSource } from '../data/StatsFileSource'; | ||
import { CLIENT_BUILD_DIR, SERVER_BUILD_DIR } from '../utils/middleware'; | ||
|
||
export function createServer(options: Options) { | ||
global.EXPO_ATLAS_SOURCE = new StatsFileSource(options.statsFile); | ||
process.env.NODE_ENV = 'production'; | ||
|
||
const app = express(); | ||
|
||
// http://expressjs.com/en/advanced/best-practice-security.html#at-a-minimum-disable-x-powered-by-header | ||
app.disable('x-powered-by'); | ||
|
||
app.use(compression()); | ||
app.use(morgan('tiny')); | ||
|
||
// TODO(cedric): replace with middleware once we can | ||
app.use( | ||
express.static(CLIENT_BUILD_DIR, { | ||
maxAge: '1h', | ||
extensions: ['html'], | ||
}) | ||
); | ||
|
||
// TODO(cedric): replace with middleware once we can | ||
app.all('*', createRequestHandler({ build: SERVER_BUILD_DIR })); | ||
|
||
return app; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters