Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
connect-assets-cdn
Advanced tools
A connect-assets helper for uploading built assets to a CDN (like Amazon S3)
A helper module for connect-assets to upload your files to a CDN (like Amazon S3)
npm install connect-assets-cdn
To create a Cake task to upload new assets, follow this example.
/s3.js
require("coffee-script");
var uploader = require("./src/s3AssetUpload");
uploader.upload(console.log, function(err, uploaded) {
if(err) {
return console.log("Error uploading: " + err.message);
process.exit(1);
}
console.log("Completed");
process.exit(0);
});
/src/s3AssetUpload.coffee
express = require 'express'
assets = require "connect-assets"
jsPaths = require "connect-assets-jspaths"
{AssetsCDN} = require "connect-assets-cdn"
# Either create a config file like here or set this to
# an object with amazon key, secret and bucket values
# Also should have the assetsRoot; e.g. //s3.amazonaws.com/myBucket
config = require "./config"
primeCSS = (assets) ->
# We only have one file to pre-compile for css
# You might need to add more for your situation;
# whatever you reference in your views should be
# referenced like this here
assets.instance.options.helperContext.css "prod"
upload = (log, done) ->
# Set up a fake express server so we can load connect-assets
app = express()
opts =
# TODO: Set your assetsRoot
servePath: config.assetsRoot
app.use assets opts
# Prime the CSS files
primeCSS assets
# Prime the JS files
jsPaths assets
# TODO: Set these from your config
{key, secret, bucket} = config.amazon
# Create our cdn manager and upload
cdn = new AssetsCDN {assets, key, secret, bucket, log}
cdn.upload done
module.exports = {upload}
/Cakefile
task 's3', 'Upload builtAssets', ->
# Set production NODE_ENV
currentEnv = process.env
currentEnv.NODE_ENV = "production"
server = spawn 'node', ['s3.js'],
env: currentEnv
server.stdout.pipe process.stdout
server.stderr.pipe process.stderr
# You can also upload new assets before starting the server...
assets = require 'connect-assets'
{AssetsCDN} = require 'connect-assets-cdn'
# Snip ...
app.use assets
servePath: '//s3.amazonaws.com/S3_Bucket'
# You should probably only upload for production
if process.env.NODE_ENV == "production"
cdn = new AssetsCDN
assets: assets
key: "S3_Key"
secret: "S3_Secret"
bucket: "S3_Bucket"
cdn.upload (err, uploadedPaths) ->
throw err if err
app.listen 3000, (err) ->
console.log "Server started"
Made possible thanks to connect-assets, knox.
Created by Jacob Gable. MIT License; no attribution required.
FAQs
A connect-assets helper for uploading built assets to a CDN (like Amazon S3)
The npm package connect-assets-cdn receives a total of 1 weekly downloads. As such, connect-assets-cdn popularity was classified as not popular.
We found that connect-assets-cdn 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.