mirror of
https://github.com/nocobase/nocobase.git
synced 2026-09-19 02:23:00 +08:00
perf(server): optimize performance of APIs (#3079)
* perf: add perf_hooks * perf: add cache * fix: test * feat: support bloom filter * feat: caching token black list * perf: caching i18n instance * fix: test * fix: test * chore: remove prePerfHooks on app * chore: improve i18n instances cache * chore: remove performance measure * fix: package.json * perf: optimize cache strategy * fix: test * fix: bug * test: storer of auth-manager * fix: afterDestroy hook when updating null value * fix: version * chore: fix bug and add test * fix: test * fix: test
This commit is contained in:
@@ -76,7 +76,10 @@ const app = new Koa();
|
||||
|
||||
app.use(async (ctx, next) => {
|
||||
const repository = db.getRepository('users');
|
||||
ctx.body = await repository.find();
|
||||
ctx.body = await repository.findAndCount({
|
||||
limit: 20,
|
||||
offset: 0,
|
||||
});
|
||||
await next();
|
||||
});
|
||||
|
||||
|
||||
@@ -35,7 +35,10 @@ const User = sequelize.define(
|
||||
const app = new Koa();
|
||||
|
||||
app.use(async (ctx, next) => {
|
||||
ctx.body = await User.findAll();
|
||||
ctx.body = await User.findAndCountAll({
|
||||
offset: 0,
|
||||
limit: 20,
|
||||
});
|
||||
await next();
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const { Application } = require('@nocobase/server');
|
||||
const dotenv = require('dotenv');
|
||||
const { PerformanceObserver, createHistogram } = require('perf_hooks');
|
||||
|
||||
dotenv.config();
|
||||
|
||||
@@ -21,8 +22,14 @@ const app = new Application({
|
||||
resourcer: {
|
||||
prefix: '/api',
|
||||
},
|
||||
logger: {
|
||||
// skip: () => true,
|
||||
// transports: ['console'],
|
||||
// level: 'error',
|
||||
},
|
||||
acl: false,
|
||||
plugins: [],
|
||||
perfHooks: true,
|
||||
});
|
||||
|
||||
app.db.collection({
|
||||
@@ -78,6 +85,13 @@ app.db.collection({
|
||||
],
|
||||
});
|
||||
|
||||
// const obs = new PerformanceObserver((items) => {
|
||||
// items.getEntries().forEach((item) => {
|
||||
// console.log(item);
|
||||
// });
|
||||
// });
|
||||
// obs.observe({ entryTypes: ['measure'] });
|
||||
|
||||
app.listen(13030, (err) => {
|
||||
console.log('nocobase-server: http://localhost:13030/api/users');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user