backend: add return types to load.ts functions

This commit is contained in:
Norm 2022-09-10 13:52:23 -04:00
parent ebc4daa6c2
commit 8d5966c0bc
Signed by untrusted user: norm
GPG key ID: 7123E30E441E80DE

View file

@ -6,7 +6,7 @@ import * as fs from 'node:fs';
import { fileURLToPath } from 'node:url';
import { dirname } from 'node:path';
import * as yaml from 'js-yaml';
import { Source, Mixin } from './types.js';
import { Source, Mixin, Config } from './types.js';
const _filename = fileURLToPath(import.meta.url);
const _dirname = dirname(_filename);
@ -23,7 +23,7 @@ const path = process.env.NODE_ENV === 'test'
? `${dir}/test.yml`
: `${dir}/default.yml`;
export default function load() {
export default function load(): Config {
const meta = JSON.parse(fs.readFileSync(`${_dirname}/../../../../built/meta.json`, 'utf-8'));
const clientManifest = JSON.parse(fs.readFileSync(`${_dirname}/../../../../built/_client_dist_/manifest.json`, 'utf-8'));
const config = yaml.load(fs.readFileSync(path, 'utf-8')) as Source;
@ -55,7 +55,7 @@ export default function load() {
return Object.assign(config, mixin);
}
function tryCreateUrl(url: string) {
function tryCreateUrl(url: string): URL {
try {
return new URL(url);
} catch (e) {