This repository has been archived on 2022-08-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
outline/server/services/index.js
2020-04-19 22:14:31 -07:00

27 lines
623 B
JavaScript

// @flow
import debug from 'debug';
import fs from 'fs-extra';
import path from 'path';
const log = debug('services');
const services = {};
fs
.readdirSync(__dirname)
.filter(
file =>
file.indexOf('.') !== 0 &&
file !== path.basename(__filename) &&
!file.includes('.test')
)
.forEach(fileName => {
const servicePath = path.join(__dirname, fileName);
const name = path.basename(servicePath.replace(/\.js$/, ''));
// $FlowIssue
const Service = require(servicePath).default;
services[name] = new Service();
log(`loaded ${name} service`);
});
export default services;