feat: add simple cli for nocobase api

This commit is contained in:
chenos 2021-04-07 17:37:14 +08:00
parent c2f18763c9
commit f58fad922f
3 changed files with 19 additions and 5 deletions

View File

@ -0,0 +1,13 @@
const keys = process.argv;
const key = keys.pop();
const dotenv = require('dotenv');
dotenv.config();
if (key === 'start') {
require('../lib/index');
} else if (key === 'db-init') {
require('../lib/migrations/init');
}

View File

@ -5,6 +5,9 @@
"types": "./lib/index.d.ts",
"license": "MIT",
"scripts": {},
"bin": {
"nocobase": "bin/nocobase.js"
},
"dependencies": {
"@nocobase/actions": "^0.4.0-alpha.2",
"@nocobase/client": "^0.4.0-alpha.2",

View File

@ -23,9 +23,7 @@ import { middlewares } from '@nocobase/server';
useStaticServer: !(process.env.APP_USE_STATIC_SERVER === 'false' || !process.env.APP_USE_STATIC_SERVER),
}));
if (require.main === module) {
api.listen(process.env.API_PORT, () => {
console.log(`http://localhost:${process.env.API_PORT}/`);
});
}
api.listen(process.env.API_PORT, () => {
console.log(`http://localhost:${process.env.API_PORT}/`);
});
})();