@@ -48,16 +48,17 @@
|
|||||||
"changelog": true
|
"changelog": true
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@algolia/client-search": "^4.20.0",
|
"@algolia/client-search": "^4.21.1",
|
||||||
"@babel/core": "7.23.6",
|
"@babel/core": "7.23.6",
|
||||||
"@babel/plugin-transform-modules-commonjs": "7.23.3",
|
"@babel/plugin-transform-modules-commonjs": "7.23.3",
|
||||||
"@babel/plugin-transform-typescript": "7.23.6",
|
"@babel/plugin-transform-typescript": "7.23.6",
|
||||||
"@babel/types": "^7.23.5",
|
"@babel/types": "^7.23.6",
|
||||||
"@clerk/clerk-sdk-node": "4.13.1",
|
"@clerk/clerk-sdk-node": "4.13.1",
|
||||||
"@fastify/cookie": "9.2.0",
|
"@fastify/cookie": "9.2.0",
|
||||||
"@fastify/multipart": "8.0.0",
|
"@fastify/multipart": "8.0.0",
|
||||||
"@fastify/static": "6.12.0",
|
"@fastify/static": "6.12.0",
|
||||||
"@innei/next-async": "0.3.0",
|
"@innei/next-async": "0.3.0",
|
||||||
|
"@mx-space/external": "workspace:*",
|
||||||
"@nestjs/cache-manager": "2.1.1",
|
"@nestjs/cache-manager": "2.1.1",
|
||||||
"@nestjs/common": "10.2.10",
|
"@nestjs/common": "10.2.10",
|
||||||
"@nestjs/core": "10.2.10",
|
"@nestjs/core": "10.2.10",
|
||||||
@@ -98,7 +99,7 @@
|
|||||||
"linkedom": "0.16.4",
|
"linkedom": "0.16.4",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"lru-cache": "10.1.0",
|
"lru-cache": "10.1.0",
|
||||||
"marked": "10.0.0",
|
"marked": "11.1.0",
|
||||||
"mime-types": "^2.1.35",
|
"mime-types": "^2.1.35",
|
||||||
"mkdirp": "^3.0.1",
|
"mkdirp": "^3.0.1",
|
||||||
"mongoose": "8.0.3",
|
"mongoose": "8.0.3",
|
||||||
@@ -107,7 +108,6 @@
|
|||||||
"mongoose-lean-getters": "1.1.0",
|
"mongoose-lean-getters": "1.1.0",
|
||||||
"mongoose-lean-virtuals": "0.9.1",
|
"mongoose-lean-virtuals": "0.9.1",
|
||||||
"mongoose-paginate-v2": "1.7.31",
|
"mongoose-paginate-v2": "1.7.31",
|
||||||
"nanoid": "3.3.4",
|
|
||||||
"nestjs-pretty-logger": "0.2.0",
|
"nestjs-pretty-logger": "0.2.0",
|
||||||
"node-machine-id": "1.1.12",
|
"node-machine-id": "1.1.12",
|
||||||
"node-pty": "1.0.0",
|
"node-pty": "1.0.0",
|
||||||
@@ -162,4 +162,4 @@
|
|||||||
"mongodb-memory-server": "^9.1.1",
|
"mongodb-memory-server": "^9.1.1",
|
||||||
"redis-memory-server": "^0.10.0"
|
"redis-memory-server": "^0.10.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import jwt from 'jsonwebtoken'
|
import jwt from 'jsonwebtoken'
|
||||||
import { isDate, omit } from 'lodash'
|
import { isDate, omit } from 'lodash'
|
||||||
import { customAlphabet } from 'nanoid/async'
|
|
||||||
import type { TokenModel, UserModel } from '~/modules/user/user.model'
|
import type { TokenModel, UserModel } from '~/modules/user/user.model'
|
||||||
import type { TokenDto } from './auth.controller'
|
import type { TokenDto } from './auth.controller'
|
||||||
|
|
||||||
import { Clerk } from '@clerk/clerk-sdk-node'
|
import { Clerk } from '@clerk/clerk-sdk-node'
|
||||||
|
import { nanoid } from '@mx-space/external'
|
||||||
import { forwardRef, Inject, Injectable, Logger } from '@nestjs/common'
|
import { forwardRef, Inject, Injectable, Logger } from '@nestjs/common'
|
||||||
import { ReturnModelType } from '@typegoose/typegoose'
|
import { ReturnModelType } from '@typegoose/typegoose'
|
||||||
|
|
||||||
@@ -16,6 +16,8 @@ import { InjectModel } from '~/transformers/model.transformer'
|
|||||||
|
|
||||||
import { ConfigsService } from '../configs/configs.service'
|
import { ConfigsService } from '../configs/configs.service'
|
||||||
|
|
||||||
|
const { customAlphabet } = nanoid
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AuthService {
|
export class AuthService {
|
||||||
private readonly logger = new Logger(AuthService.name)
|
private readonly logger = new Logger(AuthService.name)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { FastifyReply, FastifyRequest } from 'fastify'
|
import { FastifyReply, FastifyRequest } from 'fastify'
|
||||||
import { lookup } from 'mime-types'
|
import { lookup } from 'mime-types'
|
||||||
import { customAlphabet } from 'nanoid/async'
|
|
||||||
|
|
||||||
|
import { nanoid } from '@mx-space/external'
|
||||||
import { Delete, Get, Param, Post, Query, Req, Res } from '@nestjs/common'
|
import { Delete, Get, Param, Post, Query, Req, Res } from '@nestjs/common'
|
||||||
import { Throttle } from '@nestjs/throttler'
|
import { Throttle } from '@nestjs/throttler'
|
||||||
|
|
||||||
@@ -17,6 +17,8 @@ import { PagerDto } from '~/shared/dto/pager.dto'
|
|||||||
import { FileQueryDto, FileUploadDto } from './file.dto'
|
import { FileQueryDto, FileUploadDto } from './file.dto'
|
||||||
import { FileService } from './file.service'
|
import { FileService } from './file.service'
|
||||||
|
|
||||||
|
const { customAlphabet } = nanoid
|
||||||
|
|
||||||
@ApiController(['objects', 'files'])
|
@ApiController(['objects', 'files'])
|
||||||
export class FileController {
|
export class FileController {
|
||||||
constructor(
|
constructor(
|
||||||
|
|||||||
@@ -161,5 +161,5 @@ marked.use({
|
|||||||
})
|
})
|
||||||
|
|
||||||
export const markdownToHtml = (markdown: string) => {
|
export const markdownToHtml = (markdown: string) => {
|
||||||
return marked(markdown, { gfm: true })
|
return marked(markdown, { gfm: true }) as string
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
// THIS MODULE IS DISABLED
|
// THIS MODULE IS DISABLED
|
||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import { isNil, pick } from 'lodash'
|
import { isNil, pick } from 'lodash'
|
||||||
import { nanoid } from 'nanoid'
|
|
||||||
import { spawn } from 'node-pty'
|
import { spawn } from 'node-pty'
|
||||||
import { Socket } from 'socket.io'
|
import { Socket } from 'socket.io'
|
||||||
import { quiet } from 'zx-cjs'
|
import { quiet } from 'zx-cjs'
|
||||||
@@ -12,6 +11,7 @@ import type {
|
|||||||
} from '@nestjs/websockets'
|
} from '@nestjs/websockets'
|
||||||
import type { IPty } from 'node-pty'
|
import type { IPty } from 'node-pty'
|
||||||
|
|
||||||
|
import { nanoid as N } from '@mx-space/external'
|
||||||
import { SubscribeMessage, WebSocketGateway } from '@nestjs/websockets'
|
import { SubscribeMessage, WebSocketGateway } from '@nestjs/websockets'
|
||||||
|
|
||||||
import { DEMO_MODE } from '~/app.config'
|
import { DEMO_MODE } from '~/app.config'
|
||||||
@@ -25,6 +25,8 @@ import { JWTService } from '~/processors/helper/helper.jwt.service'
|
|||||||
import { CacheService } from '~/processors/redis/cache.service'
|
import { CacheService } from '~/processors/redis/cache.service'
|
||||||
import { getIp, getRedisKey } from '~/utils'
|
import { getIp, getRedisKey } from '~/utils'
|
||||||
|
|
||||||
|
const { nanoid } = N
|
||||||
|
|
||||||
const AuthGateway = createAuthGateway({ namespace: 'pty', authway: 'jwt' })
|
const AuthGateway = createAuthGateway({ namespace: 'pty', authway: 'jwt' })
|
||||||
@WebSocketGateway<GatewayMetadata>({ namespace: 'pty' })
|
@WebSocketGateway<GatewayMetadata>({ namespace: 'pty' })
|
||||||
export class PTYGateway
|
export class PTYGateway
|
||||||
@@ -99,10 +101,10 @@ export class PTYGateway
|
|||||||
os.platform() === 'win32'
|
os.platform() === 'win32'
|
||||||
? 'powershell.exe'
|
? 'powershell.exe'
|
||||||
: zsh.exitCode == 0
|
: zsh.exitCode == 0
|
||||||
? 'zsh'
|
? 'zsh'
|
||||||
: fish.exitCode == 0
|
: fish.exitCode == 0
|
||||||
? 'fish'
|
? 'fish'
|
||||||
: 'bash',
|
: 'bash',
|
||||||
[],
|
[],
|
||||||
{
|
{
|
||||||
cwd: DATA_DIR,
|
cwd: DATA_DIR,
|
||||||
|
|||||||
@@ -489,7 +489,6 @@ export class ServerlessService implements OnModuleInit {
|
|||||||
'jszip',
|
'jszip',
|
||||||
'lodash',
|
'lodash',
|
||||||
'marked',
|
'marked',
|
||||||
'nanoid',
|
|
||||||
'qs',
|
'qs',
|
||||||
'rxjs',
|
'rxjs',
|
||||||
'snakecase-keys',
|
'snakecase-keys',
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
import cluster from 'cluster'
|
import cluster from 'cluster'
|
||||||
import { render } from 'ejs'
|
import { render } from 'ejs'
|
||||||
import { LRUCache } from 'lru-cache'
|
import { LRUCache } from 'lru-cache'
|
||||||
import { nanoid } from 'nanoid'
|
|
||||||
import type { CoAction } from '@innei/next-async/types/interface'
|
import type { CoAction } from '@innei/next-async/types/interface'
|
||||||
import type { OnModuleDestroy, OnModuleInit } from '@nestjs/common'
|
import type { OnModuleDestroy, OnModuleInit } from '@nestjs/common'
|
||||||
import type { IEventManagerHandlerDisposer } from '~/processors/helper/helper.event.service'
|
import type { IEventManagerHandlerDisposer } from '~/processors/helper/helper.event.service'
|
||||||
@@ -11,6 +10,7 @@ import type { PostModel } from '../post/post.model'
|
|||||||
import type { SubscribeTemplateRenderProps } from './subscribe.email.default'
|
import type { SubscribeTemplateRenderProps } from './subscribe.email.default'
|
||||||
|
|
||||||
import { Co } from '@innei/next-async'
|
import { Co } from '@innei/next-async'
|
||||||
|
import { nanoid as N } from '@mx-space/external'
|
||||||
import { BadRequestException, Injectable } from '@nestjs/common'
|
import { BadRequestException, Injectable } from '@nestjs/common'
|
||||||
|
|
||||||
import { BusinessEvents, EventScope } from '~/constants/business-event.constant'
|
import { BusinessEvents, EventScope } from '~/constants/business-event.constant'
|
||||||
@@ -32,6 +32,8 @@ import {
|
|||||||
import { defaultSubscribeForRenderProps } from './subscribe.email.default'
|
import { defaultSubscribeForRenderProps } from './subscribe.email.default'
|
||||||
import { SubscribeModel } from './subscribe.model'
|
import { SubscribeModel } from './subscribe.model'
|
||||||
|
|
||||||
|
const { nanoid } = N
|
||||||
|
|
||||||
declare type Email = string
|
declare type Email = string
|
||||||
declare type SubscribeBit = number
|
declare type SubscribeBit = number
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"prepare": "husky install && node scripts/init-project.mjs && corepack enable",
|
"prepare": "husky install && node scripts/init-project.mjs && corepack enable",
|
||||||
"build": "pnpm -C \"apps/core\" run build",
|
"build": "pnpm -C \"apps/core\" run build",
|
||||||
"dev": "pnpm -C \"apps/core\" run start",
|
"dev": "pnpm -C \"packages/external\" run build && pnpm -C \"apps/core\" run start",
|
||||||
"bundle": "pnpm -C \"apps/core\" run bundle",
|
"bundle": "pnpm -C \"apps/core\" run bundle",
|
||||||
"test": "pnpm -C \"apps/core\" run test",
|
"test": "pnpm -C \"apps/core\" run test",
|
||||||
"lint": "eslint --cache --ext .ts,.tsx --ignore-path .gitignore . --fix",
|
"lint": "eslint --cache --ext .ts,.tsx --ignore-path .gitignore . --fix",
|
||||||
@@ -45,6 +45,7 @@
|
|||||||
"rimraf": "5.0.5",
|
"rimraf": "5.0.5",
|
||||||
"ts-node": "10.9.2",
|
"ts-node": "10.9.2",
|
||||||
"tsconfig-paths": "4.2.0",
|
"tsconfig-paths": "4.2.0",
|
||||||
|
"tsup": "8.0.1",
|
||||||
"typescript": "5.3.3",
|
"typescript": "5.3.3",
|
||||||
"vite-tsconfig-paths": "4.2.2"
|
"vite-tsconfig-paths": "4.2.2"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
"@types/lodash": "4.14.202",
|
"@types/lodash": "4.14.202",
|
||||||
"abort-controller": "3.0.0",
|
"abort-controller": "3.0.0",
|
||||||
"axios": "^1.6.2",
|
"axios": "^1.6.2",
|
||||||
"camelcase-keys": "^7.0.2",
|
"camelcase-keys": "^9.1.2",
|
||||||
"cors": "2.8.5",
|
"cors": "2.8.5",
|
||||||
"express": "4.18.2",
|
"express": "4.18.2",
|
||||||
"form-data": "4.0.0",
|
"form-data": "4.0.0",
|
||||||
@@ -57,7 +57,7 @@
|
|||||||
"lodash": "4.17.21",
|
"lodash": "4.17.21",
|
||||||
"tsup": "8.0.1",
|
"tsup": "8.0.1",
|
||||||
"umi-request": "1.4.0",
|
"umi-request": "1.4.0",
|
||||||
"vite": "^5.0.7",
|
"vite": "^5.0.8",
|
||||||
"vitest": "^0.34.6"
|
"vitest": "^1.0.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
90
packages/external/dist/index.cjs
vendored
Normal file
90
packages/external/dist/index.cjs
vendored
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
"use strict";
|
||||||
|
var __defProp = Object.defineProperty;
|
||||||
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||||
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||||
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||||
|
var __export = (target, all) => {
|
||||||
|
for (var name in all)
|
||||||
|
__defProp(target, name, { get: all[name], enumerable: true });
|
||||||
|
};
|
||||||
|
var __copyProps = (to, from, except, desc) => {
|
||||||
|
if (from && typeof from === "object" || typeof from === "function") {
|
||||||
|
for (let key of __getOwnPropNames(from))
|
||||||
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||||
|
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||||
|
}
|
||||||
|
return to;
|
||||||
|
};
|
||||||
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||||
|
|
||||||
|
// index.ts
|
||||||
|
var external_exports = {};
|
||||||
|
__export(external_exports, {
|
||||||
|
nanoid: () => nanoid_exports
|
||||||
|
});
|
||||||
|
module.exports = __toCommonJS(external_exports);
|
||||||
|
|
||||||
|
// ../../node_modules/.pnpm/nanoid@5.0.4/node_modules/nanoid/index.js
|
||||||
|
var nanoid_exports = {};
|
||||||
|
__export(nanoid_exports, {
|
||||||
|
customAlphabet: () => customAlphabet,
|
||||||
|
customRandom: () => customRandom,
|
||||||
|
nanoid: () => nanoid,
|
||||||
|
random: () => random,
|
||||||
|
urlAlphabet: () => urlAlphabet
|
||||||
|
});
|
||||||
|
var import_node_crypto = require("crypto");
|
||||||
|
|
||||||
|
// ../../node_modules/.pnpm/nanoid@5.0.4/node_modules/nanoid/url-alphabet/index.js
|
||||||
|
var urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
||||||
|
|
||||||
|
// ../../node_modules/.pnpm/nanoid@5.0.4/node_modules/nanoid/index.js
|
||||||
|
var POOL_SIZE_MULTIPLIER = 128;
|
||||||
|
var pool;
|
||||||
|
var poolOffset;
|
||||||
|
function fillPool(bytes) {
|
||||||
|
if (!pool || pool.length < bytes) {
|
||||||
|
pool = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER);
|
||||||
|
import_node_crypto.webcrypto.getRandomValues(pool);
|
||||||
|
poolOffset = 0;
|
||||||
|
} else if (poolOffset + bytes > pool.length) {
|
||||||
|
import_node_crypto.webcrypto.getRandomValues(pool);
|
||||||
|
poolOffset = 0;
|
||||||
|
}
|
||||||
|
poolOffset += bytes;
|
||||||
|
}
|
||||||
|
function random(bytes) {
|
||||||
|
fillPool(bytes -= 0);
|
||||||
|
return pool.subarray(poolOffset - bytes, poolOffset);
|
||||||
|
}
|
||||||
|
function customRandom(alphabet, defaultSize, getRandom) {
|
||||||
|
let mask = (2 << 31 - Math.clz32(alphabet.length - 1 | 1)) - 1;
|
||||||
|
let step = Math.ceil(1.6 * mask * defaultSize / alphabet.length);
|
||||||
|
return (size = defaultSize) => {
|
||||||
|
let id = "";
|
||||||
|
while (true) {
|
||||||
|
let bytes = getRandom(step);
|
||||||
|
let i = step;
|
||||||
|
while (i--) {
|
||||||
|
id += alphabet[bytes[i] & mask] || "";
|
||||||
|
if (id.length === size)
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
function customAlphabet(alphabet, size = 21) {
|
||||||
|
return customRandom(alphabet, size, random);
|
||||||
|
}
|
||||||
|
function nanoid(size = 21) {
|
||||||
|
fillPool(size -= 0);
|
||||||
|
let id = "";
|
||||||
|
for (let i = poolOffset - size; i < poolOffset; i++) {
|
||||||
|
id += urlAlphabet[pool[i] & 63];
|
||||||
|
}
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
// Annotate the CommonJS export names for ESM import in node:
|
||||||
|
0 && (module.exports = {
|
||||||
|
nanoid
|
||||||
|
});
|
||||||
2
packages/external/dist/index.d.cts
vendored
Normal file
2
packages/external/dist/index.d.cts
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
import * as nanoid from 'nanoid';
|
||||||
|
export { nanoid };
|
||||||
3
packages/external/index.ts
vendored
Normal file
3
packages/external/index.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import * as nanoid from 'nanoid'
|
||||||
|
|
||||||
|
export { nanoid }
|
||||||
11
packages/external/package.json
vendored
Normal file
11
packages/external/package.json
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"name": "@mx-space/external",
|
||||||
|
"type": "module",
|
||||||
|
"main": "dist/index.cjs",
|
||||||
|
"scripts": {
|
||||||
|
"build": "tsup"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"nanoid": "5.0.4"
|
||||||
|
}
|
||||||
|
}
|
||||||
37
packages/external/tsconfig.json
vendored
Normal file
37
packages/external/tsconfig.json
vendored
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"declaration": true,
|
||||||
|
"outDir": "./esm",
|
||||||
|
"baseUrl": ".",
|
||||||
|
"jsx": "react",
|
||||||
|
"target": "ES2020",
|
||||||
|
"lib": [
|
||||||
|
"ESNext",
|
||||||
|
"DOM",
|
||||||
|
"DOM.Iterable"
|
||||||
|
],
|
||||||
|
"module": "ESNext",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"strict": true,
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"sourceMap": true,
|
||||||
|
"paths": {
|
||||||
|
"~/*": [
|
||||||
|
"*"
|
||||||
|
],
|
||||||
|
"@core/*": [
|
||||||
|
"../../apps/core/src/*"
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"exclude": [
|
||||||
|
"esm/*",
|
||||||
|
"build/*",
|
||||||
|
"node_modules/*",
|
||||||
|
"lib/*",
|
||||||
|
"dist/**"
|
||||||
|
]
|
||||||
|
}
|
||||||
9
packages/external/tsup.config.ts
vendored
Normal file
9
packages/external/tsup.config.ts
vendored
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import { defineConfig } from 'tsup'
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
clean: true,
|
||||||
|
target: 'es2020',
|
||||||
|
entry: ['index.ts'],
|
||||||
|
dts: true,
|
||||||
|
format: ['cjs'],
|
||||||
|
})
|
||||||
764
pnpm-lock.yaml
generated
764
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user