forked from noxious/server
npm run format
This commit is contained in:
parent
c4a42066ab
commit
709d34d59b
@ -21,25 +21,25 @@ class DateManager {
|
|||||||
// When a GM sets the time, update the current date and update the world file
|
// When a GM sets the time, update the current date and update the world file
|
||||||
public async setTime(time: string): Promise<void> {
|
public async setTime(time: string): Promise<void> {
|
||||||
try {
|
try {
|
||||||
let newDate: Date;
|
let newDate: Date
|
||||||
|
|
||||||
// Check if it's just a time (HH:mm or HH:mm:ss format)
|
// Check if it's just a time (HH:mm or HH:mm:ss format)
|
||||||
if (/^\d{1,2}:\d{2}(:\d{2})?$/.test(time)) {
|
if (/^\d{1,2}:\d{2}(:\d{2})?$/.test(time)) {
|
||||||
const [hours, minutes] = time.split(':').map(Number);
|
const [hours, minutes] = time.split(':').map(Number)
|
||||||
newDate = new Date(this.currentDate); // Clone current date
|
newDate = new Date(this.currentDate) // Clone current date
|
||||||
newDate.setHours(hours, minutes);
|
newDate.setHours(hours, minutes)
|
||||||
} else {
|
} else {
|
||||||
// Treat as full datetime string
|
// Treat as full datetime string
|
||||||
newDate = new Date(time);
|
newDate = new Date(time)
|
||||||
if (isNaN(newDate.getTime())) return;
|
if (isNaN(newDate.getTime())) return
|
||||||
}
|
}
|
||||||
|
|
||||||
this.currentDate = newDate;
|
this.currentDate = newDate
|
||||||
this.emitDate();
|
this.emitDate()
|
||||||
await this.saveDate();
|
await this.saveDate()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
appLogger.error(`Failed to set time: ${error instanceof Error ? error.message : String(error)}`);
|
appLogger.error(`Failed to set time: ${error instanceof Error ? error.message : String(error)}`)
|
||||||
throw error;
|
throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,9 +28,11 @@ export class Server {
|
|||||||
*/
|
*/
|
||||||
constructor() {
|
constructor() {
|
||||||
this.app = express()
|
this.app = express()
|
||||||
this.app.use(cors({
|
this.app.use(
|
||||||
origin: config.CLIENT_URL
|
cors({
|
||||||
}))
|
origin: config.CLIENT_URL
|
||||||
|
})
|
||||||
|
)
|
||||||
this.app.use(express.json())
|
this.app.use(express.json())
|
||||||
this.app.use(express.urlencoded({ extended: true }))
|
this.app.use(express.urlencoded({ extended: true }))
|
||||||
this.http = httpServer(this.app)
|
this.http = httpServer(this.app)
|
||||||
|
@ -8,7 +8,6 @@ class PasswordResetTokenService {
|
|||||||
* @param token
|
* @param token
|
||||||
*/
|
*/
|
||||||
public async delete(token: string): Promise<boolean> {
|
public async delete(token: string): Promise<boolean> {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const tokenData = await passwordResetTokenRepository.getByToken(token)
|
const tokenData = await passwordResetTokenRepository.getByToken(token)
|
||||||
if (!tokenData) {
|
if (!tokenData) {
|
||||||
|
@ -23,7 +23,7 @@ export default class TeleportCommandEvent {
|
|||||||
private async handleTeleportCommand(data: TypePayload, callback: (response: boolean) => void): Promise<void> {
|
private async handleTeleportCommand(data: TypePayload, callback: (response: boolean) => void): Promise<void> {
|
||||||
try {
|
try {
|
||||||
// Check if character exists
|
// Check if character exists
|
||||||
const character = await CharacterRepository.getByUserAndId(this.socket.user?.id as number, this.socket.characterId as number) as ExtendedCharacter
|
const character = (await CharacterRepository.getByUserAndId(this.socket.user?.id as number, this.socket.characterId as number)) as ExtendedCharacter
|
||||||
if (!character) {
|
if (!character) {
|
||||||
gameLogger.error('chat:alert_command error', 'Character not found')
|
gameLogger.error('chat:alert_command error', 'Character not found')
|
||||||
callback(false)
|
callback(false)
|
||||||
|
@ -42,10 +42,7 @@ export const resetPasswordSchema = z.object({
|
|||||||
})
|
})
|
||||||
|
|
||||||
export const newPasswordSchema = z.object({
|
export const newPasswordSchema = z.object({
|
||||||
urlToken: z
|
urlToken: z.string().min(10, { message: 'Invalid request' }).max(255, { message: 'Invalid request' }),
|
||||||
.string()
|
|
||||||
.min(10, { message: 'Invalid request' })
|
|
||||||
.max(255, { message: 'Invalid request' }),
|
|
||||||
password: z
|
password: z
|
||||||
.string()
|
.string()
|
||||||
.min(8, {
|
.min(8, {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user