UNPKG

farrow-helmet

Version:

Security middleware for Farrow HTTP applications that helps secure your web apps by setting various HTTP security headers

18 lines (17 loc) 512 B
import { Response, useReq, useRes } from 'farrow-http'; import { default as helmetExpress } from 'helmet'; export const helmet = (options) => { const helmet = helmetExpress(options); return async (request, next) => { const req = useReq(); const res = useRes(); const resp = next(request); try { helmet(req, res, () => { }); } catch (error) { return Response.status(500).text(error.message); } return resp; }; };