server: use import/export syntax

This commit is contained in:
Jesse Chan
2020-09-16 22:22:25 +08:00
parent 0b2f3a45c1
commit 501900858c
50 changed files with 264 additions and 246 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
const services = require('../services');
import services from '../services';
module.exports = (req, res, next) => {
export default (req, res, next) => {
req.services = services.getAllServices(req.user);
next();
};
+1 -1
View File
@@ -1,4 +1,4 @@
module.exports = (key) => (req, res, next) => {
export default (key) => (req, res, next) => {
const value = req.body && req.body[key];
if (value && typeof value === 'string') {
+12 -12
View File
@@ -1,16 +1,16 @@
const clientGatewayServiceEvents = require('../constants/clientGatewayServiceEvents');
const historyServiceEvents = require('../constants/historyServiceEvents');
const historySnapshotTypes = require('../../shared/constants/historySnapshotTypes');
const notificationServiceEvents = require('../constants/notificationServiceEvents');
const ServerEvent = require('../models/ServerEvent');
const serverEventTypes = require('../../shared/constants/serverEventTypes');
const services = require('../services');
const taxonomyServiceEvents = require('../constants/taxonomyServiceEvents');
const torrentServiceEvents = require('../constants/torrentServiceEvents');
const diskUsageServiceEvents = require('../constants/diskUsageServiceEvents');
const DiskUsageService = require('../services/diskUsageService');
import clientGatewayServiceEvents from '../constants/clientGatewayServiceEvents';
import historyServiceEvents from '../constants/historyServiceEvents';
import historySnapshotTypes from '../../shared/constants/historySnapshotTypes';
import notificationServiceEvents from '../constants/notificationServiceEvents';
import ServerEvent from '../models/ServerEvent';
import serverEventTypes from '../../shared/constants/serverEventTypes';
import services from '../services';
import taxonomyServiceEvents from '../constants/taxonomyServiceEvents';
import torrentServiceEvents from '../constants/torrentServiceEvents';
import diskUsageServiceEvents from '../constants/diskUsageServiceEvents';
import DiskUsageService from '../services/diskUsageService';
module.exports = (req, res) => {
export default (req, res) => {
const {
query: {historySnapshot = historySnapshotTypes.FIVE_MINUTE},
user,
+1 -1
View File
@@ -1,4 +1,4 @@
module.exports = (req, res, next) => {
export default (req, res, next) => {
req.socket.setKeepAlive(true);
req.socket.setTimeout(0);
+1 -1
View File
@@ -1,4 +1,4 @@
module.exports = (req, res, next) => {
export default (req, res, next) => {
if (req.user == null || !req.user.isAdmin) {
return res.status(403).json({message: 'User is not admin.'}).send();
}