Skip to content
This repository has been archived by the owner on Jan 6, 2024. It is now read-only.

Commit

Permalink
Serve static web files from server
Browse files Browse the repository at this point in the history
  • Loading branch information
MrXyfir committed Feb 25, 2019
1 parent 0875c82 commit 63988f6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions server/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as cookieParser from 'cookie-parser';
import * as bodyParser from 'body-parser';
import * as Express from 'express';
import { Accownt } from 'types/accownt';
import { resolve } from 'path';
import { router } from 'api/router';

declare global {
Expand Down Expand Up @@ -44,11 +45,15 @@ if (!PROD) {
next();
});
}
app.use('/static', Express.static(resolve(process.enve.WEB_DIRECTORY, 'dist')));
app.use(bodyParser.urlencoded({ extended: true, limit: '2mb' }));
app.use(bodyParser.json({ limit: '2mb' }));
app.use(cookieParser());
app.use(verifyRequestJWT);
app.use('/api', router);
app.get('/*', (req, res) =>
res.sendFile(resolve(process.enve.WEB_DIRECTORY, 'dist', 'index.html'))
);
app.use(
(
err: string | Error,
Expand Down
5 changes: 5 additions & 0 deletions types/accownt.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ export namespace Accownt {
* For Jest tests. Keep this as such so the TypeScript compiler is happy
*/
TEST_STORAGE: object;
/**
* Absolute path for accownt-web.
* @example "/path/to/accownt/web"
*/
WEB_DIRECTORY: string;
/**
* Used by `nodemailer.createTransport()`
* https://nodemailer.com/smtp/
Expand Down

0 comments on commit 63988f6

Please sign in to comment.