Files
talk/src/core/server/app/router/client.ts
T
Wyatt JohnsonandGitHub 9608198d86 [next] Content Security Policy (#1972)
* feat: initial csp support

* fix: strip non-frame directives

* review: added tests, fixed some edge cases
2018-10-19 17:06:40 +00:00

37 lines
817 B
TypeScript

import express from "express";
import { cacheHeadersMiddleware } from "talk-server/app/middleware/cacheHeaders";
export interface ClientTargetHandlerOptions {
/**
* view is the name of the template to render.
*/
view: string;
/**
* cacheDuration is the cache duration that a given request should be cached for.
*/
cacheDuration?: string | false;
/**
* staticURI is prepended to the static url's that are included on the static
* pages.
*/
staticURI: string;
}
export function createClientTargetRouter({
staticURI,
view,
cacheDuration = "1h",
}: ClientTargetHandlerOptions) {
// Create a router.
const router = express.Router();
router.use(cacheHeadersMiddleware(cacheDuration));
router.get("/", (req, res) => res.render(view, { staticURI }));
return router;
}