Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// @flow
import App from 'fusion-core';
import {assetUrl} from 'fusion-core';
import * as jsonData from './static/test.json';
import serverAsset from './server-asset.js';
const hoistedUrl = assetUrl('./static/test.css');
if (typeof window !== 'undefined') {
window.__hoistedUrl__ = hoistedUrl;
}
export default (async function() {
const app = new App('element', el => el);
__NODE__ &&
app.middleware((ctx, next) => {
if (ctx.url.startsWith('/_static')) {
ctx.set('x-test', 'test');
} else if (ctx.url === '/test') {
ctx.body = assetUrl('./static/test.css');
} else if (ctx.url === '/dirname') {
ctx.body = __dirname;
} else if (ctx.url === '/filename') {
ctx.body = __filename;
// @noflow
import {assetUrl} from 'fusion-core';
export default assetUrl('./static/test-server-asset.txt');
// @noflow
import App from 'fusion-core';
import {assetUrl} from 'fusion-core';
import {key as jsonField} from './static/test.json';
import serverAsset from './server-asset.js';
const hoistedUrl = assetUrl('./static/test.css');
if (typeof window !== 'undefined') {
window.__hoistedUrl__ = hoistedUrl;
}
export default (async function() {
const app = new App('element', el => el);
__NODE__ &&
app.middleware((ctx, next) => {
if (ctx.url.startsWith('/_static')) {
ctx.set('x-test', 'test');
} else if (ctx.url === '/test') {
ctx.body = assetUrl('./static/test.css');
} else if (ctx.url === '/dirname') {
ctx.body = __dirname;
} else if (ctx.url === '/filename') {
ctx.body = __filename;
app.middleware((ctx, next) => {
if (ctx.url.startsWith('/_static')) {
ctx.set('x-test', 'test');
} else if (ctx.url === '/test') {
ctx.body = assetUrl('./static/test.css');
} else if (ctx.url === '/dirname') {
ctx.body = __dirname;
} else if (ctx.url === '/filename') {
ctx.body = __filename;
} else if (ctx.url === '/hoisted') {
ctx.body = hoistedUrl;
} else if (ctx.url === '/json') {
ctx.body = assetUrl('./static/test.json');
} else if (ctx.url === '/json-import') {
ctx.body = JSON.stringify(jsonData);
} else if (ctx.url === '/server-asset') {
ctx.body = serverAsset;
}
return next();
});
componentDidMount() {
fetch(assetUrl('../static/test.json'))
.then(result => result.json())
.then(result => {
this.setState({
content: result.content,
});
});
}
export default async function() {
const app = new App('element', el => el);
assetUrl('./assets/SVG_logo.svg');
return app;
}
export const serverAsset = () => assetUrl('./assets/server-asset.txt');
app.middleware((ctx, next) => {
if (ctx.url.startsWith('/_static')) {
ctx.set('x-test', 'test');
} else if (ctx.url === '/test') {
ctx.body = assetUrl('./static/test.css');
} else if (ctx.url === '/dirname') {
ctx.body = __dirname;
} else if (ctx.url === '/filename') {
ctx.body = __filename;
} else if (ctx.url === '/hoisted') {
ctx.body = hoistedUrl;
} else if (ctx.url === '/json') {
ctx.body = assetUrl('./static/test.json');
} else if (ctx.url === '/json-import') {
ctx.body = JSON.stringify(jsonData);
} else if (ctx.url === '/server-asset') {
ctx.body = serverAsset;
}
return next();
});
componentDidMount() {
fetch(assetUrl('../static/test.json'))
.then(result => result.json())
.then(result => {
this.setState({
content: result.content,
});
});
}
middleware: () => {
const todoCssUrl = assetUrl("../../node_modules/todomvc-app-css/index.css");
return (ctx, next) => {
applyTodoMvcStyling(ctx, todoCssUrl);
return next();
};
}
});