[site] updated
This commit is contained in:
1 parent
e9ac51d675
commit
d5db0ca07e
4 files changed
+33
-26
No files matched your search
+21
-22
@@ -1,40 +1,39 @@
|
|||||||
import 'babel-polyfill';
|
import 'babel-polyfill'
|
||||||
|
|
||||||
import config from './config';
|
import config, {name} from './config'
|
||||||
import {name} from './config';
|
import {connect, collection} from './core/db'
|
||||||
import {connect, collection} from './core/db';
|
import io from './io'
|
||||||
import io from './io';
|
import server from './server'
|
||||||
import server from './server';
|
|
||||||
|
|
||||||
import DataManager from 'hudozka-data';
|
import DataManager from 'hudozka-data'
|
||||||
// var DataManager = require('hudozka-data').default;
|
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
async function loop() {
|
async function loop() {
|
||||||
const db = config.db.uri;
|
const db = config.db.uri
|
||||||
await connect(db);
|
await connect(db)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let data = new DataManager({
|
let data = new DataManager({
|
||||||
timeline: collection('timeline'),
|
timeline: collection('timeline'),
|
||||||
schedules: collection('schedules')
|
schedules: collection('schedules'),
|
||||||
});
|
documents: collection('documents'),
|
||||||
|
})
|
||||||
|
|
||||||
let app = server(data);
|
let app = server(data)
|
||||||
io(app, data);
|
io(app, data)
|
||||||
|
|
||||||
app.listen(config.port);
|
app.listen(config.port)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e.stack);
|
console.error(e.stack)
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`App ${name} started`);
|
console.log(`App ${name} started`)
|
||||||
console.log(`listening ${config.port}`);
|
console.log(`listening ${config.port}`)
|
||||||
console.log(`db address ${db}`);
|
console.log(`db address ${db}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
loop();
|
loop()
|
||||||
}
|
}
|
||||||
|
|
||||||
main();
|
main()
|
||||||
@@ -8,14 +8,22 @@ async function exists(ctx, id) {
|
|||||||
return Boolean(i)
|
return Boolean(i)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function () {
|
export default function (store) {
|
||||||
return compose([
|
return compose([
|
||||||
|
docs(store),
|
||||||
documents(),
|
documents(),
|
||||||
document(),
|
document(),
|
||||||
type()
|
type()
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function docs(store) {
|
||||||
|
return route.get('/docs', async ctx => {
|
||||||
|
const docs = await store.document.find({})
|
||||||
|
ctx.body = docs
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function documents() {
|
function documents() {
|
||||||
return route.get('/documents', json(
|
return route.get('/documents', json(
|
||||||
async(ctx) => {
|
async(ctx) => {
|
||||||
|
|||||||
+2
-2
@@ -20,14 +20,14 @@ import pages from './pages';
|
|||||||
|
|
||||||
let main = () => route.get('/', index());
|
let main = () => route.get('/', index());
|
||||||
|
|
||||||
export function routes() {
|
export function routes(store) {
|
||||||
return compose([
|
return compose([
|
||||||
main(),
|
main(),
|
||||||
sitemap(),
|
sitemap(),
|
||||||
schedule(),
|
schedule(),
|
||||||
news(),
|
news(),
|
||||||
gallery(),
|
gallery(),
|
||||||
documents(),
|
documents(store),
|
||||||
teachers(),
|
teachers(),
|
||||||
events(),
|
events(),
|
||||||
articles(),
|
articles(),
|
||||||
|
|||||||
+1
-1
@@ -45,7 +45,7 @@ export default function (store) {
|
|||||||
app.use($(redirect(redirectionTable)));
|
app.use($(redirect(redirectionTable)));
|
||||||
app.use($(helmet()));
|
app.use($(helmet()));
|
||||||
app.use(queryObject());
|
app.use(queryObject());
|
||||||
app.use(routes());
|
app.use(routes(store));
|
||||||
|
|
||||||
return Server(app.callback());
|
return Server(app.callback());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user