generated from tailored/router-template
temp
This commit is contained in:
@@ -2,23 +2,19 @@
|
||||
// https://bun.sh/docs/bundler
|
||||
// @ts-ignore
|
||||
import pkg from './package.json';
|
||||
// import { resolvePath as rp } from '@kevisual/use-config/env';
|
||||
import path from 'path';
|
||||
const rp = (resolvePath) => {
|
||||
return path.resolve(process.cwd(), resolvePath);
|
||||
};
|
||||
import { resolvePath as rp } from '@kevisual/use-config/env';
|
||||
|
||||
// bun run src/index.ts --
|
||||
await Bun.build({
|
||||
target: 'node',
|
||||
format: 'esm',
|
||||
entrypoints: [rp('src/index.js')],
|
||||
entrypoints: [rp('src/index.ts')],
|
||||
outdir: rp('./dist'),
|
||||
naming: {
|
||||
entry: 'app.mjs',
|
||||
},
|
||||
|
||||
define: {
|
||||
VERSION: JSON.stringify(pkg.version),
|
||||
},
|
||||
env: 'KEVISUAL_*',
|
||||
external: ['sequelize'],
|
||||
});
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"types": "app.d.ts",
|
||||
"scripts": {
|
||||
"build": "bun run bun.config.mjs",
|
||||
"postbuild": "dts -i src/index.js -o app.d.ts",
|
||||
"postbuild": "dts -i src/index.ts -o app.d.ts",
|
||||
"cmd": "tsx src/test/command.ts ",
|
||||
"dts": "dts -i src/index.js -o app.d.ts"
|
||||
},
|
||||
@@ -22,10 +22,21 @@
|
||||
"packageManager": "pnpm@10.10.0",
|
||||
"type": "module",
|
||||
"devDependencies": {
|
||||
"@kevisual/use-config": "^1.0.14",
|
||||
"@kevisual/xhs-core": "workspace:*",
|
||||
"@types/node": "^22.15.3"
|
||||
},
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./dist/app.mjs",
|
||||
"types": "./dist/app.d.ts"
|
||||
},
|
||||
"./index": {
|
||||
"import": "./src/index.ts"
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@kevisual/db": "^0.0.1",
|
||||
"nanoid": "^5.1.5",
|
||||
"sequelize": "^6.37.7",
|
||||
"sqlite3": "^5.1.7"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { QueryRouterServer } from '@kevisual/router';
|
||||
import { XhsServices } from '@/services/xhs-services.ts';
|
||||
import { QueryRouterServer } from '@kevisual/router/browser';
|
||||
import { XhsServices } from '@kevisual/xhs/services/xhs-services.ts';
|
||||
|
||||
export const app = new QueryRouterServer();
|
||||
export const xhsServices = new XhsServices();
|
||||
|
||||
@@ -49,7 +49,7 @@ export const getSign = async (signInfo: SignInfo, options?: SignOptions): Promis
|
||||
web_session: web_session,
|
||||
}),
|
||||
}).then((res) => res.json());
|
||||
return signs;
|
||||
return signs as SignResponse;
|
||||
} catch (error) {
|
||||
return null;
|
||||
}
|
||||
@@ -161,7 +161,7 @@ export class XhsClient extends XhsClientBase {
|
||||
const url = '/api/sns/web/v1/you/mentions';
|
||||
const response = await this.get(
|
||||
url,
|
||||
{ num: 20, cursor: '' },
|
||||
{ num: num, cursor: '' },
|
||||
{
|
||||
sign: this.sign.bind(this),
|
||||
needSign: true,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { app, xhsServices } from '@/app.ts';
|
||||
import { Parse } from '@/libs/parse.ts';
|
||||
import { app, xhsServices } from '@kevisual/xhs/app.ts';
|
||||
import { Parse } from '@kevisual/xhs/libs/parse.ts';
|
||||
app
|
||||
.route({
|
||||
path: 'fans',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { app, xhsServices } from '@/app.ts';
|
||||
import { app, xhsServices } from '@kevisual/xhs/app.ts';
|
||||
|
||||
app
|
||||
.route({
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { app, xhsServices } from '@/app.ts';
|
||||
import { Mention } from '@/libs/xhs-type/mention.ts';
|
||||
import { Parse } from '@/libs/parse.ts';
|
||||
import { app, xhsServices } from '@kevisual/xhs/app.ts';
|
||||
import { Mention } from '@kevisual/xhs/libs/xhs-type/mention.ts';
|
||||
import { Parse } from '@kevisual/xhs/libs/parse.ts';
|
||||
|
||||
app
|
||||
.route({
|
||||
@@ -20,7 +20,7 @@ app
|
||||
path: 'mention',
|
||||
key: 'getMention',
|
||||
payload: {
|
||||
num: 2,
|
||||
num: unread_count,
|
||||
},
|
||||
});
|
||||
if (mentionRes.code === 200) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { InitOptions, Model, Sequelize, SyncOptions } from 'sequelize';
|
||||
import { DBModel, Sequelize, SyncOptions } from '@kevisual/db';
|
||||
import { DataTypes } from 'sequelize';
|
||||
export class Comment extends Model {
|
||||
export class Comment extends DBModel {
|
||||
declare id: number;
|
||||
declare content: string;
|
||||
declare note_id: string;
|
||||
@@ -8,7 +8,7 @@ export class Comment extends Model {
|
||||
declare comment_id: string;
|
||||
declare created_at: Date;
|
||||
declare updated_at: Date;
|
||||
static async initModel(sequelize: Sequelize, initOptions?: InitOptions, opts?: SyncOptions) {
|
||||
static async initModel(sequelize: Sequelize, opts?: SyncOptions) {
|
||||
Comment.init(
|
||||
{
|
||||
id: {
|
||||
@@ -36,7 +36,6 @@ export class Comment extends Model {
|
||||
{
|
||||
sequelize, // passing the `sequelize` instance is required
|
||||
modelName: 'Comment', // we need to choose the model name
|
||||
...initOptions,
|
||||
},
|
||||
);
|
||||
await Comment.sync(opts || {});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { XhsClient } from '@/libs/xhs.ts';
|
||||
import { XhsClient } from '@kevisual/xhs/libs/xhs.ts';
|
||||
import { Sequelize } from 'sequelize';
|
||||
import { createSequelize } from '@/services/xhs-db/db.ts';
|
||||
import { createSequelize } from '@kevisual/xhs/services/xhs-db/db.ts';
|
||||
import path from 'node:path';
|
||||
import fs from 'node:fs';
|
||||
|
||||
@@ -22,6 +22,10 @@ type XhsClientMap = {
|
||||
type XhsServicesOptions = {
|
||||
root?: string;
|
||||
};
|
||||
/**
|
||||
* @description XhsServices is a singleton class that manages the XhsClient instances.
|
||||
* It is used to create and manage the XhsClient instances.
|
||||
*/
|
||||
export class XhsServices {
|
||||
map: Map<string, XhsClientMap> = new Map();
|
||||
root: string = 'root';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Comment } from '@/services/xhs-db/comment.ts';
|
||||
import { Comment } from '@kevisual/xhs/services/xhs-db/comment.ts';
|
||||
|
||||
import { Sequelize, Model, DataTypes, InferAttributes, InferCreationAttributes } from 'sequelize';
|
||||
import path from 'path';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { app } from '@/index.ts';
|
||||
import { app } from '@kevisual/xhs/index.ts';
|
||||
|
||||
app.parse({
|
||||
path: 'mention',
|
||||
|
||||
Binary file not shown.
@@ -5,13 +5,8 @@
|
||||
"lib": [
|
||||
"ESNext"
|
||||
],
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"types": [
|
||||
"node_modules/@types"
|
||||
],
|
||||
"paths": {
|
||||
"@/*": [
|
||||
"@kevisual/xhs/*": [
|
||||
"src/*"
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user