Compare commits

...

3 Commits

Author SHA1 Message Date
Norm 91c043689b Merge pull request 'backend: Fix imports from weird paths' (#192) from Michcio/FoundKey-0x7f:extensionless-imports into main
Reviewed-on: FoundKeyGang/FoundKey#192
2022-10-10 18:58:54 +00:00
Michcio 30faeb73d2 backend: Fix type errors in genId
I checked on NodeJS locally and `Math.min` was coercing the Dates to numbers,
I'm just making it more obvious (to the typechecker as well)
2022-10-10 20:50:04 +02:00
Michcio dc510c6834 Fix imports from weird paths
These imports were breaking in TS error checking and VS Code, because
imports need to have an extension to be valid, apparently
2022-10-10 20:45:45 +02:00
3 changed files with 4 additions and 4 deletions

View File

@ -7,8 +7,8 @@ import * as crypto from 'node:crypto';
const TIME2000 = 946684800000;
let counter = crypto.randomBytes(2).readUInt16LE(0);
export function genId(date?: Date = new Date()): string {
let t = Math.min(date, new Date());
export function genId(date: Date = new Date()): string {
let t = Math.min(date.valueOf(), new Date().valueOf());
t -= TIME2000;
if (t < 0) t = 0;
if (isNaN(t)) throw new Error('Failed to create AID: Invalid Date');

View File

@ -2,7 +2,7 @@ import { Note } from '@/models/entities/note.js';
import { Notes } from '@/models/index.js';
import { Packed } from '@/misc/schema.js';
import { IdentifiableError } from '@/misc/identifiable-error.js';
import Connection from '.';
import Connection from './index.js';
/**
* Stream channel

View File

@ -14,7 +14,7 @@ import { AbuseUserReport } from '@/models/entities/abuse-user-report.js';
import { Signin } from '@/models/entities/signin.js';
import { Page } from '@/models/entities/page.js';
import { Packed } from '@/misc/schema.js';
import { Webhook } from '@/models/entities/webhook';
import { Webhook } from '@/models/entities/webhook.js';
//#region Stream type-body definitions
export interface InternalStreamTypes {