1
0
Fork 0
chronos/server/index.js

26 lines
583 B
JavaScript
Raw Permalink Normal View History

2017-03-02 09:55:04 +08:00
import path from 'path';
import express from 'express';
2017-04-06 21:20:23 +08:00
2017-03-02 09:55:04 +08:00
import Database from './database';
import API from './api';
const app = express();
const database = new Database({
host: 'localhost',
user: 'root',
password: '',
});
const api = new API(database);
2017-03-30 20:55:54 +08:00
// API mount
2017-03-02 09:55:04 +08:00
app.use('/api/v1', api.router);
2017-03-30 20:55:54 +08:00
// API fallback
app.use('/api', (req, res) => res.end('API'));
// Assets
app.use('/', express.static(path.join(__dirname, '..', 'app')));
// Pages
app.get('/*', (req, res) => res.sendFile(path.join(__dirname, '..', 'app', 'index.html')));
2017-03-02 09:55:04 +08:00
2017-03-30 20:55:54 +08:00
app.listen(process.env.PORT || 8080);