Commit 40b413db authored by nanahira's avatar nanahira

bump to Koishi 4.8

parent c21fcc7f
import { App } from 'koishi'; import { Context } from 'koishi';
import TargetPlugin from '../src'; import TargetPlugin from '../src';
import ConsolePlugin from '@koishijs/plugin-console'; import ConsolePlugin from '@koishijs/plugin-console';
import SandboxPlugin from '@koishijs/plugin-sandbox'; import SandboxPlugin from '@koishijs/plugin-sandbox';
import * as DatabasePlugin from '@koishijs/plugin-database-memory'; import DatabasePlugin from '@koishijs/plugin-database-memory';
import CachePlugin from '@koishijs/plugin-cache-lru'; // import CachePlugin from '@koishijs/plugin-cache-lru';
import ExtrasInDev from './extras'; import ExtrasInDev from './extras';
const app = new App({ const app = new Context({
port: 14514, port: 14514,
host: 'localhost', host: 'localhost',
prefix: '.', prefix: '.',
...@@ -19,7 +19,7 @@ app.plugin(ConsolePlugin, { ...@@ -19,7 +19,7 @@ app.plugin(ConsolePlugin, {
}); });
// Some services // Some services
app.plugin(CachePlugin); // app.plugin(CachePlugin);
app.plugin(DatabasePlugin); app.plugin(DatabasePlugin);
// Some extras // Some extras
......
This diff is collapsed.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import { XffPluginConfig } from './config'; import { XffPluginConfig } from './config';
import { import {
DefinePlugin, DefinePlugin,
BasePlugin, StarterPlugin,
LifecycleEvents, LifecycleEvents,
Inject, Inject,
} from 'koishi-thirdeye'; } from 'koishi-thirdeye';
...@@ -11,7 +11,7 @@ import { Router } from 'koishi'; ...@@ -11,7 +11,7 @@ import { Router } from 'koishi';
@DefinePlugin({ name: 'xff', schema: XffPluginConfig }) @DefinePlugin({ name: 'xff', schema: XffPluginConfig })
export default class XffPlugin export default class XffPlugin
extends BasePlugin<XffPluginConfig> extends StarterPlugin(XffPluginConfig)
implements LifecycleEvents implements LifecycleEvents
{ {
@Inject(true) @Inject(true)
......
import { App } from 'koishi'; import { Context } from 'koishi';
import TargetPlugin from '../src'; import TargetPlugin from '../src';
import request from 'supertest'; import request from 'supertest';
describe('Test of plugin.', () => { describe('Test of plugin.', () => {
let app: App; let app: Context;
beforeEach(async () => { beforeEach(async () => {
app = new App(); app = new Context();
app.plugin(TargetPlugin); app.plugin(TargetPlugin);
await app.start(); await app.start();
}); });
...@@ -16,7 +16,7 @@ describe('Test of plugin.', () => { ...@@ -16,7 +16,7 @@ describe('Test of plugin.', () => {
ctx.status = 200; ctx.status = 200;
ctx.body = ctx.ip; ctx.body = ctx.ip;
}); });
return request(app._httpServer) return request(app.router._http)
.get('/ip') .get('/ip')
.set('x-forwarded-for', '1.1.1.1,11.4.51.4') .set('x-forwarded-for', '1.1.1.1,11.4.51.4')
.expect(200) .expect(200)
......
const path = require('path'); const path = require('path');
const packgeInfo = require('./package.json'); const packgeInfo = require('./package.json');
const { ESBuildMinifyPlugin } = require('esbuild-loader');
function externalsFromDep() { function externalsFromDep() {
return Object.fromEntries( return Object.fromEntries(
...@@ -43,4 +44,11 @@ module.exports = { ...@@ -43,4 +44,11 @@ module.exports = {
koishi: 'koishi', koishi: 'koishi',
...(packAll ? {} : externalsFromDep()), ...(packAll ? {} : externalsFromDep()),
}, },
optimization: {
minimizer: [
new ESBuildMinifyPlugin({
keepNames: true,
}),
],
},
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment