mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 09:47:10 +00:00
474b09c7f2
* 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
48 lines
896 B
JavaScript
48 lines
896 B
JavaScript
const Koa = require('koa');
|
|
const { Sequelize, DataTypes } = require('sequelize');
|
|
const dotenv = require('dotenv');
|
|
|
|
dotenv.config();
|
|
|
|
const sequelize = new Sequelize({
|
|
dialect: process.env.DB_DIALECT,
|
|
username: process.env.DB_USER,
|
|
password: process.env.DB_PASSWORD,
|
|
database: process.env.DB_DATABASE,
|
|
host: process.env.DB_HOST,
|
|
port: process.env.DB_PORT,
|
|
logging: false,
|
|
});
|
|
|
|
const User = sequelize.define(
|
|
'users',
|
|
{
|
|
nickname: DataTypes.STRING,
|
|
username: {
|
|
type: DataTypes.STRING,
|
|
unique: true,
|
|
},
|
|
email: {
|
|
type: DataTypes.STRING,
|
|
unique: true,
|
|
},
|
|
},
|
|
{
|
|
underscored: true,
|
|
},
|
|
);
|
|
|
|
const app = new Koa();
|
|
|
|
app.use(async (ctx, next) => {
|
|
ctx.body = await User.findAndCountAll({
|
|
offset: 0,
|
|
limit: 20,
|
|
});
|
|
await next();
|
|
});
|
|
|
|
app.listen(13020, () => {
|
|
console.log('koa-sequelize: http://localhost:13020/');
|
|
});
|