Socket
Socket
Sign inDemoInstall

@bitgenics/fab-static

Package Overview
Dependencies
328
Maintainers
3
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.5.0-rc1 to 0.5.0-rc2

18

bundle.js

@@ -6,5 +6,8 @@ const path = require('path')

const globby = require('globby')
const mime = require('mime-types')
const webpack = require('webpack')
const zip = util.promisify(require('deterministic-zip'))
const HOUR_IN_SEC = 60 * 60
const createWebpackConfig = require('./webpack.config.server.js')

@@ -14,3 +17,3 @@

const files = await globby(['**/*'], { cwd: includesDir })
let contents = files.map(file => {
let contents = files.map((file) => {
file = path.join(includesDir, file)

@@ -22,3 +25,8 @@ return fse.readFile(file, { encoding: 'base64' })

files.forEach((file, index) => {
urls[file] = `Buffer.from('${contents[index]}', 'base64')`
const headers = {
'Cache-Control': `max-age=${HOUR_IN_SEC}`,
'Content-Type': mime.lookup(file),
}
const bytes = `Buffer.from('${contents[index]}', 'base64')`
urls[file] = `{ bytes: ${bytes}, headers: ${JSON.stringify(headers)} }`
})

@@ -30,3 +38,3 @@ return urls

let code = 'const urls = {}\n'
Object.keys(contents).forEach(url => {
Object.keys(contents).forEach((url) => {
code = code.concat(`urls['/${url}'] = ${contents[url]}\n`)

@@ -88,3 +96,3 @@ })

includes: ['./server/**', './_assets/**'],
cwd: distDir
cwd: distDir,
}

@@ -107,2 +115,2 @@ await zip(distDir, zipfile, options)

module.exports = doBundle
module.exports = doBundle

@@ -98,2 +98,3 @@ const path = require('path')

})
urls['_catch_all.html'] = urls['_catch_all.html'] || urls['index.html']
const htmlsFile = path.join(config.serverDestDir, '_htmls.js')

@@ -100,0 +101,0 @@ const code = generateCode(urls)

{
"name": "@bitgenics/fab-static",
"version": "0.5.0-rc1",
"version": "0.5.0-rc2",
"description": "Front-end Application Bundle generator for (mostly) static applications.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -1,4 +0,1 @@

const url_parse = require('url').parse
const mime = require('mime-types')
const HOUR_IN_SEC = 60 * 60

@@ -40,3 +37,3 @@

const getPath = (url) => {
let pathname = url_parse(url).pathname
let pathname = new URL(url).pathname
if (pathname.endsWith('/')) {

@@ -60,7 +57,2 @@ pathname += 'index.html'

const getContentType = (pathname) => {
const mimeType = mime.lookup(pathname)
return mimeType ? mime.contentType(mimeType) : 'text/html; charset=utf-8'
}
const handleRedirectToAssets = async (req, _, next) => {

@@ -86,11 +78,7 @@ if (config.redirectToAssets && req.pathname.startsWith(STATIC_DIR_PATH)) {

const content = files[req.pathname]
//const charset = content instanceof String ? 'utf-8' : undefined
const headers = {
'Cache-Control': `public, max-age=${config.cacheStatic}`,
'Content-Type': getContentType(req.pathname),
}
console.log({ content })
const response = new Response(content, {
const response = new Response(content.bytes, {
status: 200,
headers,
headers: content.headers,
})

@@ -112,3 +100,3 @@ console.log({ response })

: accepts_html
? htmls['/200.html']
? htmls['/_catch_all.html']
: null

@@ -130,8 +118,8 @@

} else {
next()
return next()
}
}
const handle404 = async (_, res) => {
return new Response(content, {
const handle404 = async () => {
return new Response('Content not Found', {
status: 404,

@@ -138,0 +126,0 @@ })

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc