How to use soya-next - 10 common examples

To help you get started, we’ve selected a few soya-next examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github traveloka / soya-next / examples / custom-routes / server.js View on Github external
.then(() => {
    const server = express();
    server.use(createRouter(app, routerOptions));
    server.listen(3000, err => {
      if (err) {
        throw err;
      }
      // eslint-disable-next-line no-console
      console.log('> Ready on http://localhost:3000');
    });
  })
  .catch(ex => {
github traveloka / soya-next / packages / soya-next-cli / templates / server.js View on Github external
.then(() => {
    const server = express();
    server.use(createRouter(app));
    server.listen(soya.config.port, err => {
      if (err) {
        throw err;
      }
      // eslint-disable-next-line no-console
      console.log(`> Ready on http://localhost:${soya.config.port}`);
    });
  })
  .catch(ex => {
github traveloka / soya-next / examples / todomvc / server.js View on Github external
.then(() => {
    const server = express();
    server.use(createRouter(app));
    server.listen(3000, err => {
      if (err) {
        throw err;
      }
      // eslint-disable-next-line no-console
      console.log('> Ready on http://localhost:3000');
    });
  })
  .catch(ex => {
github traveloka / soya-next / examples / i18n-with-redux / server.js View on Github external
.then(() => {
    const server = express();
    server.use(createRouter(app, routerOptions));
    server.listen(3000, err => {
      if (err) {
        throw err;
      }
      // eslint-disable-next-line no-console
      console.log('> Ready on http://localhost:3000');
    });
  })
  .catch(ex => {
github traveloka / soya-next / packages / soya-next-cli / templates / server.js View on Github external
server.listen(soya.config.port, err => {
      if (err) {
        throw err;
      }
      // eslint-disable-next-line no-console
      console.log(`> Ready on http://localhost:${soya.config.port}`);
    });
  })
github traveloka / soya-next / packages / soya-next-cli / templates / server.js View on Github external
.then(() => {
    const server = express();
    server.use(createRouter(app));
    server.listen(soya.config.port, err => {
      if (err) {
        throw err;
      }
      // eslint-disable-next-line no-console
      console.log(`> Ready on http://localhost:${soya.config.port}`);
    });
  })
  .catch(ex => {
github traveloka / soya-next / packages / soya-next-server / server.js View on Github external
res.header(field, config.server.headers[field]);
          });
          next();
        });

      const includeSoyaLegacy =
        process.argv.indexOf("--include-soya-legacy") !== -1;
      const soyaMiddleware = includeSoyaLegacy
        ? require(join(appDir, "build", "server", "index.js")).default
        : null;
      if (soyaMiddleware !== null) {
        server.use(soyaMiddleware);
      }

      server.use(
        createRouter(app, {
          basePath: config.basePath,
          routes: config.routes,
          redirects: config.redirects,
          defaultLocale: config.defaultLocale,
          siteLocales: config.siteLocales,
          compression: config.server.compression,
          whoami: config.whoami
        })
      );
      server.listen(config.server.port, config.server.host, err => {
        if (err) {
          throw err;
        }

        if (typeof process.send === "function") {
          process.send("ready");
github traveloka / soya-next / examples / i18n / components / LanguagePicker.js View on Github external
const style = { marginLeft: 5 };
      if (locale.language === language && locale.country === country) {
        style.color = "white";
        style.background = "red";
      }
      return (
        
          <a style="{style}">{data[language].language}</a>
        
      );
    })}
  
);

LanguagePicker.propTypes = {
  locale: localeShape.isRequired,
  siteLocales: PropTypes.arrayOf(PropTypes.string.isRequired).isRequired
};

export default withLocale(LanguagePicker);
github traveloka / soya-next / examples / i18n-with-redux / components / Dictionary.js View on Github external
import { connect } from "react-redux";
import { applyReducers } from "soya-next/redux";
import { withLocale } from "soya-next/i18n";
import { localeShape } from "soya-next/prop-types";
import dictionary from "../reducers/DictionaryReducer";
import { generateId } from "../utils/DictionaryUtil";
import { fetchTranslation } from "../actions/DictionaryAction";

class Dictionary extends React.Component {
  static propTypes = {
    component: PropTypes.node,
    renderProp: PropTypes.string,
    entryKey: PropTypes.string.isRequired,
    params: PropTypes.object,
    translation: PropTypes.string,
    locale: localeShape.isRequired,
    fetchTranslation: PropTypes.func.isRequired
  };

  static defaultProps = {
    component: "span",
    renderProp: "children",
    params: null
  };

  componentDidMount() {
    this.props.fetchTranslation();
  }

  componentDidUpdate(prevProps) {
    if (
      this.props.locale.language !== prevProps.locale.language ||
github traveloka / soya-next / examples / i18n / components / Layout.js View on Github external
<a>{data[locale.language].menuHome}</a>
      {" "}
      
        <a>{data[locale.language].menuAboutUs}</a>
      
    
    {children}
    <hr>
    
  
);

Layout.propTypes = {
  children: PropTypes.node,
  locale: localeShape.isRequired,
  siteLocales: PropTypes.arrayOf(PropTypes.string.isRequired).isRequired
};

export default withLocale(Layout);