mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
refactor: use bun for package management
+ add package.json to each packages + update import path
This commit is contained in:
1 parent
fb7dc0eb73
commit
2feedc329c
47 files changed
+2893
-8818
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { connectDB, User } from '../../packages/models'
|
||||
import { connectDB, User } from '@odyssey/models'
|
||||
|
||||
async function migrate() {
|
||||
await connectDB(
|
||||
|
||||
+5
-3
@@ -12,6 +12,10 @@
|
||||
"build:quests": "tsx src/cli/build.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@odyssey/constants": "workspace:*",
|
||||
"@odyssey/game": "workspace:*",
|
||||
"@odyssey/models": "workspace:*",
|
||||
"@odyssey/utils": "workspace:*",
|
||||
"@trpc/server": "^11.8.0",
|
||||
"bcrypt": "^5.1.1",
|
||||
"commander": "^11.0.0",
|
||||
@@ -36,7 +40,6 @@
|
||||
"passport-jwt": "^4.0.1",
|
||||
"passport-local": "^1.0.0",
|
||||
"socket.io": "^4.7.1",
|
||||
"ssh2": "^1.16.0",
|
||||
"swagger-ui-express": "^5.0.0",
|
||||
"tsx": "^4.19.3",
|
||||
"validator": "^13.15.22",
|
||||
@@ -50,6 +53,7 @@
|
||||
"@types/bcrypt": "^5.0.2",
|
||||
"@types/dockerode": "^3.3.23",
|
||||
"@types/express": "^4.17.21",
|
||||
"@types/express-serve-static-core": "^5.1.3",
|
||||
"@types/express-session": "^1.17.10",
|
||||
"@types/jsonwebtoken": "^9.0.5",
|
||||
"@types/minimist": "^1.2.5",
|
||||
@@ -60,11 +64,9 @@
|
||||
"@types/passport-local": "^1.0.38",
|
||||
"@types/passport-oauth2": "^1.4.15",
|
||||
"@types/source-map-support": "^0",
|
||||
"@types/ssh2": "^1.15.1",
|
||||
"@types/swagger-ui-express": "^4.1.6",
|
||||
"@types/validator": "^13.11.9",
|
||||
"concurrently": "^8.2.2",
|
||||
"jest": "^29.6.1",
|
||||
"regenerator-runtime": "^0.14.1",
|
||||
"source-map-support": "^0.5.21",
|
||||
"typescript": "^5.3.3"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { Request, Response } from 'express'
|
||||
import { GameSession, commandSchema } from '../../../../packages/game'
|
||||
import { Command, Session } from '../../../../packages/models'
|
||||
import { GameSession, commandSchema } from '@odyssey/game'
|
||||
import { Command, Session } from '@odyssey/models'
|
||||
import { pushToSession } from '../socket'
|
||||
import { finishSession } from '../../models/sessionManager'
|
||||
import { asyncHandler } from '../../middleware/error'
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Router, Request, Response, Express } from 'express'
|
||||
import passport from 'passport'
|
||||
import { NextFunction } from 'express-serve-static-core'
|
||||
import { LoginAttempt } from '../../../../packages/models'
|
||||
import { LoginAttempt } from '@odyssey/models'
|
||||
import enabledMethods from '../../auth/passport.js'
|
||||
|
||||
import {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Server } from 'socket.io'
|
||||
import type { Socket } from 'socket.io'
|
||||
import validator from 'validator'
|
||||
import type { Server as HttpServer } from 'http'
|
||||
import { Session } from '../../../packages/models'
|
||||
import { Session } from '@odyssey/models'
|
||||
import SessionMiddleware from '../middleware/session.js'
|
||||
import logger from '../utils/logger.js'
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { check } from 'express-validator'
|
||||
|
||||
import { isValidUsername, isValidEmail } from '../../../../packages/utils'
|
||||
import { User } from '../../../../packages/models'
|
||||
import { passwordPolicy } from '../../../../packages/constants'
|
||||
import { isValidUsername, isValidEmail } from '@odyssey/utils'
|
||||
import { User } from '@odyssey/models'
|
||||
import { passwordPolicy } from '@odyssey/constants'
|
||||
import { noError } from '../../middleware/validator.js'
|
||||
|
||||
const checkUsername = () =>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { Profile } from 'passport'
|
||||
import type { VerifyCallback } from 'passport-oauth2'
|
||||
import { User } from '../../../packages/models'
|
||||
import { User } from '@odyssey/models'
|
||||
import logger from '../utils/logger.js'
|
||||
|
||||
export default async function oauthVerify(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import passport from 'passport'
|
||||
import type { Express } from 'express'
|
||||
import { UserProfile } from '../../../packages/models'
|
||||
import { UserProfile } from '@odyssey/models'
|
||||
import passwordStrategy from './passwordStrategy.js'
|
||||
import jwtStrategy from './jwtStrategy.js'
|
||||
import googleStrategy from './googleStrategy.js'
|
||||
|
||||
@@ -3,7 +3,7 @@ import bcrypt from 'bcrypt'
|
||||
import { Strategy as LocalStrategy } from 'passport-local'
|
||||
import type { IVerifyOptions } from 'passport-local'
|
||||
import type { Express } from 'express'
|
||||
import { User } from '../../../packages/models'
|
||||
import { User } from '@odyssey/models'
|
||||
|
||||
async function verifyPassword(
|
||||
username: string,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { connectDB } from '../../../packages/models'
|
||||
import { connectDB } from '@odyssey/models'
|
||||
import { removeExpired } from '../containers/expiryChecker'
|
||||
import config from '../config'
|
||||
import logger from '../utils/logger'
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { execFile } from 'child_process'
|
||||
|
||||
import { buildFileCheckCmd } from '../../../packages/utils'
|
||||
import type { IFileExistenceChecker, IFileInput } from '../../../packages/game'
|
||||
import { buildFileCheckCmd } from '@odyssey/utils'
|
||||
import type { IFileExistenceChecker, IFileInput } from '@odyssey/game'
|
||||
|
||||
function sanitizeId(id: string) {
|
||||
return id.replace(/[^a-zA-Z0-9]/g, '')
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import fs from 'fs/promises'
|
||||
import Docker from 'dockerode'
|
||||
import type { QuestLocale } from '../../../packages/constants'
|
||||
import type { QuestLocale } from '@odyssey/constants'
|
||||
import config, { getQuestImage } from '../config.js'
|
||||
import logger from '../utils/logger.js'
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import schedule from 'node-schedule'
|
||||
import type { HydratedDocument } from 'mongoose'
|
||||
import { Session } from '../../../packages/models'
|
||||
import type { ISession } from '../../../packages/models'
|
||||
import { Session } from '@odyssey/models'
|
||||
import type { ISession } from '@odyssey/models'
|
||||
import config from '../config.js'
|
||||
import { deleteContainer } from './docker.js'
|
||||
import logger from '../utils/logger.js'
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import YAML from 'yaml'
|
||||
import swaggerUI from 'swagger-ui-express'
|
||||
import passport from 'passport'
|
||||
import * as trpcExpress from '@trpc/server/adapters/express'
|
||||
import { connectDB } from '../../packages/models'
|
||||
import { connectDB } from '@odyssey/models'
|
||||
|
||||
import './auth/passport.js'
|
||||
import socketServer from './api/socket.js'
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import rateLimit from 'express-rate-limit'
|
||||
import type { Options } from 'express-rate-limit'
|
||||
import type { Request, Response, NextFunction } from 'express'
|
||||
import { LoginAttempt } from '@odyssey/models'
|
||||
import config from '../config.js'
|
||||
import { LoginAttempt } from '../../../packages/models'
|
||||
import logger from '../utils/logger.js'
|
||||
|
||||
function createRateLimiter(options: Partial<Options>) {
|
||||
|
||||
@@ -3,13 +3,9 @@ import fs from 'fs/promises'
|
||||
import path from 'path'
|
||||
import yaml from 'yaml'
|
||||
|
||||
import type { QuestLocale } from '../../../packages/constants'
|
||||
import { SUPPORTED_LOCALES } from '../../../packages/constants'
|
||||
import {
|
||||
questSchema,
|
||||
globalExceptionSchema,
|
||||
IQuest,
|
||||
} from '../../../packages/game'
|
||||
import type { QuestLocale } from '@odyssey/constants'
|
||||
import { SUPPORTED_LOCALES } from '@odyssey/constants'
|
||||
import { questSchema, globalExceptionSchema, IQuest } from '@odyssey/game'
|
||||
import logger from '../utils/logger.js'
|
||||
import config from '../config.js'
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { HydratedDocument } from 'mongoose'
|
||||
import type { QuestLocale } from '../../../packages/constants'
|
||||
import { LOCALE_NAME_MAP } from '../../../packages/constants'
|
||||
import { Session, UserProfile } from '../../../packages/models'
|
||||
import type { ISession, IUser } from '../../../packages/models'
|
||||
import type { QuestLocale } from '@odyssey/constants'
|
||||
import { LOCALE_NAME_MAP } from '@odyssey/constants'
|
||||
import { Session, UserProfile } from '@odyssey/models'
|
||||
import type { ISession, IUser } from '@odyssey/models'
|
||||
import {
|
||||
createContainer,
|
||||
deleteContainer,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Express } from 'express'
|
||||
import { format } from 'date-fns'
|
||||
import { User, UserProfile } from '../../../packages/models'
|
||||
import { User, UserProfile } from '@odyssey/models'
|
||||
import { hashPassword } from '../utils/auth.js'
|
||||
|
||||
export async function createUser(
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { z } from 'zod'
|
||||
import { SUPPORTED_LOCALES } from '@odyssey/constants'
|
||||
import { router, publicProcedure } from '../trpc.js'
|
||||
import { questManager } from '../models/quest.js'
|
||||
import { SUPPORTED_LOCALES } from '../../../packages/constants'
|
||||
|
||||
export const questRouter = router({
|
||||
getQuests: publicProcedure
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { z } from 'zod'
|
||||
import { SUPPORTED_LOCALES } from '../../../packages/constants'
|
||||
import { ISession, Session } from '../../../packages/models'
|
||||
import { GameSession, VoidFileExistenceChecker } from '../../../packages/game'
|
||||
import { SUPPORTED_LOCALES } from '@odyssey/constants'
|
||||
import { ISession, Session } from '@odyssey/models'
|
||||
import { GameSession, VoidFileExistenceChecker } from '@odyssey/game'
|
||||
import { createNewSession, isQuestUnlocked } from '../models/sessionManager.js'
|
||||
import config from '../config.js'
|
||||
import { protectedProcedure, router } from '../trpc.js'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { UserProfile } from '../../../packages/models'
|
||||
import { UserProfile } from '@odyssey/models'
|
||||
import { protectedProcedure, router } from '../trpc.js'
|
||||
|
||||
export const userRouter = router({
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { User } from '../../../packages/models'
|
||||
import { User } from '@odyssey/models'
|
||||
import config from '../config.js'
|
||||
import { createUser } from '../models/userManager.js'
|
||||
import logger from './logger.js'
|
||||
|
||||
Reference in new issue
Block a user