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