Socket
Socket
Sign inDemoInstall

ember-cli-inject-meta

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-cli-inject-meta - npm Package Compare versions

Comparing version 0.0.4 to 1.0.0

23

lib/inject-meta.js

@@ -7,2 +7,4 @@ var fs = require('fs');

var Promise = RSVP.Promise;
module.exports = function(modules) {

@@ -35,4 +37,11 @@ return function(req, res, next) {

moduleLoader: getModuleLoader(),
modules: new RSVP.Promise(function(resolve) {
modules(req, res, resolve);
modules: new Promise(function(resolve) {
var result = modules(req);
if (!result) {
resolve();
return;
} else if (!Array.isArray(result)) {
result = [result];
}
resolve(Promise.all(result));
})

@@ -46,6 +55,2 @@ };

// Format modules to always be an array
if (!Array.isArray(modules)) {
modules = [modules];
}
// Inject the module loader script, this is planned to be a part of ember-cli in the near future

@@ -62,2 +67,6 @@ // https://github.com/ember-cli/ember-cli/pull/5233

res.end(body);
}).catch(function(reason) {
// fail the request
console.error(reason);
console.error(reason && reason.stack);
});

@@ -80,3 +89,3 @@ }

function getModuleLoader() {
return new RSVP.Promise(function(resolve, reject) {
return new Promise(function(resolve, reject) {
fs.readFile(path.join(__dirname, 'define-meta-modules.js'), 'utf8', function(err, data) {

@@ -83,0 +92,0 @@ if (err) {

{
"name": "ember-cli-inject-meta",
"version": "0.0.4",
"version": "1.0.0",
"description": "Inject meta tags into an ember application to use as modules",

@@ -9,3 +9,4 @@ "author": "Offir Golan <offirgolan@gmail.com>",

"scripts": {
"test": "./node_modules/.bin/mocha",
"test": "mocha",
"test:debug": "mocha debug",
"cover": "istanbul cover _mocha -- -R spec ./test/*-test.js"

@@ -12,0 +13,0 @@ },

@@ -12,3 +12,3 @@ # Ember CLI Inject Meta

In this example, we will create our user config that will be located in `<APP_NAMESPACE>/config/user.js`. In your express server, you will have to define the middleware.
In this example, we will create our user config that will be located in `<APP_NAMESPACE>/config/user.js`. In your express server, you will have to define the middleware.

@@ -20,4 +20,4 @@ ```js

app.use(injectMeta(function(req, res, inject) {
inject({
app.use(injectMeta(function(req) {
return {
path: 'config/user',

@@ -28,3 +28,3 @@ content: {

}
})
};
}))

@@ -66,15 +66,15 @@ ```

```js
injectMeta(function(req, res, inject) {
inject({
injectMeta(function(req) {
return {
path: 'config/user',
content: { username: 'offirgolan' }
});
};
});
```
**Mutliple Meta Tags**
**Multiple Meta Tags**
```js
injectMeta(function(req, res, inject) {
inject([{
injectMeta(function(req) {
return [{
path: 'config/user',

@@ -85,5 +85,26 @@ content: { username: 'offirgolan' }

content: { endpoint: 'api/v2' }
}])
}]
})
```
**Multiple Meta Tags with Promises**
```js
injectMeta(function(req) {
var userConfig = getUserConfig(req).then(function(result) {
return {
path: 'config/user',
content: result
}
});
var apiConfig = getAPIConfig(req).then(function(result) {
return {
path: 'config/api',
content: result
}
});
return [ userConfig, apiConfig ];
})
```
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc