ojus v1.1.5
ojus
Lightweight, modular Node.js framework for quick API scaffolding
Table of Contents
- Installation
- Features
- Quick Start
- Project Structure
- CLI Commands
- Core Dependencies
- Contributing
- Author
- License
Installation
To get started with ojus, you can install it globally using npm:
npm install -g ojus
After installation, you can use the ojus
CLI to scaffold and manage your Node.js projects.
Features
- API scaffolding: Quickly scaffold REST or GraphQL APIs with just one command.
- Database integration: Supports MongoDB and SQL (Sequelize) out-of-the-box.
- Modular architecture: Built using the MVC (Model-View-Controller) pattern for easy maintainability.
- Command-line interface: A simple and intuitive CLI to scaffold new projects with minimal setup.
- Customizable: Generate flexible folder structures and include database configurations.
- Lightweight: Minimal dependencies for faster performance.
Quick Start
Create a new project using the ojus CLI:
ojus create my-project
During project creation, you will be prompted to choose:
- API type: REST or GraphQL
- Database type: MongoDB or SQL (Sequelize)
Once the project is generated, navigate into the project folder and install dependencies:
cd my-project
npm install
To start the server, run:
npm start
Project Structure
The generated project follows a modular, MVC-based structure. Here’s a typical structure for a REST API project:
my-project/
├── client/ (For frontend code)
│ ├── src/
│ │ ├── components/ (Reusable UI elements)
│ │ ├── pages/ (Route-specific components)
│ │ ├── utils/ (Utility functions)
│ │ ├── styles/ (CSS or styled-components)
│ │ └── App.js (Root application component)
│ ├── public/ (Static assets, favicon)
│ └── index.html (Entry point for the frontend)
├── server/ (For backend code)
│ ├── controllers/ (Business logic for API endpoints)
│ ├── models/ (Data models and database interactions)
│ ├── routes/ (API endpoints and routing configuration)
│ ├── config/ (Configuration files, e.g., database connection)
│ └── index.js (Entry point for the backend server)
├── .env (Environment variables for server-side configuration)
├── package.json (Project dependencies and scripts)
└── README.md
REST API:
- controllers/: Contains the logic for handling requests (e.g.,
userController.js
). - models/: Defines data models (e.g.,
user.js
). - routes/: Defines routes for the API (e.g.,
userRoutes.js
). - config/: Configuration files, such as database setup.
- app.js: Initializes the app, middleware, and routes.
GraphQL API:
- graphql/schema.js: Defines the GraphQL schema.
- graphql/resolvers.js: Handles GraphQL query and mutation logic.
CLI Commands
Create a New Project
ojus <project-name>
Scaffold a new project. You'll be prompted to select:
- API type: REST or GraphQL
- Database: MongoDB or SQL (Sequelize)
Start the Development Server
Once inside your project directory, you can start the development server:
npm start
This command will launch the server, and it will be accessible at http://localhost:3000
.
Folder Structure
By default, ojus generates a project with the following structure:
controllers/
: Business logic for API requests.models/
: Database models for either MongoDB or Sequelize.routes/
: Route handlers for your API endpoints.graphql/
: Contains the GraphQL schema and resolvers (if GraphQL was selected).config/
: Stores database and other configuration files.
Custom Configuration
You can modify environment variables using the .env
file in your project’s root directory. Typical values include:
PORT=3000
DATABASE_URL=mongodb://localhost:27017/mydatabase
Core Dependencies
- Express.js: Web framework for handling API routes.
- Mongoose: ODM for MongoDB integration.
- Sequelize: ORM for SQL-based databases (optional, if SQL is selected).
- GraphQL: If GraphQL is selected, provides a schema-first API layer.
- dotenv: For environment variables and configuration.
Contributing
Contributions are welcome! To contribute:
- Fork the repository.
- Create a new branch with your feature or bug fix.
- Submit a pull request with detailed information about the changes.
Please follow the coding standards and include relevant tests for any new functionality
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago