chore: disable auto imports (#2672)
* disable auto imports * fix imports * improve cli imports * fix imports * fix import cycle * fix imports
This commit is contained in:
@@ -2,8 +2,8 @@ import { defineCommand } from 'citty';
|
||||
import { consola } from 'consola';
|
||||
import { eq } from 'drizzle-orm';
|
||||
|
||||
import { db, schema } from '../db';
|
||||
import { hashPassword } from '../../server/utils/password';
|
||||
import { db, schema } from '#cli/db';
|
||||
import { hashPassword } from '#server/utils/password';
|
||||
|
||||
export default defineCommand({
|
||||
meta: {
|
||||
|
||||
+2
-12
@@ -1,6 +1,7 @@
|
||||
// @ts-check
|
||||
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
import esbuild from 'esbuild';
|
||||
|
||||
esbuild.build({
|
||||
@@ -9,17 +10,6 @@ esbuild.build({
|
||||
outfile: fileURLToPath(new URL('../.output/server/cli.mjs', import.meta.url)),
|
||||
platform: 'node',
|
||||
format: 'esm',
|
||||
plugins: [
|
||||
{
|
||||
name: 'make-all-packages-external',
|
||||
setup(build) {
|
||||
let filter = /^[^./]|^\.[^./]|^\.\.[^/]/; // Must not start with "/" or "./" or "../"
|
||||
build.onResolve({ filter }, (args) => ({
|
||||
path: args.path,
|
||||
external: true,
|
||||
}));
|
||||
},
|
||||
},
|
||||
],
|
||||
packages: 'external',
|
||||
logLevel: 'info',
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { defineCommand } from 'citty';
|
||||
import { consola } from 'consola';
|
||||
|
||||
import { db } from '../db';
|
||||
import { db } from '#cli/db';
|
||||
|
||||
export default defineCommand({
|
||||
meta: {
|
||||
|
||||
@@ -2,9 +2,9 @@ import { defineCommand } from 'citty';
|
||||
import { consola } from 'consola';
|
||||
import { eq } from 'drizzle-orm';
|
||||
|
||||
import { wg } from '../../server/utils/wgHelper';
|
||||
import { encodeQRCodeTerm } from '../../server/utils/qr';
|
||||
import { db, schema } from '../db';
|
||||
import { db, schema } from '#cli/db';
|
||||
import { wg } from '#server/utils/wgHelper';
|
||||
import { encodeQRCodeTerm } from '#server/utils/qr';
|
||||
|
||||
export default defineCommand({
|
||||
meta: {
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import { createClient } from '@libsql/client';
|
||||
import { drizzle } from 'drizzle-orm/libsql';
|
||||
|
||||
import * as schema from '../server/database/schema';
|
||||
import * as schema from '#server/database/schema';
|
||||
|
||||
//const client = createClient({ url: 'file:../data/wg-easy.db' });
|
||||
const client = createClient({ url: 'file:/etc/wireguard/wg-easy.db' });
|
||||
|
||||
+4
-3
@@ -6,9 +6,10 @@ import { defineCommand, runMain } from 'citty';
|
||||
import packageJson from '../package.json';
|
||||
|
||||
// Commands
|
||||
import dbAdminReset from './admin/reset';
|
||||
import clientsList from './clients/list';
|
||||
import clientsQr from './clients/qr';
|
||||
import clientsList from '#cli/clients/list';
|
||||
import clientsQr from '#cli/clients/qr';
|
||||
import dbAdminReset from '#cli/admin/reset';
|
||||
|
||||
const subCommands = [dbAdminReset, clientsList, clientsQr] as const;
|
||||
|
||||
// from citty
|
||||
|
||||
@@ -6,7 +6,12 @@
|
||||
"esModuleInterop": true,
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"moduleResolution": "bundler"
|
||||
"moduleResolution": "bundler",
|
||||
"paths": {
|
||||
"#cli/*": ["./*"],
|
||||
"#server/*": ["../server/*"],
|
||||
"#db/*": ["../server/database/*"]
|
||||
}
|
||||
},
|
||||
"include": ["./**/*.ts"]
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import eslintConfigPrettier from 'eslint-config-prettier';
|
||||
|
||||
import withNuxt from './.nuxt/eslint.config.mjs';
|
||||
|
||||
export default withNuxt([
|
||||
{
|
||||
rules: {
|
||||
'import/order': 'warn',
|
||||
'import/order': ['warn', { 'newlines-between': 'always' }],
|
||||
},
|
||||
},
|
||||
eslintConfigPrettier,
|
||||
|
||||
@@ -1,4 +1,13 @@
|
||||
export default defineI18nLocaleDetector((event, config) => {
|
||||
import {
|
||||
tryCookieLocale,
|
||||
tryHeaderLocale,
|
||||
tryQueryLocale,
|
||||
} from '@intlify/utils/h3';
|
||||
import type { H3Event } from 'h3';
|
||||
|
||||
// TODO: use defineI18nLocaleDetector
|
||||
|
||||
export default (event: H3Event, config: { defaultLocale: string }) => {
|
||||
const query = tryQueryLocale(event, { lang: '' });
|
||||
if (query) {
|
||||
return query.toString();
|
||||
@@ -18,4 +27,4 @@ export default defineI18nLocaleDetector((event, config) => {
|
||||
}
|
||||
|
||||
return config.defaultLocale;
|
||||
});
|
||||
};
|
||||
|
||||
+4
-4
@@ -160,21 +160,21 @@ export default defineNuxtConfig({
|
||||
},
|
||||
},
|
||||
nitro: {
|
||||
imports: {
|
||||
autoImport: false,
|
||||
},
|
||||
esbuild: {
|
||||
options: {
|
||||
// to support big int
|
||||
target: 'node20',
|
||||
},
|
||||
},
|
||||
alias: {
|
||||
'#db': fileURLToPath(new URL('./server/database/', import.meta.url)),
|
||||
},
|
||||
externals: {
|
||||
traceInclude: [fileURLToPath(new URL('./cli/index.ts', import.meta.url))],
|
||||
},
|
||||
},
|
||||
alias: {
|
||||
// for typecheck reasons (https://github.com/nuxt/cli/issues/323)
|
||||
'#db': fileURLToPath(new URL('./server/database/', import.meta.url)),
|
||||
'#cli': fileURLToPath(new URL('./cli', import.meta.url)),
|
||||
},
|
||||
});
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
"dependencies": {
|
||||
"@eschricht/nuxt-color-mode": "^1.2.0",
|
||||
"@heroicons/vue": "^2.2.0",
|
||||
"@intlify/h3": "^0.7.4",
|
||||
"@intlify/utils": "^0.14.1",
|
||||
"@libsql/client": "^0.17.3",
|
||||
"@nuxtjs/i18n": "^10.4.0",
|
||||
"@nuxtjs/tailwindcss": "^6.14.0",
|
||||
@@ -38,12 +40,15 @@
|
||||
"consola": "^3.4.2",
|
||||
"crc-32": "^1.2.2",
|
||||
"drizzle-orm": "^0.45.2",
|
||||
"h3": "^1.15.11",
|
||||
"ip-bigint": "^9.0.6",
|
||||
"is-cidr": "^7.0.0",
|
||||
"is-ip": "^5.0.1",
|
||||
"js-sha256": "^0.11.1",
|
||||
"nuxt": "^3.21.8",
|
||||
"nitropack": "^2.13.4",
|
||||
"obug": "^2.1.2",
|
||||
"ofetch": "^1.5.1",
|
||||
"openid-client": "^6.8.4",
|
||||
"otpauth": "^9.5.1",
|
||||
"pinia": "^3.0.4",
|
||||
|
||||
Generated
+15
@@ -14,6 +14,12 @@ importers:
|
||||
'@heroicons/vue':
|
||||
specifier: ^2.2.0
|
||||
version: 2.2.0(vue@3.5.38(typescript@6.0.3))
|
||||
'@intlify/h3':
|
||||
specifier: ^0.7.4
|
||||
version: 0.7.4
|
||||
'@intlify/utils':
|
||||
specifier: ^0.14.1
|
||||
version: 0.14.1
|
||||
'@libsql/client':
|
||||
specifier: ^0.17.3
|
||||
version: 0.17.3
|
||||
@@ -59,6 +65,9 @@ importers:
|
||||
drizzle-orm:
|
||||
specifier: ^0.45.2
|
||||
version: 0.45.2(@libsql/client@0.17.3)
|
||||
h3:
|
||||
specifier: ^1.15.11
|
||||
version: 1.15.11
|
||||
ip-bigint:
|
||||
specifier: ^9.0.6
|
||||
version: 9.0.6
|
||||
@@ -71,12 +80,18 @@ importers:
|
||||
js-sha256:
|
||||
specifier: ^0.11.1
|
||||
version: 0.11.1
|
||||
nitropack:
|
||||
specifier: ^2.13.4
|
||||
version: 2.13.4(@libsql/client@0.17.3)(drizzle-orm@0.45.2(@libsql/client@0.17.3))(oxc-parser@0.132.0)(srvx@0.11.16)
|
||||
nuxt:
|
||||
specifier: ^3.21.8
|
||||
version: 3.21.8(@libsql/client@0.17.3)(@parcel/watcher@2.5.6)(@types/node@25.9.3)(@vue/compiler-sfc@3.5.38)(cac@6.7.14)(db0@0.3.4(@libsql/client@0.17.3)(drizzle-orm@0.45.2(@libsql/client@0.17.3)))(drizzle-orm@0.45.2(@libsql/client@0.17.3))(eslint@9.39.4(jiti@1.21.7))(ioredis@5.11.1)(magicast@0.5.3)(optionator@0.9.4)(rollup-plugin-visualizer@7.0.1(rollup@4.61.1))(rollup@4.61.1)(srvx@0.11.16)(terser@5.48.0)(tsx@4.22.4)(typescript@6.0.3)(vite@7.3.5(@types/node@25.9.3)(jiti@1.21.7)(terser@5.48.0)(tsx@4.22.4)(yaml@2.9.0))(vue-tsc@3.3.4(typescript@6.0.3))(yaml@2.9.0)
|
||||
obug:
|
||||
specifier: ^2.1.2
|
||||
version: 2.1.2
|
||||
ofetch:
|
||||
specifier: ^1.5.1
|
||||
version: 1.5.1
|
||||
openid-client:
|
||||
specifier: ^6.8.4
|
||||
version: 6.8.4
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import Database from '#server/utils/Database';
|
||||
import { definePermissionEventHandler } from '#server/utils/handler';
|
||||
|
||||
export default definePermissionEventHandler('admin', 'any', async () => {
|
||||
const generalConfig = await Database.general.getConfig();
|
||||
return generalConfig;
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
import { readValidatedBody } from 'h3';
|
||||
|
||||
import Database from '#server/utils/Database';
|
||||
import { definePermissionEventHandler } from '#server/utils/handler';
|
||||
import { validateZod } from '#server/utils/types';
|
||||
import { GeneralUpdateSchema } from '#db/repositories/general/types';
|
||||
|
||||
export default definePermissionEventHandler(
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import Database from '#server/utils/Database';
|
||||
import { definePermissionEventHandler } from '#server/utils/handler';
|
||||
|
||||
export default definePermissionEventHandler('admin', 'any', async () => {
|
||||
const hooks = await Database.hooks.get();
|
||||
return hooks;
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
import { readValidatedBody } from 'h3';
|
||||
|
||||
import Database from '#server/utils/Database';
|
||||
import WireGuard from '#server/utils/WireGuard';
|
||||
import { definePermissionEventHandler } from '#server/utils/handler';
|
||||
import { validateZod } from '#server/utils/types';
|
||||
import { HooksUpdateSchema } from '#db/repositories/hooks/types';
|
||||
|
||||
export default definePermissionEventHandler(
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
import { readValidatedBody } from 'h3';
|
||||
|
||||
import Database from '#server/utils/Database';
|
||||
import WireGuard from '#server/utils/WireGuard';
|
||||
import { definePermissionEventHandler } from '#server/utils/handler';
|
||||
import { validateZod } from '#server/utils/types';
|
||||
import { InterfaceCidrUpdateSchema } from '#db/repositories/interface/types';
|
||||
|
||||
export default definePermissionEventHandler(
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import Database from '#server/utils/Database';
|
||||
import { definePermissionEventHandler } from '#server/utils/handler';
|
||||
|
||||
export default definePermissionEventHandler('admin', 'any', async () => {
|
||||
const wgInterface = await Database.interfaces.get();
|
||||
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
import { createError, readValidatedBody } from 'h3';
|
||||
|
||||
import Database from '#server/utils/Database';
|
||||
import WireGuard from '#server/utils/WireGuard';
|
||||
import { WG_ENV } from '#server/utils/config';
|
||||
import { firewall } from '#server/utils/firewall';
|
||||
import { definePermissionEventHandler } from '#server/utils/handler';
|
||||
import { validateZod } from '#server/utils/types';
|
||||
import { InterfaceUpdateSchema } from '#db/repositories/interface/types';
|
||||
|
||||
export default definePermissionEventHandler(
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import WireGuard from '#server/utils/WireGuard';
|
||||
import { definePermissionEventHandler } from '#server/utils/handler';
|
||||
|
||||
export default definePermissionEventHandler('admin', 'any', async () => {
|
||||
await WireGuard.Restart();
|
||||
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import { definePermissionEventHandler } from '#server/utils/handler';
|
||||
import { cachedGetIpInformation } from '#server/utils/ip';
|
||||
|
||||
export default definePermissionEventHandler('admin', 'any', async () => {
|
||||
const result = await cachedGetIpInformation();
|
||||
return result;
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import Database from '#server/utils/Database';
|
||||
import { definePermissionEventHandler } from '#server/utils/handler';
|
||||
|
||||
export default definePermissionEventHandler('admin', 'any', async () => {
|
||||
const userConfig = await Database.userConfigs.get();
|
||||
return userConfig;
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
import { readValidatedBody } from 'h3';
|
||||
|
||||
import Database from '#server/utils/Database';
|
||||
import WireGuard from '#server/utils/WireGuard';
|
||||
import { definePermissionEventHandler } from '#server/utils/handler';
|
||||
import { validateZod } from '#server/utils/types';
|
||||
import { UserConfigUpdateSchema } from '#db/repositories/userConfig/types';
|
||||
|
||||
export default definePermissionEventHandler(
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
import { createError, defineEventHandler, sendRedirect } from 'h3';
|
||||
|
||||
import Database from '#server/utils/Database';
|
||||
import { SERVER_DEBUG } from '#server/utils/config';
|
||||
import { buildOauthConfig, getUserInfo } from '#server/utils/oauth';
|
||||
import { useWGSession } from '#server/utils/session';
|
||||
import { assertUnreachable } from '#server/utils/types';
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const { config, provider, providerConfig } = await buildOauthConfig(event);
|
||||
|
||||
|
||||
@@ -1,6 +1,17 @@
|
||||
import {
|
||||
defineEventHandler,
|
||||
getRequestHost,
|
||||
getValidatedQuery,
|
||||
sendRedirect,
|
||||
} from 'h3';
|
||||
import * as client from 'openid-client';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { WG_ENV } from '#server/utils/config';
|
||||
import { buildOauthConfig } from '#server/utils/oauth';
|
||||
import { useWGSession } from '#server/utils/session';
|
||||
import { validateZod } from '#server/utils/types';
|
||||
|
||||
const OauthQuerySchema = z.object({
|
||||
link: z.coerce.boolean().optional(),
|
||||
});
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
import { createError, sendRedirect } from 'h3';
|
||||
|
||||
import Database from '#server/utils/Database';
|
||||
import { definePermissionEventHandler } from '#server/utils/handler';
|
||||
import { buildOauthConfig, getUserInfo } from '#server/utils/oauth';
|
||||
import { useWGSession } from '#server/utils/session';
|
||||
|
||||
export default definePermissionEventHandler(
|
||||
'me',
|
||||
'update',
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
import { defineEventHandler } from 'h3';
|
||||
|
||||
import { useWGSession } from '#server/utils/session';
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const session = await useWGSession(event);
|
||||
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
import { defineEventHandler } from 'h3';
|
||||
|
||||
import { WG_ENV } from '#server/utils/config';
|
||||
import { OAUTH_PROVIDERS } from '#server/utils/oauth';
|
||||
import type { OAUTH_PROVIDER } from '#server/utils/oauth';
|
||||
|
||||
export default defineEventHandler(() => {
|
||||
return {
|
||||
providers: WG_ENV.OAUTH_PROVIDERS?.reduce(
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
import { createError, defineEventHandler, readValidatedBody } from 'h3';
|
||||
|
||||
import Database from '#server/utils/Database';
|
||||
import { SERVER_DEBUG, WG_ENV } from '#server/utils/config';
|
||||
import { useWGSession } from '#server/utils/session';
|
||||
import { assertUnreachable, validateZod } from '#server/utils/types';
|
||||
import { UserLoginSchema } from '#db/repositories/user/types';
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
import { createError, defineEventHandler } from 'h3';
|
||||
|
||||
import { useWGSession } from '#server/utils/session';
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const session = await useWGSession(event);
|
||||
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import Database from '#server/utils/Database';
|
||||
import { definePermissionEventHandler } from '#server/utils/handler';
|
||||
|
||||
export default definePermissionEventHandler(
|
||||
'me',
|
||||
'update',
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
import { createError, defineEventHandler, readValidatedBody } from 'h3';
|
||||
|
||||
import Database from '#server/utils/Database';
|
||||
import { useWGSession } from '#server/utils/session';
|
||||
import { assertUnreachable, validateZod } from '#server/utils/types';
|
||||
import { Verify2faSchema } from '#db/repositories/user/types';
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
import { createError, getValidatedRouterParams, setHeader } from 'h3';
|
||||
|
||||
import Database from '#server/utils/Database';
|
||||
import WireGuard from '#server/utils/WireGuard';
|
||||
import { definePermissionEventHandler } from '#server/utils/handler';
|
||||
import { validateZod } from '#server/utils/types';
|
||||
import { ClientGetSchema } from '#db/repositories/client/types';
|
||||
|
||||
export default definePermissionEventHandler(
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
import { getValidatedRouterParams } from 'h3';
|
||||
|
||||
import Database from '#server/utils/Database';
|
||||
import WireGuard from '#server/utils/WireGuard';
|
||||
import { definePermissionEventHandler } from '#server/utils/handler';
|
||||
import { validateZod } from '#server/utils/types';
|
||||
import { ClientGetSchema } from '#db/repositories/client/types';
|
||||
|
||||
export default definePermissionEventHandler(
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
import { createError, getValidatedRouterParams } from 'h3';
|
||||
|
||||
import Database from '#server/utils/Database';
|
||||
import WireGuard from '#server/utils/WireGuard';
|
||||
import { definePermissionEventHandler } from '#server/utils/handler';
|
||||
import { validateZod } from '#server/utils/types';
|
||||
import { ClientGetSchema } from '#db/repositories/client/types';
|
||||
|
||||
export default definePermissionEventHandler(
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
import { getValidatedRouterParams } from 'h3';
|
||||
|
||||
import Database from '#server/utils/Database';
|
||||
import { definePermissionEventHandler } from '#server/utils/handler';
|
||||
import { validateZod } from '#server/utils/types';
|
||||
import { ClientGetSchema } from '#db/repositories/client/types';
|
||||
|
||||
export default definePermissionEventHandler(
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
import { getValidatedRouterParams } from 'h3';
|
||||
|
||||
import Database from '#server/utils/Database';
|
||||
import WireGuard from '#server/utils/WireGuard';
|
||||
import { definePermissionEventHandler } from '#server/utils/handler';
|
||||
import { validateZod } from '#server/utils/types';
|
||||
import { ClientGetSchema } from '#db/repositories/client/types';
|
||||
|
||||
export default definePermissionEventHandler(
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
import { createError, getValidatedRouterParams } from 'h3';
|
||||
|
||||
import Database from '#server/utils/Database';
|
||||
import WireGuard from '#server/utils/WireGuard';
|
||||
import { definePermissionEventHandler } from '#server/utils/handler';
|
||||
import { validateZod } from '#server/utils/types';
|
||||
import { ClientGetSchema } from '#db/repositories/client/types';
|
||||
|
||||
export default definePermissionEventHandler(
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
import { getValidatedRouterParams, readValidatedBody } from 'h3';
|
||||
|
||||
import Database from '#server/utils/Database';
|
||||
import WireGuard from '#server/utils/WireGuard';
|
||||
import { definePermissionEventHandler } from '#server/utils/handler';
|
||||
import { validateZod } from '#server/utils/types';
|
||||
import {
|
||||
ClientGetSchema,
|
||||
ClientUpdateSchema,
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
import { getValidatedRouterParams, setHeader } from 'h3';
|
||||
|
||||
import Database from '#server/utils/Database';
|
||||
import WireGuard from '#server/utils/WireGuard';
|
||||
import { definePermissionEventHandler } from '#server/utils/handler';
|
||||
import { validateZod } from '#server/utils/types';
|
||||
import { ClientGetSchema } from '#db/repositories/client/types';
|
||||
|
||||
export default definePermissionEventHandler(
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
import { getValidatedQuery } from 'h3';
|
||||
|
||||
import WireGuard from '#server/utils/WireGuard';
|
||||
import { definePermissionEventHandler } from '#server/utils/handler';
|
||||
import { validateZod } from '#server/utils/types';
|
||||
import { roles } from '#shared/utils/permissions';
|
||||
import { ClientQuerySchema } from '#db/repositories/client/types';
|
||||
|
||||
export default definePermissionEventHandler(
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
import { readValidatedBody } from 'h3';
|
||||
|
||||
import Database from '#server/utils/Database';
|
||||
import WireGuard from '#server/utils/WireGuard';
|
||||
import { definePermissionEventHandler } from '#server/utils/handler';
|
||||
import { validateZod } from '#server/utils/types';
|
||||
import { ClientCreateSchema } from '#db/repositories/client/types';
|
||||
|
||||
export default definePermissionEventHandler(
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
import { defineEventHandler } from 'h3';
|
||||
import { gt } from 'semver';
|
||||
|
||||
import Database from '#server/utils/Database';
|
||||
import { RELEASE, WG_ENV } from '#server/utils/config';
|
||||
import { cachedFetchLatestRelease } from '#server/utils/release';
|
||||
|
||||
export default defineEventHandler(async () => {
|
||||
const latestRelease = await cachedFetchLatestRelease();
|
||||
const updateAvailable = gt(latestRelease.version, RELEASE);
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
import { readValidatedBody } from 'h3';
|
||||
|
||||
import Database from '#server/utils/Database';
|
||||
import { definePermissionEventHandler } from '#server/utils/handler';
|
||||
import { validateZod } from '#server/utils/types';
|
||||
import { UserUpdateSchema } from '#db/repositories/user/types';
|
||||
|
||||
export default definePermissionEventHandler(
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
import { readValidatedBody } from 'h3';
|
||||
|
||||
import Database from '#server/utils/Database';
|
||||
import { definePermissionEventHandler } from '#server/utils/handler';
|
||||
import { validateZod } from '#server/utils/types';
|
||||
import { UserUpdatePasswordSchema } from '#db/repositories/user/types';
|
||||
|
||||
export default definePermissionEventHandler(
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
import { createError, readValidatedBody } from 'h3';
|
||||
import { Secret, TOTP } from 'otpauth';
|
||||
|
||||
import Database from '#server/utils/Database';
|
||||
import { definePermissionEventHandler } from '#server/utils/handler';
|
||||
import { validateZod } from '#server/utils/types';
|
||||
import { UserUpdateTotpSchema } from '#db/repositories/user/types';
|
||||
|
||||
type Response =
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
import { createError, defineEventHandler } from 'h3';
|
||||
|
||||
import { SERVER_DEBUG } from '#server/utils/config';
|
||||
import { useWGSession } from '#server/utils/session';
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const session = await useWGSession(event);
|
||||
const sessionId = session.id;
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
import { createError, defineEventHandler } from 'h3';
|
||||
|
||||
import Database from '#server/utils/Database';
|
||||
import { useWGSession } from '#server/utils/session';
|
||||
import type { SharedPublicUser } from '#shared/utils/permissions';
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const session = await useWGSession(event);
|
||||
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
import { readValidatedBody } from 'h3';
|
||||
|
||||
import Database from '#server/utils/Database';
|
||||
import { defineSetupEventHandler } from '#server/utils/handler';
|
||||
import { validateZod } from '#server/utils/types';
|
||||
import { UserSetupSchema } from '#db/repositories/user/types';
|
||||
|
||||
export default defineSetupEventHandler(2, async ({ event }) => {
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import { defineSetupEventHandler } from '#server/utils/handler';
|
||||
import { cachedGetIpInformation } from '#server/utils/ip';
|
||||
|
||||
export default defineSetupEventHandler(4, async () => {
|
||||
const result = await cachedGetIpInformation();
|
||||
return result;
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
import { readValidatedBody } from 'h3';
|
||||
|
||||
import Database from '#server/utils/Database';
|
||||
import { defineSetupEventHandler } from '#server/utils/handler';
|
||||
import { validateZod } from '#server/utils/types';
|
||||
import { UserConfigSetupSchema } from '#db/repositories/userConfig/types';
|
||||
|
||||
export default defineSetupEventHandler(4, async ({ event }) => {
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
import { readValidatedBody } from 'h3';
|
||||
import { parseCidr } from 'cidr-tools';
|
||||
import { stringifyIp } from 'ip-bigint';
|
||||
import { z } from 'zod';
|
||||
|
||||
import Database from '#server/utils/Database';
|
||||
import { defineSetupEventHandler } from '#server/utils/handler';
|
||||
import { nextIP } from '#server/utils/ip';
|
||||
import { FileSchema, validateZod } from '#server/utils/types';
|
||||
|
||||
export default defineSetupEventHandler('migrate', async ({ event }) => {
|
||||
const { file } = await readValidatedBody(
|
||||
event,
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { sql, relations } from 'drizzle-orm';
|
||||
import { int, sqliteTable, text } from 'drizzle-orm/sqlite-core';
|
||||
|
||||
import { oneTimeLink, user, wgInterface } from '../../schema';
|
||||
import { wgInterface } from '#db/repositories/interface/schema';
|
||||
import { oneTimeLink } from '#db/repositories/oneTimeLink/schema';
|
||||
import { user } from '#db/repositories/user/schema';
|
||||
|
||||
/** null means use value from userConfig */
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { eq, sql, or, like, and } from 'drizzle-orm';
|
||||
import { containsCidr, parseCidr } from 'cidr-tools';
|
||||
|
||||
import { client } from './schema';
|
||||
import type {
|
||||
ClientCreateFromExistingType,
|
||||
@@ -7,6 +8,11 @@ import type {
|
||||
ClientQueryType,
|
||||
UpdateClientType,
|
||||
} from './types';
|
||||
|
||||
import Database from '#server/utils/Database';
|
||||
import { nextIP } from '#server/utils/ip';
|
||||
import type { ID } from '#server/utils/types';
|
||||
import { wg } from '#server/utils/wgHelper';
|
||||
import type { DBType } from '#db/sqlite';
|
||||
import { wgInterface, userConfig } from '#db/schema';
|
||||
|
||||
|
||||
@@ -1,9 +1,28 @@
|
||||
import type { InferSelectModel } from 'drizzle-orm';
|
||||
import z from 'zod';
|
||||
|
||||
import { isIPv4, isIPv6 } from 'is-ip';
|
||||
|
||||
import type { client } from './schema';
|
||||
|
||||
import {
|
||||
AddressSchema,
|
||||
AllowedIpsSchema,
|
||||
DnsSchema,
|
||||
EnabledSchema,
|
||||
FirewallIpsSchema,
|
||||
HookSchema,
|
||||
ISchema,
|
||||
JcSchema,
|
||||
JmaxSchema,
|
||||
JminSchema,
|
||||
MtuSchema,
|
||||
PersistentKeepaliveSchema,
|
||||
controlStringRefine,
|
||||
safeStringRefine,
|
||||
schemaForType,
|
||||
t,
|
||||
} from '#server/utils/types';
|
||||
|
||||
export type ClientType = InferSelectModel<typeof client>;
|
||||
|
||||
export type ClientNextIpType = Pick<ClientType, 'ipv4Address' | 'ipv6Address'>;
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { sql } from 'drizzle-orm';
|
||||
|
||||
import { general } from './schema';
|
||||
import type { GeneralUpdateType } from './types';
|
||||
|
||||
import { hashPassword, isValidPasswordHash } from '#server/utils/password';
|
||||
import type { DBType } from '#db/sqlite';
|
||||
|
||||
function createPreparedStatement(db: DBType) {
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import type { InferSelectModel } from 'drizzle-orm';
|
||||
import z from 'zod';
|
||||
|
||||
import type { general } from './schema';
|
||||
|
||||
import { safeStringRefine, t } from '#server/utils/types';
|
||||
|
||||
export type GeneralType = InferSelectModel<typeof general>;
|
||||
|
||||
const sessionTimeout = z.number({ message: t('zod.general.sessionTimeout') });
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { sql } from 'drizzle-orm';
|
||||
import { sqliteTable, text } from 'drizzle-orm/sqlite-core';
|
||||
|
||||
import { wgInterface } from '../../schema';
|
||||
import { wgInterface } from '#db/repositories/interface/schema';
|
||||
|
||||
export const hooks = sqliteTable('hooks_table', {
|
||||
/** same as `wgInterface.name` */
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { eq, sql } from 'drizzle-orm';
|
||||
|
||||
import { hooks } from './schema';
|
||||
import type { HooksUpdateType } from './types';
|
||||
|
||||
import type { DBType } from '#db/sqlite';
|
||||
|
||||
function createPreparedStatement(db: DBType) {
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import type { InferSelectModel } from 'drizzle-orm';
|
||||
import z from 'zod';
|
||||
|
||||
import type { hooks } from './schema';
|
||||
|
||||
import { HookSchema, schemaForType } from '#server/utils/types';
|
||||
|
||||
export type HooksType = InferSelectModel<typeof hooks>;
|
||||
|
||||
export type HooksUpdateType = Omit<HooksType, 'id' | 'createdAt' | 'updatedAt'>;
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { sql, relations } from 'drizzle-orm';
|
||||
import { int, sqliteTable, text } from 'drizzle-orm/sqlite-core';
|
||||
|
||||
import { userConfig, hooks } from '../../schema';
|
||||
import { hooks } from '#db/repositories/hooks/schema';
|
||||
import { userConfig } from '#db/repositories/userConfig/schema';
|
||||
|
||||
// maybe support multiple interfaces in the future
|
||||
export const wgInterface = sqliteTable('interfaces_table', {
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import { eq, sql } from 'drizzle-orm';
|
||||
import { parseCidr } from 'cidr-tools';
|
||||
|
||||
import { wgInterface } from './schema';
|
||||
import type { InterfaceCidrUpdateType, InterfaceUpdateType } from './types';
|
||||
|
||||
import { nextIP } from '#server/utils/ip';
|
||||
import { client as clientSchema } from '#db/schema';
|
||||
import type { DBType } from '#db/sqlite';
|
||||
|
||||
|
||||
@@ -1,8 +1,24 @@
|
||||
import type { InferSelectModel } from 'drizzle-orm';
|
||||
import z from 'zod';
|
||||
import isCidr from 'is-cidr';
|
||||
|
||||
import type { wgInterface } from './schema';
|
||||
|
||||
import {
|
||||
EnabledSchema,
|
||||
HSchema,
|
||||
ISchema,
|
||||
JcSchema,
|
||||
JmaxSchema,
|
||||
JminSchema,
|
||||
MtuSchema,
|
||||
PortSchema,
|
||||
SSchema,
|
||||
safeStringRefine,
|
||||
schemaForType,
|
||||
t,
|
||||
} from '#server/utils/types';
|
||||
|
||||
export type InterfaceType = InferSelectModel<typeof wgInterface>;
|
||||
|
||||
export type InterfaceCreateType = Omit<
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { sql, relations } from 'drizzle-orm';
|
||||
import { int, sqliteTable, text } from 'drizzle-orm/sqlite-core';
|
||||
|
||||
import { client } from '../../schema';
|
||||
import { client } from '#db/repositories/client/schema';
|
||||
|
||||
export const oneTimeLink = sqliteTable('one_time_links_table', {
|
||||
/** same as `client.id` */
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { eq, sql } from 'drizzle-orm';
|
||||
import CRC32 from 'crc-32';
|
||||
|
||||
import { oneTimeLink } from './schema';
|
||||
|
||||
import type { ID } from '#server/utils/types';
|
||||
import type { DBType } from '#db/sqlite';
|
||||
|
||||
function createPreparedStatement(db: DBType) {
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import type { InferSelectModel } from 'drizzle-orm';
|
||||
import { z } from 'zod';
|
||||
|
||||
import type { oneTimeLink } from './schema';
|
||||
|
||||
import { safeStringRefine, t } from '#server/utils/types';
|
||||
|
||||
export type OneTimeLinkType = InferSelectModel<typeof oneTimeLink>;
|
||||
|
||||
const oneTimeLinkType = z
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { sql, relations } from 'drizzle-orm';
|
||||
import { int, sqliteTable, text, uniqueIndex } from 'drizzle-orm/sqlite-core';
|
||||
|
||||
import { client } from '../../schema';
|
||||
import { client } from '#db/repositories/client/schema';
|
||||
import type { Role } from '#shared/utils/permissions';
|
||||
import type { OAUTH_PROVIDER } from '#server/utils/oauth';
|
||||
|
||||
export const user = sqliteTable(
|
||||
'users_table',
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
import { eq, sql, and } from 'drizzle-orm';
|
||||
import { TOTP } from 'otpauth';
|
||||
|
||||
import { user } from './schema';
|
||||
import type { UserType } from './types';
|
||||
|
||||
import { WG_ENV } from '#server/utils/config';
|
||||
import type { OAUTH_PROVIDER } from '#server/utils/oauth';
|
||||
import { hashPassword, isPasswordValid } from '#server/utils/password';
|
||||
import type { ID } from '#server/utils/types';
|
||||
import { roles } from '#shared/utils/permissions';
|
||||
import type { DBType } from '#db/sqlite';
|
||||
|
||||
type LoginResult =
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import type { InferSelectModel } from 'drizzle-orm';
|
||||
import z from 'zod';
|
||||
|
||||
import type { user } from './schema';
|
||||
|
||||
import { safeStringRefine, t } from '#server/utils/types';
|
||||
|
||||
export type UserType = InferSelectModel<typeof user>;
|
||||
|
||||
const username = z
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { sql } from 'drizzle-orm';
|
||||
import { int, sqliteTable, text } from 'drizzle-orm/sqlite-core';
|
||||
|
||||
import { wgInterface } from '../../schema';
|
||||
import { wgInterface } from '#db/repositories/interface/schema';
|
||||
|
||||
// default* means clients store it themselves
|
||||
export const userConfig = sqliteTable('user_configs_table', {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { eq, sql } from 'drizzle-orm';
|
||||
|
||||
import { userConfig } from './schema';
|
||||
import type { UserConfigUpdateType } from './types';
|
||||
|
||||
import { wgInterface } from '#db/schema';
|
||||
import type { DBType } from '#db/sqlite';
|
||||
|
||||
|
||||
@@ -1,7 +1,23 @@
|
||||
import type { InferSelectModel } from 'drizzle-orm';
|
||||
import z from 'zod';
|
||||
|
||||
import type { userConfig } from './schema';
|
||||
|
||||
import {
|
||||
AllowedIpsSchema,
|
||||
DnsSchema,
|
||||
ISchema,
|
||||
JcSchema,
|
||||
JmaxSchema,
|
||||
JminSchema,
|
||||
MtuSchema,
|
||||
PersistentKeepaliveSchema,
|
||||
PortSchema,
|
||||
safeStringRefine,
|
||||
schemaForType,
|
||||
t,
|
||||
} from '#server/utils/types';
|
||||
|
||||
export type UserConfigType = InferSelectModel<typeof userConfig>;
|
||||
|
||||
const host = z
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
// Make sure to not use any Path Aliases in these files
|
||||
export * from './repositories/client/schema';
|
||||
export * from './repositories/general/schema';
|
||||
export * from './repositories/hooks/schema';
|
||||
export * from './repositories/interface/schema';
|
||||
export * from './repositories/oneTimeLink/schema';
|
||||
export * from './repositories/user/schema';
|
||||
export * from './repositories/userConfig/schema';
|
||||
export * from '#db/repositories/client/schema';
|
||||
export * from '#db/repositories/general/schema';
|
||||
export * from '#db/repositories/hooks/schema';
|
||||
export * from '#db/repositories/interface/schema';
|
||||
export * from '#db/repositories/oneTimeLink/schema';
|
||||
export * from '#db/repositories/user/schema';
|
||||
export * from '#db/repositories/userConfig/schema';
|
||||
|
||||
@@ -4,14 +4,15 @@ import { createClient } from '@libsql/client';
|
||||
import { createDebug } from 'obug';
|
||||
import { eq } from 'drizzle-orm';
|
||||
|
||||
import * as schema from './schema';
|
||||
import { ClientService } from './repositories/client/service';
|
||||
import { GeneralService } from './repositories/general/service';
|
||||
import { UserService } from './repositories/user/service';
|
||||
import { UserConfigService } from './repositories/userConfig/service';
|
||||
import { InterfaceService } from './repositories/interface/service';
|
||||
import { HooksService } from './repositories/hooks/service';
|
||||
import { OneTimeLinkService } from './repositories/oneTimeLink/service';
|
||||
import { GeneralService } from '#db/repositories/general/service';
|
||||
import { UserService } from '#db/repositories/user/service';
|
||||
import { UserConfigService } from '#db/repositories/userConfig/service';
|
||||
import { InterfaceService } from '#db/repositories/interface/service';
|
||||
import { HooksService } from '#db/repositories/hooks/service';
|
||||
import { OneTimeLinkService } from '#db/repositories/oneTimeLink/service';
|
||||
import { ClientService } from '#db/repositories/client/service';
|
||||
import * as schema from '#db/schema';
|
||||
import { WG_ENV, WG_INITIAL_ENV } from '#server/utils/config';
|
||||
|
||||
const DB_DEBUG = createDebug('Database');
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
import { defineEventHandler, getRequestURL, sendRedirect } from 'h3';
|
||||
|
||||
import Database from '#server/utils/Database';
|
||||
|
||||
/* First setup of wg-easy */
|
||||
export default defineEventHandler(async (event) => {
|
||||
const url = getRequestURL(event);
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
import { defineNitroPlugin } from 'nitropack/runtime';
|
||||
|
||||
import WireGuard from '#server/utils/WireGuard';
|
||||
import { RELEASE } from '#server/utils/config';
|
||||
|
||||
export default defineNitroPlugin((nitroApp) => {
|
||||
console.log(`
|
||||
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
import {
|
||||
createError,
|
||||
defineEventHandler,
|
||||
getValidatedRouterParams,
|
||||
setHeader,
|
||||
} from 'h3';
|
||||
|
||||
import Database from '#server/utils/Database';
|
||||
import WireGuard from '#server/utils/WireGuard';
|
||||
import { validateZod } from '#server/utils/types';
|
||||
import { OneTimeLinkGetSchema } from '#db/repositories/oneTimeLink/types';
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
import WireGuard from '#server/utils/WireGuard';
|
||||
import { defineMetricsHandler } from '#server/utils/handler';
|
||||
import { isPeerConnected } from '#shared/utils/time';
|
||||
|
||||
export default defineMetricsHandler('json', async () => {
|
||||
return getMetricsJSON();
|
||||
});
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
import { setHeader } from 'h3';
|
||||
|
||||
import Database from '#server/utils/Database';
|
||||
import WireGuard from '#server/utils/WireGuard';
|
||||
import { defineMetricsHandler } from '#server/utils/handler';
|
||||
import { isPeerConnected } from '#shared/utils/time';
|
||||
|
||||
export default defineMetricsHandler('prometheus', async ({ event }) => {
|
||||
setHeader(event, 'Content-Type', 'text/plain');
|
||||
return getPrometheusResponse();
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import WireGuard from '#server/utils/WireGuard';
|
||||
/**
|
||||
* Changing the Database Provider
|
||||
* This design allows for easy swapping of different database implementations.
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
import fs from 'node:fs/promises';
|
||||
|
||||
import { createDebug } from 'obug';
|
||||
|
||||
import Database from '#server/utils/Database';
|
||||
import { OLD_ENV, WG_ENV } from '#server/utils/config';
|
||||
import { firewall } from '#server/utils/firewall';
|
||||
import { encodeQRCode } from '#server/utils/qr';
|
||||
import type { ID } from '#server/utils/types';
|
||||
import { wg } from '#server/utils/wgHelper';
|
||||
import { setIntervalImmediately } from '#shared/utils/time';
|
||||
import type { InterfaceType } from '#db/repositories/interface/types';
|
||||
import type { ClientQueryType } from '#db/repositories/client/types';
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import childProcess from 'child_process';
|
||||
|
||||
import { createDebug } from 'obug';
|
||||
|
||||
const CMD_DEBUG = createDebug('CMD');
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
import { createDebug } from 'obug';
|
||||
import packageJson from '@@/package.json';
|
||||
|
||||
import { exec } from '#server/utils/cmd';
|
||||
import {
|
||||
OAUTH_PROVIDERS,
|
||||
isConfiguredOauthProvider,
|
||||
isValidOauthProvider,
|
||||
} from '#server/utils/oauth';
|
||||
|
||||
export const RELEASE = 'v' + packageJson.version;
|
||||
|
||||
export const SERVER_DEBUG = createDebug('Server');
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { createDebug } from 'obug';
|
||||
import { isIPv6 } from 'is-ip';
|
||||
|
||||
import { exec } from '#server/utils/cmd';
|
||||
import type { ClientType } from '#db/repositories/client/types';
|
||||
import type { InterfaceType } from '#db/repositories/interface/types';
|
||||
import type { UserConfigType } from '#db/repositories/userConfig/types';
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
import { createError, defineEventHandler, getHeader } from 'h3';
|
||||
import type { EventHandlerRequest, EventHandlerResponse, H3Event } from 'h3';
|
||||
|
||||
import Database from '#server/utils/Database';
|
||||
import { isPasswordValid } from '#server/utils/password';
|
||||
import { getCurrentUser } from '#server/utils/session';
|
||||
import type { UserType } from '#db/repositories/user/types';
|
||||
import type { SetupStepType } from '#db/repositories/general/types';
|
||||
import {
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { Resolver } from 'node:dns/promises';
|
||||
import { networkInterfaces } from 'node:os';
|
||||
|
||||
import { stringifyIp } from 'ip-bigint';
|
||||
import type { parseCidr } from 'cidr-tools';
|
||||
|
||||
import { cacheFunction } from '#server/utils/cache';
|
||||
import type { ClientNextIpType } from '#db/repositories/client/types';
|
||||
|
||||
type ParsedCidr = ReturnType<typeof parseCidr>;
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { createError, getRequestURL, getRouterParam } from 'h3';
|
||||
import type { H3Event } from 'h3';
|
||||
import * as client from 'openid-client';
|
||||
|
||||
import { WG_ENV } from '#server/utils/config';
|
||||
|
||||
type OAuthConfig = {
|
||||
friendlyName: string;
|
||||
server: string;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
// ! Auto Imports are not supported in this file
|
||||
|
||||
import argon2 from 'argon2';
|
||||
import { deserialize } from '@phc/format';
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
// ! Auto Imports are not supported in this file
|
||||
|
||||
import type { ErrorCorrection } from 'qr';
|
||||
import { encodeQR } from 'qr';
|
||||
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
import { createError } from 'h3';
|
||||
import { $fetch } from 'ofetch';
|
||||
|
||||
import { cacheFunction } from '#server/utils/cache';
|
||||
import { RELEASE, SERVER_DEBUG, WG_ENV } from '#server/utils/config';
|
||||
|
||||
type GithubRelease = {
|
||||
tag_name: string;
|
||||
body: string;
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
import { createError, getHeader, getSession, useSession } from 'h3';
|
||||
import type { H3Event } from 'h3';
|
||||
|
||||
import Database from '#server/utils/Database';
|
||||
import { WG_ENV } from '#server/utils/config';
|
||||
import { isPasswordValid } from '#server/utils/password';
|
||||
import type { ID } from '#server/utils/types';
|
||||
import type { UserType } from '#db/repositories/user/types';
|
||||
|
||||
export type WGSession = Partial<{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// ! Auto Imports are not supported in this file
|
||||
|
||||
import { WG_ENV } from '#server/utils/config';
|
||||
import type { InterfaceType } from '#db/repositories/interface/types';
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { useTranslation } from '@intlify/h3';
|
||||
import type { ZodType } from 'zod';
|
||||
import z from 'zod';
|
||||
import type { H3Event, EventHandlerRequest } from 'h3';
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// ! Auto Imports are not supported in this file
|
||||
|
||||
import { parseCidr } from 'cidr-tools';
|
||||
import { stringifyIp } from 'ip-bigint';
|
||||
import { removeNewlines } from './template';
|
||||
|
||||
import { removeNewlines, iptablesTemplate } from '#server/utils/template';
|
||||
import { exec } from '#server/utils/cmd';
|
||||
import { WG_ENV } from '#server/utils/config';
|
||||
import type { ClientType } from '#db/repositories/client/types';
|
||||
import type { InterfaceType } from '#db/repositories/interface/types';
|
||||
import type { UserConfigType } from '#db/repositories/userConfig/types';
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { describe, expect, test } from 'vitest';
|
||||
import { firewallTestExports } from '../../server/utils/firewall';
|
||||
import { typesTestExports } from '../../server/utils/types';
|
||||
|
||||
import { firewallTestExports } from '#server/utils/firewall';
|
||||
import { typesTestExports } from '#server/utils/types';
|
||||
|
||||
describe('firewall', () => {
|
||||
describe('isValidFirewallEntry', () => {
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { expect, test, describe } from 'vitest';
|
||||
|
||||
import {
|
||||
hashPassword,
|
||||
isPasswordValid,
|
||||
isValidPasswordHash,
|
||||
} from '../../server/utils/password';
|
||||
} from '#server/utils/password';
|
||||
|
||||
describe('password', () => {
|
||||
test('password', async () => {
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
import { defineConfig } from 'vitest/config';
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
projects: [
|
||||
{
|
||||
resolve: {
|
||||
alias: {
|
||||
'#server': fileURLToPath(new URL('./server', import.meta.url)),
|
||||
},
|
||||
},
|
||||
test: {
|
||||
name: 'unit',
|
||||
include: ['test/unit/*.{test,spec}.ts'],
|
||||
|
||||
Reference in New Issue
Block a user