Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
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)
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.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.