diff --git a/bootstrap/bootstrap_host.ts b/bootstrap/bootstrap_host.ts index 9b5d265..1e91a68 100644 --- a/bootstrap/bootstrap_host.ts +++ b/bootstrap/bootstrap_host.ts @@ -1,9 +1,9 @@ import * as bunyan from 'bunyan'; import * as fs from 'fs'; -import Config from '../src/config'; -import Model from '../src/model/model'; +import Config from '../src/config.js'; +import Model from '../src/model/model.js'; -import { HARDWARE_LAB, LOUNGE, PRACTICE_SERVER, SOFTWARE_LAB } from './hosts_info'; +import { HARDWARE_LAB, LOUNGE, PRACTICE_SERVER, SOFTWARE_LAB } from './hosts_info.js'; const config: Config = JSON.parse(fs.readFileSync('config.json', { encoding: 'utf-8' })); diff --git a/bootstrap/rebuild_group_cache.ts b/bootstrap/rebuild_group_cache.ts index 7b953d6..262af12 100644 --- a/bootstrap/rebuild_group_cache.ts +++ b/bootstrap/rebuild_group_cache.ts @@ -1,7 +1,7 @@ import * as bunyan from 'bunyan'; import * as fs from 'fs'; -import Config from '../src/config'; -import Model from '../src/model/model'; +import Config from '../src/config.js'; +import Model from '../src/model/model.js'; const config: Config = JSON.parse(fs.readFileSync('config.json', { encoding: 'utf-8' })); diff --git a/package.json b/package.json index 04242ad..a2d998b 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "bugs": { "url": "https://github.com/bacchus-snu/id/issues" }, + "type": "module", "dependencies": { "@koa/cors": "^5.0.0", "@phc/format": "^1.0.0", diff --git a/src/api/email.ts b/src/api/email.ts index 4309023..7dd6f7c 100644 --- a/src/api/email.ts +++ b/src/api/email.ts @@ -1,7 +1,7 @@ import * as Bunyan from 'bunyan'; import * as nodemailer from 'nodemailer'; -import Config from '../config'; -import { InvalidEmailError, ResendLimitExeededError } from '../model/errors'; +import Config from '../config.js'; +import { InvalidEmailError, ResendLimitExeededError } from '../model/errors.js'; export interface EmailOption { address: string; diff --git a/src/api/handlers/emails.ts b/src/api/handlers/emails.ts index 4b8838c..7bb2e6e 100644 --- a/src/api/handlers/emails.ts +++ b/src/api/handlers/emails.ts @@ -1,11 +1,11 @@ import { IMiddleware } from 'koa-router'; import z from 'zod'; -import Config from '../../config'; -import { EmailAddress } from '../../model/email_addresses'; -import { EmailInUseError, InvalidEmailError, ResendLimitExeededError } from '../../model/errors'; -import Model from '../../model/model'; -import { sendEmail } from '../email'; -import emailVerificationTemplate from '../templates/verification_email_template'; +import Config from '../../config.js'; +import { EmailAddress } from '../../model/email_addresses.js'; +import { EmailInUseError, InvalidEmailError, ResendLimitExeededError } from '../../model/errors.js'; +import Model from '../../model/model.js'; +import { sendEmail } from '../email.js'; +import emailVerificationTemplate from '../templates/verification_email_template.js'; export function sendVerificationEmail(model: Model, config: Config): IMiddleware { const bodySchema = z.object({ diff --git a/src/api/handlers/groups.ts b/src/api/handlers/groups.ts index dbef10f..4453f14 100644 --- a/src/api/handlers/groups.ts +++ b/src/api/handlers/groups.ts @@ -1,8 +1,8 @@ import { IMiddleware } from 'koa-router'; import z from 'zod'; -import { BadParameterError } from '../../model/errors'; -import Model from '../../model/model'; -import { User } from '../../model/users'; +import { BadParameterError } from '../../model/errors.js'; +import Model from '../../model/model.js'; +import { User } from '../../model/users.js'; export function listGroups(model: Model): IMiddleware { return async (ctx, next) => { diff --git a/src/api/handlers/login.ts b/src/api/handlers/login.ts index 74d00e6..ff93335 100644 --- a/src/api/handlers/login.ts +++ b/src/api/handlers/login.ts @@ -1,10 +1,10 @@ import { IMiddleware } from 'koa-router'; import z from 'zod'; -import Config from '../../config'; -import { AuthorizationError, ControllableError, NoSuchEntryError } from '../../model/errors'; -import Model from '../../model/model'; -import { SignatureError, verifyPubkeyReq } from '../pubkey'; +import Config from '../../config.js'; +import { AuthorizationError, ControllableError, NoSuchEntryError } from '../../model/errors.js'; +import Model from '../../model/model.js'; +import { SignatureError, verifyPubkeyReq } from '../pubkey.js'; const loginBodySchema = z.object({ username: z.string(), diff --git a/src/api/handlers/nss.ts b/src/api/handlers/nss.ts index 1c5a37d..05c7e68 100644 --- a/src/api/handlers/nss.ts +++ b/src/api/handlers/nss.ts @@ -1,7 +1,7 @@ import { IMiddleware } from 'koa-router'; -import { NoSuchEntryError } from '../../model/errors'; -import Model from '../../model/model'; +import { NoSuchEntryError } from '../../model/errors.js'; +import Model from '../../model/model.js'; export function getPasswd(model: Model): IMiddleware { return async (ctx, next) => { diff --git a/src/api/handlers/shells.ts b/src/api/handlers/shells.ts index f0da55c..b4c434e 100644 --- a/src/api/handlers/shells.ts +++ b/src/api/handlers/shells.ts @@ -1,5 +1,5 @@ import { IMiddleware } from 'koa-router'; -import Model from '../../model/model'; +import Model from '../../model/model.js'; export function getShells(model: Model): IMiddleware { return async (ctx, next) => { diff --git a/src/api/handlers/users.ts b/src/api/handlers/users.ts index 5396060..bf375b9 100644 --- a/src/api/handlers/users.ts +++ b/src/api/handlers/users.ts @@ -2,12 +2,12 @@ import { createPublicKey } from 'crypto'; import { jwtVerify } from 'jose'; import { IMiddleware } from 'koa-router'; import z from 'zod'; -import Config from '../../config'; -import { EmailAddress } from '../../model/email_addresses'; -import { InvalidEmailError, ResendLimitExeededError, UserExistsError } from '../../model/errors'; -import Model from '../../model/model'; -import { sendEmail } from '../email'; -import changePasswordTemplate from '../templates/change_password_email_template'; +import Config from '../../config.js'; +import { EmailAddress } from '../../model/email_addresses.js'; +import { InvalidEmailError, ResendLimitExeededError, UserExistsError } from '../../model/errors.js'; +import Model from '../../model/model.js'; +import { sendEmail } from '../email.js'; +import changePasswordTemplate from '../templates/change_password_email_template.js'; export function createUser(model: Model, config: Config): IMiddleware { const bodySchema = z.object({ diff --git a/src/api/router.ts b/src/api/router.ts index 13de5b5..44752c8 100644 --- a/src/api/router.ts +++ b/src/api/router.ts @@ -1,9 +1,12 @@ import bodyParser from 'koa-bodyparser'; import Router from 'koa-router'; -import Config from '../config'; -import Model from '../model/model'; -import createOIDCRouter from '../oidc/routes'; -import { checkVerificationEmailToken, sendVerificationEmail } from './handlers/emails'; +import type OIDCProvider from 'oidc-provider'; +import type { Configuration as OIDCConfiguration } from 'oidc-provider'; + +import Config from '../config.js'; +import Model from '../model/model.js'; +import createOIDCRouter from '../oidc/routes.js'; +import { checkVerificationEmailToken, sendVerificationEmail } from './handlers/emails.js'; import { acceptGroup, applyGroup, @@ -12,10 +15,10 @@ import { listMembers, listPending, rejectGroup, -} from './handlers/groups'; -import { checkLogin, login, loginLegacy, loginPAM, logout } from './handlers/login'; -import { getGroup, getPasswd } from './handlers/nss'; -import { getShells } from './handlers/shells'; +} from './handlers/groups.js'; +import { checkLogin, login, loginLegacy, loginPAM, logout } from './handlers/login.js'; +import { getGroup, getPasswd } from './handlers/nss.js'; +import { getShells } from './handlers/shells.js'; import { changePassword, checkChangePasswordEmailToken, @@ -23,10 +26,8 @@ import { getUserEmails, getUserInfo, sendChangePasswordEmail, -} from './handlers/users'; -import { changeUserShell, getUserShell } from './handlers/users'; -// @ts-expect-error: https://github.com/microsoft/TypeScript/issues/49721 -import type OIDCProvider, { Configuration as OIDCConfiguration } from 'oidc-provider'; +} from './handlers/users.js'; +import { changeUserShell, getUserShell } from './handlers/users.js'; export function createRouter( model: Model, diff --git a/src/api/server.ts b/src/api/server.ts index 35f5bd2..bdb6b44 100644 --- a/src/api/server.ts +++ b/src/api/server.ts @@ -3,15 +3,15 @@ import * as Bunyan from 'bunyan'; import * as crypto from 'crypto'; import Koa from 'koa'; import mount from 'koa-mount'; +import OIDCProvider from 'oidc-provider'; -import Config from '../config'; -import Model from '../model/model'; -import createOIDCConfig from '../oidc/configuration'; -import { createRouter } from './router'; +import Config from '../config.js'; +import Model from '../model/model.js'; +import createOIDCConfig from '../oidc/configuration.js'; +import { createRouter } from './router.js'; -const createServer = async (config: Config, log: Bunyan, inputModel?: Model) => { +const createServer = (config: Config, log: Bunyan, inputModel?: Model) => { const model = inputModel ?? new Model(config, log); - const OIDCProvider = (await import('oidc-provider')).default; const oidcConfig = createOIDCConfig(model, config.oidc); const oidcProvider = new OIDCProvider(config.oidc.issuer, oidcConfig); diff --git a/src/config.ts b/src/config.ts index 0a3afdb..b2676f2 100644 --- a/src/config.ts +++ b/src/config.ts @@ -2,7 +2,6 @@ * Configuration. */ -// @ts-expect-error: https://github.com/microsoft/TypeScript/issues/49721 import type { ClientMetadata, JWKS } from 'oidc-provider'; /** diff --git a/src/index.ts b/src/index.ts index fe63948..9129476 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,7 @@ import * as bunyan from 'bunyan'; import * as fs from 'fs'; -import createAPIServer from './api/server'; -import Config from './config'; +import createAPIServer from './api/server.js'; +import Config from './config.js'; const config: Config = JSON.parse(fs.readFileSync('config.json', { encoding: 'utf-8' })); @@ -10,8 +10,8 @@ const log = bunyan.createLogger({ level: config.logLevel, }); -async function run() { - const apiServer = await createAPIServer(config, log); +function run() { + const apiServer = createAPIServer(config, log); apiServer.listen(config.api.listenPort, config.api.listenHost); } diff --git a/src/model/email_addresses.ts b/src/model/email_addresses.ts index 834c351..7728ef6 100644 --- a/src/model/email_addresses.ts +++ b/src/model/email_addresses.ts @@ -1,7 +1,7 @@ import * as crypto from 'crypto'; import moment from 'moment'; -import { ExpiredTokenError, NoSuchEntryError } from './errors'; -import Transaction from './transaction'; +import { ExpiredTokenError, NoSuchEntryError } from './errors.js'; +import Transaction from './transaction.js'; interface EmailAddressRow { address_local: string; diff --git a/src/model/groups.ts b/src/model/groups.ts index c3cd4f4..19a9df1 100644 --- a/src/model/groups.ts +++ b/src/model/groups.ts @@ -1,6 +1,6 @@ -import { NoSuchEntryError } from './errors'; -import Transaction from './transaction'; -import { Translation } from './translation'; +import { NoSuchEntryError } from './errors.js'; +import Transaction from './transaction.js'; +import { Translation } from './translation.js'; interface GroupRow { idx: number; diff --git a/src/model/hosts.ts b/src/model/hosts.ts index 9cb6703..56bd908 100644 --- a/src/model/hosts.ts +++ b/src/model/hosts.ts @@ -1,6 +1,6 @@ -import { AuthorizationError, NoSuchEntryError } from './errors'; -import Model from './model'; -import Transaction from './transaction'; +import { AuthorizationError, NoSuchEntryError } from './errors.js'; +import Model from './model.js'; +import Transaction from './transaction.js'; interface HostRow { idx: number; diff --git a/src/model/model.ts b/src/model/model.ts index 34a9fa4..b4fae2c 100644 --- a/src/model/model.ts +++ b/src/model/model.ts @@ -1,15 +1,15 @@ import * as Bunyan from 'bunyan'; import * as pg from 'pg'; -import Config from '../config'; -import EmailAddresses from './email_addresses'; -import { ControllableError } from './errors'; -import Groups from './groups'; -import Hosts from './hosts'; -import OAuth from './oauth'; -import Permissions from './permissions'; -import Shells from './shells'; -import Transaction from './transaction'; -import Users from './users'; +import Config from '../config.js'; +import EmailAddresses from './email_addresses.js'; +import { ControllableError } from './errors.js'; +import Groups from './groups.js'; +import Hosts from './hosts.js'; +import OAuth from './oauth.js'; +import Permissions from './permissions.js'; +import Shells from './shells.js'; +import Transaction from './transaction.js'; +import Users from './users.js'; const PSQL_SERIALIZATION_FAILURE = '40001'; const PSQL_DEADLOCK_DETECTED = '40P01'; diff --git a/src/model/oauth.ts b/src/model/oauth.ts index 058079f..3c98df3 100644 --- a/src/model/oauth.ts +++ b/src/model/oauth.ts @@ -1,8 +1,7 @@ -// @ts-expect-error: https://github.com/microsoft/TypeScript/issues/49721 import type { AllClientMetadata } from 'oidc-provider'; -import { NoSuchEntryError } from './errors'; -import Transaction from './transaction'; +import { NoSuchEntryError } from './errors.js'; +import Transaction from './transaction.js'; export default class OAuth { public async getClientById(tr: Transaction, id: string): Promise { diff --git a/src/model/permissions.ts b/src/model/permissions.ts index 511dafd..897b8f2 100644 --- a/src/model/permissions.ts +++ b/src/model/permissions.ts @@ -1,7 +1,7 @@ -import { NoSuchEntryError } from './errors'; -import Model from './model'; -import Transaction from './transaction'; -import { Translation } from './translation'; +import { NoSuchEntryError } from './errors.js'; +import Model from './model.js'; +import Transaction from './transaction.js'; +import { Translation } from './translation.js'; export default class Permissions { constructor(private readonly model: Model) { diff --git a/src/model/shells.ts b/src/model/shells.ts index f93e378..1063b0f 100644 --- a/src/model/shells.ts +++ b/src/model/shells.ts @@ -1,4 +1,4 @@ -import Transaction from './transaction'; +import Transaction from './transaction.js'; export default class Shells { constructor() { diff --git a/src/model/users.ts b/src/model/users.ts index 7a1a8ff..dda6917 100644 --- a/src/model/users.ts +++ b/src/model/users.ts @@ -8,9 +8,9 @@ import { ExpiredTokenError, NoSuchEntryError, NotActivatedError, -} from './errors'; -import Model from './model'; -import Transaction from './transaction'; +} from './errors.js'; +import Model from './model.js'; +import Transaction from './transaction.js'; // see language enum in schema.sql export type Language = 'ko' | 'en'; diff --git a/src/oidc/account.ts b/src/oidc/account.ts index 5ca3622..bf1e407 100644 --- a/src/oidc/account.ts +++ b/src/oidc/account.ts @@ -1,4 +1,3 @@ -// @ts-expect-error: https://github.com/microsoft/TypeScript/issues/49721 import type { Account } from 'oidc-provider'; class OIDCAccount implements Account { diff --git a/src/oidc/adapter.ts b/src/oidc/adapter.ts index a195a13..653c35d 100644 --- a/src/oidc/adapter.ts +++ b/src/oidc/adapter.ts @@ -1,9 +1,8 @@ -import Redis from 'ioredis'; -// @ts-expect-error: https://github.com/microsoft/TypeScript/issues/49721 +import { Redis } from 'ioredis'; import type { Adapter, AdapterPayload } from 'oidc-provider'; -import { NoSuchEntryError } from '../model/errors'; -import Model from '../model/model'; +import { NoSuchEntryError } from '../model/errors.js'; +import Model from '../model/model.js'; const grantable = new Set([ 'AccessToken', diff --git a/src/oidc/configuration.ts b/src/oidc/configuration.ts index 0175ed0..7ddcfe0 100644 --- a/src/oidc/configuration.ts +++ b/src/oidc/configuration.ts @@ -1,9 +1,8 @@ -// @ts-expect-error: https://github.com/microsoft/TypeScript/issues/49721 import type { Configuration } from 'oidc-provider'; -import Config from '../config'; -import type Model from '../model/model'; -import OIDCAccount from './account'; -import AdapterFactory from './adapter'; +import Config from '../config.js'; +import type Model from '../model/model.js'; +import OIDCAccount from './account.js'; +import AdapterFactory from './adapter.js'; const claims = { openid: ['sub', 'username', 'groups'], diff --git a/src/oidc/redis.ts b/src/oidc/redis.ts index cad4143..60cbf7f 100644 --- a/src/oidc/redis.ts +++ b/src/oidc/redis.ts @@ -1,5 +1,4 @@ -import Redis from 'ioredis'; -// @ts-expect-error: https://github.com/microsoft/TypeScript/issues/49721 +import { Redis } from 'ioredis'; import type { Adapter, AdapterPayload } from 'oidc-provider'; const grantable = new Set([ diff --git a/src/oidc/routes.ts b/src/oidc/routes.ts index e98cbe4..41522d0 100644 --- a/src/oidc/routes.ts +++ b/src/oidc/routes.ts @@ -1,11 +1,11 @@ import { strict as assert } from 'node:assert'; import Router from 'koa-router'; -// @ts-expect-error: https://github.com/microsoft/TypeScript/issues/49721 import type OIDCProvider from 'oidc-provider'; +import { errors as oidcErrors } from 'oidc-provider'; import * as z from 'zod'; -import Model from '../model/model'; +import Model from '../model/model.js'; const loginSchema = z.object({ username: z.string().nonempty(), @@ -24,13 +24,11 @@ export default (model: Model, provider: OIDCProvider) => { const router = new Router(); router.use(async (ctx, next) => { - const { errors } = await import('oidc-provider'); - ctx.set('cache-control', 'no-store'); try { await next(); } catch (err) { - if (err instanceof errors.SessionNotFound) { + if (err instanceof oidcErrors.SessionNotFound) { ctx.status = err.status; const { message: error, error_description: desc } = err; ctx.body = { error, desc }; diff --git a/test/_setup.ts b/test/_setup.ts index 0f51e27..15c4498 100644 --- a/test/_setup.ts +++ b/test/_setup.ts @@ -2,9 +2,9 @@ import test from 'ava'; import Logger, * as bunyan from 'bunyan'; import * as fs from 'fs'; import { Server } from 'node:http'; -import createAPIServer from '../src/api/server'; -import Config from '../src/config'; -import Model from '../src/model/model'; +import createAPIServer from '../src/api/server.js'; +import Config from '../src/config.js'; +import Model from '../src/model/model.js'; export let config: Config; export let log: Logger; diff --git a/test/_test_utils.ts b/test/_test_utils.ts index 019133c..b4a57f6 100644 --- a/test/_test_utils.ts +++ b/test/_test_utils.ts @@ -1,8 +1,8 @@ import { Server } from 'node:http'; import * as request from 'supertest'; import { v4 as uuid } from 'uuid'; -import Model from '../src/model/model'; -import Transaction from '../src/model/transaction'; +import Model from '../src/model/model.js'; +import Transaction from '../src/model/transaction.js'; export async function createEmailAddress(tr: Transaction, model: Model): Promise { return await model.emailAddresses.create(tr, uuid(), uuid()); diff --git a/test/api/email.test.ts b/test/api/email.test.ts index d2529a2..de73802 100644 --- a/test/api/email.test.ts +++ b/test/api/email.test.ts @@ -2,7 +2,7 @@ import test from 'ava'; import * as nodemailer from 'nodemailer'; import * as request from 'supertest'; import { v4 as uuid } from 'uuid'; -import { app, config, model } from '../_setup'; +import { app, config, model } from '../_setup.js'; test.skip('email configuration is correct', async t => { const emailOption = { diff --git a/test/api/groups.test.ts b/test/api/groups.test.ts index 7c63286..f036aa5 100644 --- a/test/api/groups.test.ts +++ b/test/api/groups.test.ts @@ -1,9 +1,9 @@ import test from 'ava'; import * as request from 'supertest'; import { v4 as uuid } from 'uuid'; -import { GroupUserInfo } from '../../src/model/groups'; -import { app, model } from '../_setup'; -import { createGroup, createGroupRelation, createUser } from '../_test_utils'; +import { GroupUserInfo } from '../../src/model/groups.js'; +import { app, model } from '../_setup.js'; +import { createGroup, createGroupRelation, createUser } from '../_test_utils.js'; test('group listing', async t => { const username = uuid(); diff --git a/test/api/login.test.ts b/test/api/login.test.ts index 386915f..6c6cda2 100644 --- a/test/api/login.test.ts +++ b/test/api/login.test.ts @@ -3,8 +3,8 @@ import moment from 'moment'; import * as request from 'supertest'; import tweetnacl from 'tweetnacl'; import { v4 as uuid } from 'uuid'; -import { app, config, model } from '../_setup'; -import { createAgentForwardedFor } from '../_test_utils'; +import { app, config, model } from '../_setup.js'; +import { createAgentForwardedFor } from '../_test_utils.js'; test('test login with credential', async t => { let username = ''; diff --git a/test/api/nss.test.ts b/test/api/nss.test.ts index 33a2a09..82ecc56 100644 --- a/test/api/nss.test.ts +++ b/test/api/nss.test.ts @@ -1,6 +1,6 @@ import test from 'ava'; -import { app, config, model } from '../_setup'; -import { createAgentForwardedFor, createUser } from '../_test_utils'; +import { app, config, model } from '../_setup.js'; +import { createAgentForwardedFor, createUser } from '../_test_utils.js'; test('fetch passwd entries', async t => { const agent = createAgentForwardedFor(app, '10.0.2.0'); diff --git a/test/api/shells.test.ts b/test/api/shells.test.ts index a5475db..6bfddac 100644 --- a/test/api/shells.test.ts +++ b/test/api/shells.test.ts @@ -1,7 +1,7 @@ import test from 'ava'; import * as request from 'supertest'; import { v4 as uuid } from 'uuid'; -import { app, model } from '../_setup'; +import { app, model } from '../_setup.js'; test('test getShells', async t => { const newShell = uuid(); diff --git a/test/api/users.test.ts b/test/api/users.test.ts index 11075f7..0e5099d 100644 --- a/test/api/users.test.ts +++ b/test/api/users.test.ts @@ -2,7 +2,7 @@ import test, { ExecutionContext } from 'ava'; import * as crypto from 'crypto'; import * as request from 'supertest'; import { v4 as uuid } from 'uuid'; -import { app, config, model } from '../_setup'; +import { app, config, model } from '../_setup.js'; test('create user step by step', async t => { const agent = request.agent(app); diff --git a/test/model/email_addresses.test.ts b/test/model/email_addresses.test.ts index 8ff6477..9aca077 100644 --- a/test/model/email_addresses.test.ts +++ b/test/model/email_addresses.test.ts @@ -3,8 +3,8 @@ import test from 'ava'; import moment from 'moment'; import { v4 as uuid } from 'uuid'; -import { model } from '../_setup'; -import { createEmailAddress, createUser } from '../_test_utils'; +import { model } from '../_setup.js'; +import { createEmailAddress, createUser } from '../_test_utils.js'; test('create extra email', async t => { await model.pgDo(async tr => { diff --git a/test/model/groups.test.ts b/test/model/groups.test.ts index 0ae9f2d..d77d7e8 100644 --- a/test/model/groups.test.ts +++ b/test/model/groups.test.ts @@ -1,11 +1,11 @@ import test from 'ava'; -import { NoSuchEntryError } from '../../src/model/errors'; -import { Translation } from '../../src/model/translation'; +import { NoSuchEntryError } from '../../src/model/errors.js'; +import { Translation } from '../../src/model/translation.js'; import { v4 as uuid } from 'uuid'; -import { model } from '../_setup'; -import { createGroup, createGroupRelation, createUser } from '../_test_utils'; +import { model } from '../_setup.js'; +import { createGroup, createGroupRelation, createUser } from '../_test_utils.js'; const name: Translation = { ko: '도지', diff --git a/test/model/hosts.test.ts b/test/model/hosts.test.ts index 229a930..2178abb 100644 --- a/test/model/hosts.test.ts +++ b/test/model/hosts.test.ts @@ -4,8 +4,8 @@ import { v4 as uuid } from 'uuid'; import * as bunyan from 'bunyan'; import * as fs from 'fs'; -import Config from '../../src/config'; -import Model from '../../src/model/model'; +import Config from '../../src/config.js'; +import Model from '../../src/model/model.js'; const config: Config = JSON.parse(fs.readFileSync('config.test.json', { encoding: 'utf-8' })); diff --git a/test/model/model.test.ts b/test/model/model.test.ts index f502322..5319953 100644 --- a/test/model/model.test.ts +++ b/test/model/model.test.ts @@ -1,6 +1,6 @@ import test from 'ava'; -import { model } from '../_setup'; -import { delay } from '../_test_utils'; +import { model } from '../_setup.js'; +import { delay } from '../_test_utils.js'; test('resolve deadlock', async t => { const transactionStages: Array = [0, 0]; diff --git a/test/model/permissions.test.ts b/test/model/permissions.test.ts index d9420b2..508b201 100644 --- a/test/model/permissions.test.ts +++ b/test/model/permissions.test.ts @@ -1,9 +1,9 @@ import test from 'ava'; -import { Translation } from '../../src/model/translation'; +import { Translation } from '../../src/model/translation.js'; -import { model } from '../_setup'; -import { createGroup, createGroupRelation, createPermission, createUser } from '../_test_utils'; +import { model } from '../_setup.js'; +import { createGroup, createGroupRelation, createPermission, createUser } from '../_test_utils.js'; const name: Translation = { ko: '도지', diff --git a/test/model/shells.test.ts b/test/model/shells.test.ts index ca92032..052d545 100644 --- a/test/model/shells.test.ts +++ b/test/model/shells.test.ts @@ -1,6 +1,6 @@ import test from 'ava'; import { v4 as uuid } from 'uuid'; -import { model } from '../_setup'; +import { model } from '../_setup.js'; test('get, add, and remove shells', async t => { const newShell = uuid(); diff --git a/test/model/users.test.ts b/test/model/users.test.ts index bdd0a7e..3fcf0b0 100644 --- a/test/model/users.test.ts +++ b/test/model/users.test.ts @@ -3,10 +3,14 @@ import test from 'ava'; import * as phc from '@phc/format'; import moment from 'moment'; import { v4 as uuid } from 'uuid'; -import { AuthenticationError, NoSuchEntryError, NotActivatedError } from '../../src/model/errors'; - -import { model } from '../_setup'; -import { createGroup, createUser } from '../_test_utils'; +import { + AuthenticationError, + NoSuchEntryError, + NotActivatedError, +} from '../../src/model/errors.js'; + +import { model } from '../_setup.js'; +import { createGroup, createUser } from '../_test_utils.js'; test('create and delete user', async t => { await model.pgDo(async tr => { diff --git a/tsconfig.json b/tsconfig.json index cd82808..cef8d4c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,20 +1,21 @@ { "compilerOptions": { "outDir": "dist", - "target": "es6", + "target": "ES2020", "lib": [ - "es2018", - "dom" + "ES2020", + "DOM" ], - "module": "node16", - "moduleResolution": "node16", + "module": "NodeNext", + "moduleResolution": "NodeNext", "strict": true, "noUnusedLocals": false, "noUnusedParameters": false, "noImplicitReturns": true, "noFallthroughCasesInSwitch": true, - "downlevelIteration": true, "esModuleInterop": true, + "isolatedModules": true, + "importsNotUsedAsValues": "remove", "typeRoots": [ "./node_modules/@types", "./typings"