-
Notifications
You must be signed in to change notification settings - Fork 33
/
server.js
43 lines (41 loc) · 1.8 KB
/
server.js
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
40
41
42
43
const express = require('express');
const config = require('./configLoader.js');
const multer = require('multer')({ dest: `./${config.folders.temp}` });
const api = require('./api.js');
let app = express();
app.use(express.json());
app.use(express.urlencoded({
extended: true
}));
app.get('/', (req, res) => res.redirect('/dashboard'));
app.get('/favicon.ico', api.favicon);
app.get('/dashboard', api.dashboard);
app.get('/projects', api.projects);
app.get('/runnable', api.contentTypes);
app.get('/export/:library/:folder', api.export);
app.post('/import/:folder', multer.single('file'), api.import);
app.post('/create/:type/:folder', api.create);
app.post('/remove/:folder', api.remove);
app.get('/split/:library/:folder', api.splitView);
app.get('/view/:library/:folder', api.view);
app.get('/edit/:library/:folder/libraries', api.ajaxLibraries);
app.post('/edit/:library/:folder/translations', api.ajaxTranslations);
app.get('/edit/:library/:folder', api.edit);
app.post('/edit/:library/:folder/libraries', api.ajaxLibraries);
app.post('/edit/:library/:folder/files', multer.single('file'), api.uploadFile);
app.post('/edit/:library/:folder', multer.none(), api.saveContent);
app.get('/content-user-data/:folder/:type/:id', api.getUserData);
app.post('/content-user-data/:folder/:type/:id', api.setUserData);
app.delete('/content-user-data/:folder', api.resetUserData);
app.use(`/${config.folders.assets}`, express.static(`${require.main.path}/${config.folders.assets}`))
app.use(express.static('./'));
let port = config.port;
app.listen(port, () => {
console.log(`h5p content type development server running on http://localhost:${port}/dashboard`);
});
if (config.files.watch) {
const eye = require('livereload').createServer({
exclusions: config?.files?.watchExclusions ?? []
});
eye.watch(config.folders.libraries);
}