Security News
cURL Project and Go Security Teams Reject CVSS as Broken
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
A helper library for rendering universal react+redux apps.
Uses naglfar
for server/client view routing, and exports all module methods.
naglfar
)react-helmet
Install via npm i fenris
.
App routes example
import {routeFragment, routeRedirect} from 'fenris'
import {getUsers, getUser} from './actions'
routeRedirect('/user', '/')
export const HomeRoute = routeFragment('/', getUsers)
export const UserRoute = routeFragment('/user/:id', getUser)
export const NotFoundRoute = routeFragment(404)
App example
import React from 'react'
import Helmet from 'react-helmet'
import {Link} from 'fenris'
import Home from './pages/Home'
import User from './pages/User'
import NoMatch from './pages/NoMatch'
import {HomeRoute, UserRoute, NotFoundRoute} from './routes'
const App = ({ children }) => (
<>
<Helmet
title="My App"
titleTemplate="%s - My App"
meta={[
{ 'char-set': 'utf-8' },
{ name: 'description', content: 'My super dooper dope app' },
]}
/>
<nav>
<ul>
<li><Link to="/" prefetchData>Users</Link></li>
</ul>
</nav>
<HomeRoute><Home /></HomeRoute>
<UserRoute><User /></UserRoute>
<NotFoundRoute><NoMatch /></NotFoundRoute>
</>
)
export default App
Client entry example
import {renderClient} from 'fenris'
import AppComponent from './App'
import reducer from '/store'
renderClient({AppComponent, reducer})
Koa server example with CSRF
import Koa from 'koa'
import Router from 'koa-router'
import {routeRenderer, csrfCreator} from 'fenris/server'
import AppComponent from './App'
import reducer from './store'
import baseCss from './style.css'
const app = new Koa()
app.keys = ['cookie_secret']
const {create, validate} = csrfCreator('csrf_secret', 3600000)
const csrfMiddleware = (ctx, next) => {
const sessionCookie = ctx.cookies.get('x-session', {signed:true})
if (['GET', 'HEAD', 'OPTIONS'].includes(method.toUpperCase())) {
const {session, csrf} = create(sessionCookie)
ctx.cookies.set('x-session', session, {signed: true})
// you can inject any initialState into redux via middleware
// and doing so prevents caching the rendered body
ctx.initialState = {csrf}
return next()
} else {
if (!validate(sessionCookie, ctx.body.csrf)) ctx.throw(403, 'Invalid CSRF token')
return next()
}
}
app.use(csrfMiddleware)
const router = new Router()
const renderRoute = routeRenderer({
reducer,
AppComponent,
baseCss,
jsSource: 'script.js',
})
router.get('*', ctx => renderRoute(ctx).then({status, url, body}) => {
if (url) ctx.status(status).redirect(url)
ctx.status(status).body = body
})
app.listen(3000, _ => console.log('Server listening on port 3000'))
FAQs
Universal app rendering and CSRF solution
The npm package fenris receives a total of 4 weekly downloads. As such, fenris popularity was classified as not popular.
We found that fenris demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.