Skip to content

Commit 075d65f

Browse files
committed
chore(import): implement native subpath import for types
Configures the `#types` alias to resolve directly to the type declarations in `src/types/index.d.ts`. Signed-off-by: Jeremy Ho <jujaga@gmail.com>
1 parent 6f1f66e commit 075d65f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+50
-53
lines changed

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
"author": "NRM Permitting and Data Solutions <NRM.PermittingAndData@gov.bc.ca>",
88
"type": "module",
99
"main": "server.ts",
10+
"imports": {
11+
"#types": "./src/types/index.d.ts"
12+
},
1013
"scripts": {
1114
"commitlint": "commitlint",
1215
"codegen": "kysely-codegen --url $(node dburl.helper.ts)",

src/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { state } from './state.ts';
1313
import { getLogger, httpLogger, Problem } from './utils/index.ts';
1414

1515
import type { NextFunction, Request, Response } from 'express';
16-
import type { LocalContext } from './types/index.d.ts';
16+
import type { LocalContext } from '#types';
1717

1818
const log = getLogger(import.meta.filename);
1919

src/controllers/record.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
} from '../services/index.ts';
88

99
import type { Request, Response } from 'express';
10-
import type { LocalContext, Record, SystemRecordQuery } from '../types/index.d.ts';
10+
import type { LocalContext, Record, SystemRecordQuery } from '#types';
1111

1212
export const getRecordController = async (
1313
req: Request<never, never, never, SystemRecordQuery>,

src/controllers/systemRecord.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { deleteSystemRecordService, findSingleSystemRecordService } from '../services/index.ts';
22

33
import type { Request, Response } from 'express';
4-
import type { SystemRecordQuery } from '../types/index.d.ts';
4+
import type { SystemRecordQuery } from '#types';
55

66
export const deleteSystemRecordController = async (
77
req: Request<never, never, never, Required<SystemRecordQuery>>,

src/db/database.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { getLogger } from '../utils/index.ts';
99

1010
import type { LogEvent, Migration } from 'kysely';
1111
import type { Seed } from 'kysely-ctl';
12-
import type { DB } from '../types/index.d.ts';
12+
import type { DB } from '#types';
1313

1414
const log = getLogger(import.meta.filename);
1515

@@ -243,5 +243,3 @@ export async function runSeeds() {
243243
export function shutdownDatabase(cb?: () => void): Promise<void> {
244244
return db.destroy().then(cb); // Also invokes pool.end()
245245
}
246-
247-
export * from './utils.ts';

src/db/seeds/1749226922436_pies-v0.1.0.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { CodingDictionary } from '../../utils/index.ts';
22

33
import type { Kysely } from 'kysely';
4-
import type { DB } from '../../types/index.d.ts';
4+
import type { DB } from '#types';
55

66
const VERSION = '0.1.0';
77

src/middlewares/auth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { getBearerToken, getJwksClient, normalizeScopes, setAuthHeader } from '.
55
import { Problem } from '../utils/index.ts';
66
import { state } from '../state.ts';
77

8-
import type { AuthErrorAttributes, AuthErrorCodes, AuthRequestHandler, SystemSource } from '../types/index.d.ts';
8+
import type { AuthErrorAttributes, AuthErrorCodes, AuthRequestHandler, SystemSource } from '#types';
99

1010
/** Default authentication error attributes */
1111
const defaultAttributes: AuthErrorAttributes = {

src/middlewares/helpers/oauth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { getLogger } from '../../utils/index.ts';
44

55
import type { Request, Response } from 'express';
66
import type { JwksClient } from 'jwks-rsa';
7-
import type { AuthErrorAttributes } from '../../types/index.d.ts';
7+
import type { AuthErrorAttributes } from '#types';
88

99
const log = getLogger(import.meta.filename);
1010

src/middlewares/validator.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@ import { validateIntegrity, validateSchema } from '../validators/index.ts';
33

44
import type { ErrorObject, SchemaObject } from 'ajv';
55
import type { RequestHandler } from 'express';
6-
import type {
7-
IntegrityDictionary,
8-
IntegrityError,
9-
RequestIntegrityOptions,
10-
RequestSchemaOptions
11-
} from '../types/index.d.ts';
6+
import type { IntegrityDictionary, IntegrityError, RequestIntegrityOptions, RequestSchemaOptions } from '#types';
127

138
/**
149
* Validates the data integrity of the incoming request by checking its body, headers, params, and query.

src/repositories/base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type {
1414
SelectQueryBuilder,
1515
Transaction
1616
} from 'kysely';
17-
import type { DB } from '../types/index.d.ts';
17+
import type { DB } from '#types';
1818

1919
/**
2020
* Abstract base class for repository implementations.

0 commit comments

Comments
 (0)