Files
spacedrive/apps/landing/server/index.ts
T
bb40110e6e Eng 243 documentation on landing (#386)
* Updated roadmap

* Color timeline to show where we are up to

* roadmap improvements

* roadmap changes

* docs init

* progress on docs

* support metadata (name & ordering)

* fix prod build

* fix lock

* fix perender

* docs progress

* added "slots" to markdown parser

* refactor to support sections

* more docs progress

* fixes

* added empty docs

* killer opening paragraph

* fix Heroicon imports & page rendering

* tweaks

* next doc

* fix build

* fix ssg failure

* fix prod build for REAL

it was the bubbles

* fix next doc api

* it's the bubbles

* wip: docs mobile

* doc nav tweak

* doc menu ui

* fix next doc in pre-render

* react-borger-menu

* fix build

* fix height and padding

* mobile docs nav styles

* oooh super cool transition

* fix button state glitch + big headings

* refactor layout

* docs mobile nav bar style

* fix min width & height

* Merge remote-tracking branch 'refs/remotes/origin/main'

Conflicts:
	docs/architecture/spaces.md
	docs/developers/architecture/spaces.md

* placeholder docs

* correct pre styles + env setup guide

* search coming soon

* docs cleanup

* resolved cargo

* reorder docs + add image

Co-authored-by: Lu Hill <email@lewie.me>
Co-authored-by: Jamie Pine <ijamespine@me.com>
2022-09-27 19:48:42 -07:00

46 lines
1.2 KiB
TypeScript

import compression from 'compression';
import express from 'express';
import { renderPage } from 'vite-plugin-ssr';
const isProduction = process.env.NODE_ENV === 'production';
const root = `${__dirname}/..`;
startServer();
async function startServer() {
const app = express();
app.use(compression());
if (isProduction) {
const sirv = require('sirv');
app.use(sirv(`${root}/dist/client`));
} else {
const vite = require('vite');
const viteDevMiddleware = (
await vite.createServer({
root,
server: { middlewareMode: true }
})
).middlewares;
app.use(viteDevMiddleware);
}
app.get('*', async (req, res, next) => {
const url = req.originalUrl;
const pageContextInit = {
url
};
const pageContext = await renderPage(pageContextInit);
const { httpResponse } = pageContext;
if (!httpResponse) return next();
const { body, statusCode, contentType } = httpResponse;
res.status(statusCode).type(contentType).send(body);
});
const port = process.env.PORT || 3000;
// @ts-ignore: I don't get why this isn't valid they have a definition matching this.
app.listen(port, '0.0.0.0');
console.log(`Server running at http://localhost:${port}`);
}