feat: add api package
This commit is contained in:
parent
e4840f9b76
commit
d3fa4d3d1a
@ -3,11 +3,12 @@
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "cd packages/app && npm start",
|
||||
"start-server": "cd packages/app && nodemon",
|
||||
"start-server": "cd packages/api && nodemon",
|
||||
"start-client": "cd packages/app && umi dev",
|
||||
"bootstrap": "lerna bootstrap --no-ci",
|
||||
"build": "father-build",
|
||||
"clean": "lerna clean",
|
||||
"db-migrate": "cd packages/app && npm run db-migrate",
|
||||
"db-migrate": "cd packages/api && npm run db-migrate",
|
||||
"db:start": "docker-compose up -d",
|
||||
"lint": "eslint --ext .ts,.tsx,.js \"packages/*/src/**.@(ts|tsx|js)\" --fix",
|
||||
"test": "npm run lint && jest",
|
||||
|
6
packages/api/nodemon.json
Normal file
6
packages/api/nodemon.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"watch": ["src", "../"],
|
||||
"ignore": ["../app"],
|
||||
"ext": "ts",
|
||||
"exec": "ts-node ./src/index.ts"
|
||||
}
|
22
packages/api/package.json
Normal file
22
packages/api/package.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "@nocobase/api",
|
||||
"version": "0.4.0-alpha.0",
|
||||
"scripts": {
|
||||
"start": "nodemon",
|
||||
"db-migrate": "ts-node ./src/migrate.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nocobase/actions": "^0.4.0-alpha.0",
|
||||
"@nocobase/client": "^0.4.0-alpha.0",
|
||||
"@nocobase/database": "^0.4.0-alpha.0",
|
||||
"@nocobase/plugin-action-logs": "^0.4.0-alpha.0",
|
||||
"@nocobase/plugin-china-region": "^0.4.0-alpha.0",
|
||||
"@nocobase/plugin-collections": "^0.4.0-alpha.0",
|
||||
"@nocobase/plugin-pages": "^0.4.0-alpha.0",
|
||||
"@nocobase/server": "^0.4.0-alpha.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"nodemon": "^2.0.6",
|
||||
"typescript": "^3.9.6"
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
import Api from '../../../server/src';
|
||||
import dotenv from 'dotenv';
|
||||
import path from 'path';
|
||||
import actions from '../../../actions/src';
|
||||
import associated from '../../../actions/src/middlewares/associated';
|
||||
import dotenv from 'dotenv';
|
||||
import Api from '../../server/src';
|
||||
import actions from '../../actions/src';
|
||||
import associated from '../../actions/src/middlewares/associated';
|
||||
|
||||
// @ts-ignore
|
||||
const sync = global.sync || {
|
||||
@ -61,13 +61,13 @@ api.resourcer.registerActionHandlers({...actions.common, ...actions.associate});
|
||||
// await next();
|
||||
// });
|
||||
|
||||
api.registerPlugin('plugin-collections', [path.resolve(__dirname, '../../../plugin-collections'), {}]);
|
||||
api.registerPlugin('plugin-action-logs', [path.resolve(__dirname, '../../../plugin-action-logs'), {}]);
|
||||
api.registerPlugin('plugin-pages', [path.resolve(__dirname, '../../../plugin-pages'), {}]);
|
||||
api.registerPlugin('plugin-users', [path.resolve(__dirname, '../../../plugin-users'), {}]);
|
||||
api.registerPlugin('plugin-file-manager', [path.resolve(__dirname, '../../../plugin-file-manager'), {}]);
|
||||
api.registerPlugin('plugin-permissions', [path.resolve(__dirname, '../../../plugin-permissions'), {}]);
|
||||
api.registerPlugin('plugin-automations', [path.resolve(__dirname, '../../../plugin-automations'), {}]);
|
||||
api.registerPlugin('plugin-china-region', [path.resolve(__dirname, '../../../plugin-china-region'), {}]);
|
||||
api.registerPlugin('plugin-collections', [path.resolve(__dirname, '../../plugin-collections'), {}]);
|
||||
api.registerPlugin('plugin-action-logs', [path.resolve(__dirname, '../../plugin-action-logs'), {}]);
|
||||
api.registerPlugin('plugin-pages', [path.resolve(__dirname, '../../plugin-pages'), {}]);
|
||||
api.registerPlugin('plugin-users', [path.resolve(__dirname, '../../plugin-users'), {}]);
|
||||
api.registerPlugin('plugin-file-manager', [path.resolve(__dirname, '../../plugin-file-manager'), {}]);
|
||||
api.registerPlugin('plugin-permissions', [path.resolve(__dirname, '../../plugin-permissions'), {}]);
|
||||
api.registerPlugin('plugin-automations', [path.resolve(__dirname, '../../plugin-automations'), {}]);
|
||||
api.registerPlugin('plugin-china-region', [path.resolve(__dirname, '../../plugin-china-region'), {}]);
|
||||
|
||||
export default api;
|
@ -1,5 +1,5 @@
|
||||
import api from './app';
|
||||
import actions from '../../../actions/src';
|
||||
import actions from '../../actions/src';
|
||||
|
||||
api.resourcer.use(async (ctx: actions.Context, next) => {
|
||||
const { actionName, resourceField, resourceName, fields = {} } = ctx.action.params;
|
16
packages/api/src/migrate.ts
Normal file
16
packages/api/src/migrate.ts
Normal file
@ -0,0 +1,16 @@
|
||||
|
||||
// @ts-ignore
|
||||
const keys = process.argv;
|
||||
|
||||
// @ts-ignore
|
||||
global.sync = {
|
||||
force: false,
|
||||
alter: {
|
||||
drop: false,
|
||||
},
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
const filename: string = keys.pop();
|
||||
|
||||
require(`./migrations/${filename}`);
|
@ -1,5 +1,6 @@
|
||||
{
|
||||
"watch": ["src/api", ".env", "../"],
|
||||
"watch": ["../"],
|
||||
"ignore": ["../app"],
|
||||
"ext": "ts",
|
||||
"exec": "ts-node ./src/api/index.ts"
|
||||
"exec": "ts-node ../api/src/index.ts"
|
||||
}
|
@ -1,11 +1,8 @@
|
||||
{
|
||||
"name": "@nocobase/app",
|
||||
"version": "0.4.0-alpha.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "concurrently \"nodemon\" \"umi dev\"",
|
||||
"start-api": "nodemon",
|
||||
"db-migrate": "ts-node ./src/api/migrate.ts",
|
||||
"build": "umi build",
|
||||
"postinstall": "umi generate tmp",
|
||||
"prettier": "prettier --write '**/*.{js,jsx,tsx,ts,less,md,json}'",
|
||||
@ -26,13 +23,6 @@
|
||||
"dependencies": {
|
||||
"@ant-design/pro-layout": "^5.0.12",
|
||||
"@formily/antd-components": "^1.3.6",
|
||||
"@nocobase/client": "^0.4.0-alpha.0",
|
||||
"@nocobase/database": "^0.4.0-alpha.0",
|
||||
"@nocobase/plugin-action-logs": "^0.4.0-alpha.0",
|
||||
"@nocobase/plugin-china-region": "^0.4.0-alpha.0",
|
||||
"@nocobase/plugin-collections": "^0.4.0-alpha.0",
|
||||
"@nocobase/plugin-pages": "^0.4.0-alpha.0",
|
||||
"@nocobase/server": "^0.4.0-alpha.0",
|
||||
"@types/react-big-calendar": "^0.24.8",
|
||||
"@umijs/preset-react": "1.x",
|
||||
"@umijs/test": "^3.2.23",
|
||||
|
@ -1,14 +0,0 @@
|
||||
|
||||
const args = process.argv;
|
||||
|
||||
// @ts-ignore
|
||||
global.sync = {
|
||||
force: false,
|
||||
alter: {
|
||||
drop: false,
|
||||
},
|
||||
};
|
||||
|
||||
const fileName: string = args.pop();
|
||||
|
||||
require(`./migrations/${fileName}`);
|
@ -45,10 +45,7 @@ export async function getInitialState() {
|
||||
const { data: systemSettings = {} } = await umiRequest('/system_settings:get?fields[appends]=logo,logo.storage', {
|
||||
method: 'get',
|
||||
});
|
||||
let redirect = '';
|
||||
// if (href.includes('?')) {
|
||||
redirect = `?redirect=${pathname}${search}`;
|
||||
// }
|
||||
let redirect = `?redirect=${pathname}${search}`;
|
||||
|
||||
if (!pathnames.includes(pathname)) {
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user