forked from pawelmalak/flame
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathapi.js
More file actions
39 lines (32 loc) · 1.26 KB
/
api.js
File metadata and controls
39 lines (32 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const { join } = require('path');
const express = require('express');
const { errorHandler } = require('./middleware');
const healthRoutes = require('./routes/health');
const changelog = require('./routes/changelog');
const version = require('./routes/version');
const api = express();
// Register health route BEFORE static content handler
api.use('/health', healthRoutes);
// Static files
api.use(express.static(join(__dirname, 'public')));
api.use('/uploads', express.static(join(__dirname, 'data/uploads')));
// 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'));
api.use('/api/auth', require('./routes/auth'));
api.use('/api/themes', require('./routes/themes'));
api.use('/api/changelog', changelog);
api.use('/app/changelog', changelog);
api.use('/api/version', version);
api.get(/^\/(?!api)/, (req, res) => {
res.sendFile(join(__dirname, 'public/index.html'));
});
// Custom error handler
api.use(errorHandler);
module.exports = api;