flowtyped everything, some functional, safety, and structural changes

This commit is contained in:
41666 2019-03-10 03:18:11 -05:00
parent 6f3eca7a64
commit d2aecb38ca
92 changed files with 17554 additions and 1440 deletions

View file

@ -1,9 +1,14 @@
const log = new (require('../logger'))('api/index')
const glob = require('glob')
// @flow
import logger from '../logger'
import glob from 'glob'
import type { Router, AppContext } from '../Roleypoly'
const log = logger(__filename)
const PROD = process.env.NODE_ENV === 'production'
module.exports = async (router, ctx, { forceClear = false } = {}) => {
export default async (router: Router, ctx: AppContext, { forceClear = false }: { forceClear: boolean } = {}) => {
const apis = glob.sync(`./api/**/!(index).js`)
log.debug('found apis', apis)
@ -18,7 +23,8 @@ module.exports = async (router, ctx, { forceClear = false } = {}) => {
if (forceClear) {
delete require.cache[require.resolve(pathname)]
}
require(pathname)(router, ctx)
// $FlowFixMe this isn't an important error. potentially dangerous, but irrelevant.
require(pathname).default(router, ctx)
} catch (e) {
log.error(`couldn't mount ${a}`, e)
}