diff --git a/docs/commands/_category_.json b/docs/commands/_category_.json new file mode 100644 index 0000000..98e1b76 --- /dev/null +++ b/docs/commands/_category_.json @@ -0,0 +1,8 @@ +{ + "label": "Commands", + "position": 3, + "link": { + "type": "generated-index", + "description": "Orion Command Guide" + } +} diff --git a/docs/commands/configure-databases.md b/docs/commands/configure-databases.md new file mode 100644 index 0000000..beba2ba --- /dev/null +++ b/docs/commands/configure-databases.md @@ -0,0 +1,75 @@ +--- +sidebar_position: 5 +--- + +# Configure Databases + +The `npm run config` command is used to configure database connections for the Orion project. It allows developers to interactively set up database configurations for **MySQL**, **MongoDB**, **Redis**, or other supported databases. + +- [Getting Started with MySQL](https://dev.mysql.com/doc/mysql-getting-started/en) +- [Install MongoDB](https://www.mongodb.com/docs/manual/installation) +- [Install Redis](https://redis.io/docs/latest/operate/oss_and_stack/install/install-redis) + +## Usage + +```bash +>>> npm run config [dbType] +``` + +- `[dbType]`: The database type you want to configure (`mysql`, `mongo`, `redis`). + +Next, it will prompt you to configure credentials according to the `dbType` you've chosen. + +:::tip From the creator +No need to manually enter credentials in the `.env` file; we've taken care of it for you. +::: + +## Purpose +The `config` command simplifies database setup by asking for connection details from the developer. It then updates the `.env` file and generates the necessary configuration scripts. If there's a mistake in the setup, the system will automatically remove the connection file for you. + +## Output + +:::info Keep in mind +- No longer need the database connection? Just **delete the connection file** in the `config` folder, and it's all gone! +- Don't worry about the core details right now; we'll dive into the inner workings in the next sections. +::: + +### MongoDB +```bash +>>> npm run config mongo + +✔ MongoDB Connection URI: mongodb://localhost:27017 +✔ MongoDB Database Name: orion +[SUCCESS] Configuration script created at src/config/mongoConfig.js +``` + +Now, start the server. +```bash +>>> npm run dev + +[nodemon] starting `node index.js` +[INFO] Visit /visualize to see information about the routes. +[INFO] Server running on port 3000. +[SUCCESS] Connection successful: MongoDB +``` + +### MySQL +```bash +>>> npm run config mysql + +✔ MySQL Host: localhost +✔ MySQL User: root +✔ MySQL Password: [input is masked] +✔ MySQL Database Name: orion +[SUCCESS] Configuration script created at src/config/mysqlConfig.js +``` + +### Redis + +```bash +>>> npm run config redis + +✔ Redis Host: localhost +✔ Redis Port: 6379 +[SUCCESS] Configuration script created at src/config/redisConfig.js +``` \ No newline at end of file diff --git a/docs/commands/development.md b/docs/commands/development.md new file mode 100644 index 0000000..42ffee9 --- /dev/null +++ b/docs/commands/development.md @@ -0,0 +1,36 @@ +--- +sidebar_position: 3 +--- + +# Start development server + +The `npm run dev` command starts the Orion server in development mode with live-reloading & routes visualization enabled. It uses `nodemon` to monitor changes in the codebase and automatically restarts the server when changes are detected. + +## Usage + +```bash +>>> npm run dev +``` + +## Purpose +This command is used during the development phase to facilitate testing and debugging. It automatically reloads the server upon any code changes. Additionally, the development server enables a `/visualize` route, allowing you to view detailed information about the routes. + +:::info Note +To switch to development mode, set the `ENVIRONMENT` constant to `"development"`. +::: + +## Output + +```bash +>>> npm run dev + +> orion@1.0.0 dev +> nodemon index.js + +[nodemon] to restart at any time, enter `rs` +[nodemon] watching path(s): *.* +[nodemon] watching extensions: js,mjs,cjs,json +[nodemon] starting `node index.js` +[INFO] Visit /visualize to see information about the routes. +[INFO] Server running on port 3000. +``` \ No newline at end of file diff --git a/docs/commands/help.md b/docs/commands/help.md new file mode 100644 index 0000000..7a71ad1 --- /dev/null +++ b/docs/commands/help.md @@ -0,0 +1,32 @@ +--- +sidebar_position: 1 +--- + +# You need help? + +The `npm run help` command displays the help information for Orion’s CLI commands. It shows a list of available commands and a brief description of each. + +## Usage + +```bash +>>> npm run help +``` + +## Purpose +The help command serves as a quick reference for developers to understand the available commands and how to use them. + +## Output + +```bash +>>> npm run help +Orion CLI - Generate plug-and-play backend services. + +Options: + -V, --version output the version number + -h, --help display help for command + +Commands: + generate Generate a new set of controller, route or module files. + config [dbTypes...] Configure one or more databases. (mysql, mongo, redis) + help display help for command +``` \ No newline at end of file diff --git a/docs/commands/prettier.md b/docs/commands/prettier.md new file mode 100644 index 0000000..79a1960 --- /dev/null +++ b/docs/commands/prettier.md @@ -0,0 +1,34 @@ +--- +sidebar_position: 6 +--- + +# Using Prettier + +The `npm run prettier` command applies formatting to all code files based on Prettier's configuration settings. This ensures uniform code style throughout the project. The configuration details are specified in the `.prettierrc` file. + +## Usage + +```bash +>>> npm run prettier +``` + +## Purpose +This command is used to enforce code style guidelines in the project. It automatically formats all `.js`, `.json`, `.md`, and other supported files based on Prettier’s configuration. + +:::info Information +`npm run prettier:check` checks the codebase for any formatting issues based on Prettier’s configuration. +::: + +## Output + +```bash +# Format all files in the project. +>>> npm run prettier + +app.js 17ms (unchanged) +cli/config.js 10ms (unchanged) +... +... +templates/databases/redisConnection.js 2ms (unchanged) +templates/route.js 1ms (unchanged) +``` diff --git a/docs/commands/production.md b/docs/commands/production.md new file mode 100644 index 0000000..1f678bc --- /dev/null +++ b/docs/commands/production.md @@ -0,0 +1,36 @@ +--- +sidebar_position: 2 +--- + +# Start production server + +The `npm start` command is the default script for starting the Orion server in production mode. This command runs the server using Node.js without the additional development features such as live-reloading. + +## Usage + +```bash +>>> npm start +``` + +## Purpose +This command is typically used to run the Orion server in a production or staging environment. It starts the server by executing the `index.js` file. + +- **No Live-Reload:** The server runs without any development features such as hot-reloading and routes visualization. +- **Configuration:** It uses the environment variables set in the `.env` file to configure server behavior. + +:::info Note +Remember to change `ENVIRONMENT="production"` in `.env`. +::: + +- **Logging:** All output and errors are logged using the custom Logger utility. + +## Output + +```bash +>>> npm start + +> orion@1.0.0 start +> node index.js + +[INFO] Server running on port 3000. +``` \ No newline at end of file diff --git a/docs/commands/services.md b/docs/commands/services.md new file mode 100644 index 0000000..db402ab --- /dev/null +++ b/docs/commands/services.md @@ -0,0 +1,59 @@ +--- +sidebar_position: 4 +--- + +# Generate services + +The `npm run generate` command facilitates the creation of new routes, controllers, or modules by automating their integration into the project structure. Don't be concerned about the boilerplate code; we will guide you through its contents and show you how to incorporate your existing logic seamlessly. + +We assure you, the process is straightforward! ⭐ + +## Usage + +```bash +>>> npm run generate +``` + +- ``: The type of component you want to generate (`route`, `controller`, or `module`). +- ``: The name of the component. + +:::tip From the creator +A **module** combines a route and a controller into one package. Running this command will create both a route and its corresponding controller, naming them as specified. +::: + +## Purpose +The `generate` command helps developers avoid the hassle of manually creating files and registering them. Instead, it automatically generates standardized files with a predefined structure. + +Check out the [TODO] section to learn how to create and apply your own controllers and routes. + +## Output + +### Module +```bash +# Generate a new route and controller named 'user'. +>>> npm run generate module user + +[SUCCESS] Generated controller: /src/controllers/UserController.js +[SUCCESS] Generated route: /src/routes/UserRoute.js +[SUCCESS] Generated module with controller and route for: user +``` + +This command generates a `UserController.js` and `UserRoute.js` file and automatically sets them up in the project. + +Setting up your first route and controller is quite straightforward, isn't it? We told you so! Go to `/visualize` for more details about them. + +### Route +```bash +# Generate a new route named 'user'. +>>> npm run generate route user + +[SUCCESS] Generated route: /src/routes/UserRoute.js +``` + +### Controller +```bash +# Generate a new controller named 'user'. +>>> npm run generate controller user + +[SUCCESS] Generated controller: /src/controllers/UserController.js +```