Skip to content

Instantly share code, notes, and snippets.

View webislife's full-sized avatar
😜
Amazing

Denis webislife

😜
Amazing
View GitHub Profile
@webislife
webislife / clientIndex.js
Created April 18, 2019 20:18
Sample vue client index js
import { createApp } from '@root/app.js';
import { Cookies } from './lib/cookie.js';
const APP = createApp();
global.cookies = new Cookies({env: 'browser'});
global.APP = APP;
if (window.__INITIAL_STATE__) {
APP.Store.replaceState(window.__INITIAL_STATE__);
}
const path = require('path');
const LRU = require('lru-cache');
const fastify = require('fastify');
const server = fastify({
logger: false,
});
const bundle = require('./../dist/vue-ssr-server-bundle.json');
const vueRenderer = require('vue-server-renderer');
const fs = require('fs');
const templatePath = path.resolve(__dirname, './index.html');
import {instance} from './instance.js';
import {SwaggerApi} from './swagger.js';
export class BiglionApi extends SwaggerApi {
constructor() {
super();
this.Request = instance;
}
/**
import {instance} from './instance.js';
import {SwaggerApi} from './swagger.js';
export class MainApi extends SwaggerApi {
constructor() {
super();
this.Request = instance;
}
/**
import axios from 'axios';
export const instance = axios.create({
baseURL: appConf.BACKEND_HOST,
});
/**
* Cookies интерфейс для универсального node\broswer доступа к кукам
*/
export class Cookies {
constructor (options) {
this.env = options.env;
if(this.env === 'browser') {
this.Interface = new require('js-cookie');
}
if(this.env === "node") {
//Get current ENV
//Options reference: https://pm2.io/doc/en/runtime/reference/ecosystem-file/
const
ENV = process.env.APP_ENV,
ENV_CONF = require(`./pm2.${ENV}.js`);
if(ENV === undefined){
console.error(`ERROR: Undefined envoirment: ${ENV}. Start stopped.`);
process.exit(1);
const ENVOIRMENT = require('./env.development.js');
module.exports = {
APPS: [
{
name: 'SSR',
script: 'src/server.js',
instances: 1,
exec_mode: 'fork',
autorestart: true,
let ENVOIRMENT = require('./env.production.js'),
GREEN_ENV = Object.assign({
SSR_PORT: 8080,
}, ENVOIRMENT),
BLUE_ENV = Object.assign({
SSR_PORT: 9090,
}, ENVOIRMENT);
console.log('GREEN ENV', GREEN_ENV);
console.log('BLUE ENV', BLUE_ENV);
@webislife
webislife / vuessr.nginx.conf
Created April 19, 2019 10:17
example nginx config for vue ssr
#GREEN
upstream NODE_SSR_GREEN { server 127.0.0.1:8080; }
upstream NODE_SSR_BLUE { server 127.0.0.1:8082; }
#Основной сервер
server {
set $ACTIVE_SSR NODE_SSR_GREEN;
set $APP_ROOT /var/www/app-GREEN/dist;
server_name vue.ssr;