@authup/server-api
Version:
This is a standalone application.
75 lines • 2.47 kB
JavaScript
/*
* Copyright (c) 2021-2021.
* Author Peter Placzek (tada5hi)
* For the full copyright and license information,
* view the LICENSE file that was distributed with this source code.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SetupCommand = void 0;
const node_process_1 = __importDefault(require("node:process"));
const core_1 = require("../../core");
const commands_1 = require("../../commands");
const config_1 = require("../../config");
const database_1 = require("../../database");
class SetupCommand {
constructor() {
this.command = 'setup';
this.describe = 'Setup the server.';
}
// eslint-disable-next-line class-methods-use-this
builder(args) {
return args
.option('root', {
alias: 'r',
default: node_process_1.default.cwd(),
describe: 'Path to the project root directory.',
})
.option('database', {
alias: 'db',
describe: 'Create database.',
type: 'boolean',
})
.option('databaseSchema', {
alias: 'db:schema',
describe: 'Setup the schema of database.',
type: 'boolean',
})
.option('databaseSeed', {
alias: 'db:seed',
describe: 'Seed database.',
type: 'boolean',
})
.option('documentation', {
alias: 'docs',
describe: 'Create swagger documentation.',
type: 'boolean',
});
}
// eslint-disable-next-line class-methods-use-this
async handler(args) {
const config = await (0, config_1.setupConfig)();
const dataSourceOptions = await (0, database_1.buildDataSourceOptions)();
const logger = (0, core_1.createLogger)({
directory: config.get('writableDirectoryPath'),
env: config.get('env'),
});
try {
await (0, commands_1.setupCommand)({
dataSourceOptions,
logger,
...args,
});
}
catch (e) {
logger.error(e);
node_process_1.default.exit(1);
}
node_process_1.default.exit(0);
}
}
exports.SetupCommand = SetupCommand;
//# sourceMappingURL=setup.js.map
;