tachybase_todo/packages/create-nocobase-app/templates/AppGenerator/src/apis/index.ts
ChengLei Shao 05ecb25d1b
feat: create nocobase app with simple & quickstart option (#87)
* feat: create nocobase app with simple & quickstart option

* chore: delete template file

* create-nocobase-app: add env API_PORT fallback

* chore: log

* env default fallback

* move config dir

* change has yarn

* chore: prettier

* fix: npm running issue

* database testing support sqlite

* once...

* chore: typo

* fix: sqlite test

* update readme

* feat: copy .env.example to .env at create-nocobase-app

* create-nocobase-app: change sqlite3 to github master

* create-nocobase-app: .env template

* create-nocobase-app: update .env

* chore: typo

* update README

* chore: Application constructor

* feat: sqlite demo data support

* fix test

* fix: application error

* chore: plugin-client run sql

* fix: application createCli

* fix: can choose whether to register actions

* chore: model compile error

* fix: support sqlite

* fix: demo data set index sequence on postgresql

* chore: code reduce

* fix: operators are compatible with sqlite

* add impor demo option to init command

* update env

Co-authored-by: chenos <chenlinxh@gmail.com>
2021-10-18 12:49:37 +08:00

43 lines
1.0 KiB
TypeScript

import path from 'path';
import Application from '@nocobase/server';
const start = Date.now();
const api = new Application({
database: require('./config/db').default,
resourcer: {
prefix: '/api',
},
});
const plugins = [
'@nocobase/plugin-ui-router',
'@nocobase/plugin-ui-schema',
'@nocobase/plugin-collections',
'@nocobase/plugin-users',
'@nocobase/plugin-action-logs',
'@nocobase/plugin-file-manager',
'@nocobase/plugin-permissions',
'@nocobase/plugin-export',
'@nocobase/plugin-system-settings',
'@nocobase/plugin-china-region',
];
for (const plugin of plugins) {
api.plugin(require(`${plugin}/lib/server`).default);
}
api.plugin(require(`@nocobase/plugin-client/lib/server`).default, {
dist: path.resolve(process.cwd(), './dist'),
importDemo: true,
});
if (process.argv.length < 3) {
// @ts-ignore
process.argv.push('start', '--port', process.env.API_PORT || '13001');
}
api.parse(process.argv).then(() => {
console.log(`Start-up time: ${(Date.now() - start) / 1000}s`);
});