mirror of
https://github.com/pawelmalak/flame.git
synced 2024-12-24 18:52:37 +03:00
29 lines
856 B
JavaScript
29 lines
856 B
JavaScript
const { join } = require('path');
|
|
const express = require('express');
|
|
const errorHandler = require('./middleware/errorHandler');
|
|
|
|
const api = express();
|
|
|
|
// Static files
|
|
api.use(express.static(join(__dirname, 'public')));
|
|
api.use('/uploads', express.static(join(__dirname, 'data/uploads')));
|
|
api.get(/^\/(?!api)/, (req, res) => {
|
|
res.sendFile(join(__dirname, 'public/index.html'));
|
|
});
|
|
|
|
// Body parser
|
|
api.use(express.json());
|
|
|
|
// Link controllers with routes
|
|
api.use('/api/apps', require('./routes/apps'));
|
|
api.use('/api/config', require('./routes/config'));
|
|
api.use('/api/weather', require('./routes/weather'));
|
|
api.use('/api/categories', require('./routes/category'));
|
|
api.use('/api/bookmarks', require('./routes/bookmark'));
|
|
api.use('/api/queries', require('./routes/queries'));
|
|
|
|
// Custom error handler
|
|
api.use(errorHandler);
|
|
|
|
module.exports = api;
|