This repository has been archived on 2022-08-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
outline/server/index.js
Tom Moor 52765d9d1d Document Viewers (#79)
* Recording document views

* Add 'views' to document response

* Basic displaying of document views, probably want it more sublte than this? But hey, lets get it in there

* Bigly improves. RESTful > RPC

* Display of who's viewed doc

* Add Popover, add Scrollable, move views store

* Working server tests 💁

* Document Stars (#81)

* Added: Starred documents

* UI is dumb but functionality works

* Star now displayed inline in title

* Optimistic rendering

* Documents Endpoints (#85)

* More seeds, documents.list endpoint

* Upgrade deprecated middleware

* document.viewers, specs

* Add documents.starred
Add request specs for star / unstar endpoints

* Basic /starred page

* Remove comment

* Fixed double layout
2017-06-25 17:21:33 -07:00

84 lines
1.9 KiB
JavaScript

import compress from 'koa-compress';
import { contentSecurityPolicy } from 'koa-helmet';
import logger from 'koa-logger';
import mount from 'koa-mount';
import Koa from 'koa';
import bugsnag from 'bugsnag';
import api from './api';
import routes from './routes';
const app = new Koa();
app.use(compress());
if (process.env.NODE_ENV === 'development') {
/* eslint-disable global-require */
const convert = require('koa-convert');
const webpack = require('webpack');
const devMiddleware = require('koa-webpack-dev-middleware');
const hotMiddleware = require('koa-webpack-hot-middleware');
const config = require('../webpack.config.dev');
const compile = webpack(config);
/* eslint-enable global-require */
app.use(
convert(
devMiddleware(compile, {
// display no info to console (only warnings and errors)
noInfo: true,
// display nothing to the console
quiet: false,
// switch into lazy mode
// that means no watching, but recompilation on every request
lazy: false,
// // watch options (only lazy: false)
// watchOptions: {
// aggregateTimeout: 300,
// poll: true
// },
// public path to bind the middleware to
// use the same as in webpack
publicPath: config.output.publicPath,
// options for formating the statistics
stats: {
colors: true,
},
})
)
);
app.use(
convert(
hotMiddleware(compile, {
log: console.log, // eslint-disable-line
path: '/__webpack_hmr',
heartbeat: 10 * 1000,
})
)
);
app.use(logger());
}
if (process.env.NODE_ENV === 'production') {
bugsnag.register('ad7a85f99b1b9324a31e16732cdf3192');
}
app.use(mount('/api', api));
app.use(mount(routes));
app.use(
contentSecurityPolicy({
directives: {
defaultSrc: ["'self'"],
styleSrc: ["'self'", "'unsafe-inline'"],
},
})
);
export default app;