+ CLOUD PAGES; style updated; other changes
This commit is contained in:
1 parent
dad12f52f4
commit
edf5fbf4bd
27 files changed
+339
-161
No files matched your search
+41
-39
@@ -6,61 +6,63 @@ import logger from 'koa-logger';
|
||||
import convert from 'koa-convert';
|
||||
import conditional from 'koa-conditional-get';
|
||||
import etag from 'koa-etag';
|
||||
// import prerender from 'koa-prerender';
|
||||
import prerender from 'koa-prerender';
|
||||
import helmet from 'koa-helmet';
|
||||
import mount from 'koa-mount';
|
||||
import bodyParser from 'koa-bodyparser';
|
||||
|
||||
import api_v1 from 'hudozka-api-v1';
|
||||
import config from './config';
|
||||
import {redirectionTable} from './config';
|
||||
import apiV1 from 'hudozka-api-v1';
|
||||
import config, {redirectionTable} from './config';
|
||||
import {routes, queryObject} from './routes';
|
||||
import {redirect} from './routes/redirect';
|
||||
import {services as serviceKeys, authChecker} from './core/service';
|
||||
import handlebars from 'handlebars';
|
||||
|
||||
const dirPublic = path.join(__dirname, '../public');
|
||||
const dirTemplates = path.join(__dirname, 'templates');
|
||||
|
||||
export default function(store){
|
||||
const $ = convert;
|
||||
|
||||
const app = new Koa();
|
||||
app.proxy = true;
|
||||
handlebars.registerHelper('raw-helper', options => options.fn());
|
||||
|
||||
app.use(bodyParser({
|
||||
extendTypes: {
|
||||
json: 'application/ejson'
|
||||
}
|
||||
}));
|
||||
app.use(logger());
|
||||
app.use(apis(store));
|
||||
app.use($(conditional()));
|
||||
app.use($(etag()));
|
||||
// app.use(prerenderRmFragment());
|
||||
// app.use($(prerender(config.prerender)));
|
||||
app.use(serve(dirPublic));
|
||||
app.use(serve(dirTemplates));
|
||||
app.use($(redirect(redirectionTable)));
|
||||
app.use($(helmet()));
|
||||
app.use(queryObject());
|
||||
app.use(routes());
|
||||
export default function (store) {
|
||||
const $ = convert;
|
||||
|
||||
return Server(app.callback());
|
||||
const app = new Koa();
|
||||
app.proxy = true;
|
||||
|
||||
app.use(bodyParser({
|
||||
extendTypes: {
|
||||
json: 'application/ejson'
|
||||
}
|
||||
}));
|
||||
app.use(logger());
|
||||
app.use(apis(store));
|
||||
app.use($(conditional()));
|
||||
app.use($(etag()));
|
||||
app.use(prerenderRmFragment());
|
||||
app.use($(prerender(config.prerender)));
|
||||
app.use(serve(dirPublic));
|
||||
app.use(serve(dirTemplates));
|
||||
app.use($(redirect(redirectionTable)));
|
||||
app.use($(helmet()));
|
||||
app.use(queryObject());
|
||||
app.use(routes());
|
||||
|
||||
return Server(app.callback());
|
||||
}
|
||||
|
||||
function apis(store){
|
||||
let checkAuth = authChecker(serviceKeys);
|
||||
return mount('/api/v1', api_v1(checkAuth, store));
|
||||
function apis(store) {
|
||||
let checkAuth = authChecker(serviceKeys);
|
||||
return mount('/api/v1', apiV1(checkAuth, store));
|
||||
}
|
||||
|
||||
function prerenderRmFragment(){
|
||||
return async (ctx, next) => {
|
||||
await next();
|
||||
function prerenderRmFragment() {
|
||||
return async(ctx, next) => {
|
||||
await next();
|
||||
|
||||
try {
|
||||
let xp = ctx.response.header['x-prerender'] == 'true';
|
||||
if (xp) ctx.body = ctx.body.replace('<meta name="fragment" content="!">', '');
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
try {
|
||||
let xp = ctx.response.header['x-prerender'] === 'true';
|
||||
if (xp) ctx.body = ctx.body.replace('<meta name="fragment" content="!">', '');
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user