1
0
forked from noxious/server

Renamed utilities to files, added datetimeManager, npm update

This commit is contained in:
2024-10-13 12:15:29 +02:00
parent 2008646a3f
commit 049b9de2b3
20 changed files with 157 additions and 43 deletions

View File

@ -1,5 +1,6 @@
import config from './config'
import path from 'path'
import fs from 'fs'
export function getRootPath(folder: string, ...additionalSegments: string[]) {
return path.join(process.cwd(), folder, ...additionalSegments)
@ -13,3 +14,20 @@ export function getAppPath(folder: string, ...additionalSegments: string[]) {
export function getPublicPath(folder: string, ...additionalSegments: string[]) {
return path.join(process.cwd(), 'public', folder, ...additionalSegments)
}
export function doesPathExist(path: string) {
try {
fs.accessSync(path, fs.constants.F_OK);
return true;
} catch (e) {
return false;
}
}
export function createDir(path: string) {
try {
fs.mkdirSync(path, { recursive: true });
} catch (e) {
console.error(e);
}
}

View File

@ -12,7 +12,7 @@ import fs from 'fs'
import zoneRepository from '../repositories/zoneRepository'
import zoneManager from '../managers/zoneManager'
import { httpLogger } from './logger'
import { getPublicPath } from './utilities'
import { getPublicPath } from './files'
async function addHttpRoutes(app: Application) {
/**

View File

@ -1,6 +1,6 @@
import pino from 'pino'
import fs from 'fs'
import { getRootPath } from './utilities'
import { getRootPath } from './files'
// Array of log types
const LOG_TYPES = ['http', 'game', 'gameMaster', 'app', 'queue', 'command'] as const