tnc-ca-geo / animl-api

Backend for https://animl.camera
4 stars 0 forks source link

TypeScript 5: Convert schemas #205

Closed alukach closed 2 weeks ago

alukach commented 2 weeks ago

What I'm changing

This PR converts all of our Mongoose schema files to TS.

How I did it

The conversion was pretty straight forward:

  1. Rename all files from .js to .ts
  2. Add a typing for the untyped mongo-cursor-pagination module
  3. While I was at it, I ran prettier on all of the files as well.

UPDATE

I've updated this PR with 0022ca2 to export a schema type from every file. This will provide us a type to conveniently describe the output of DB queries, such as:

import Batch, { BatchSchema } from '../schema/batch.js'

function query(): Promise<BatchSchema> {
    return Batch.findOne()
}

Relates to #187