@chinturai/one-stack
v1.0.2
Published
Modular backend accelerator utilities for Express.js, built for flexibility, security, and production readiness.
Maintainers
Readme
one-stack
Build your complete backend using only a single stack , i.e : one-stack
Create full Express app , MongoDB models, Set up Auth, CRUD Routes all in one line using one-stack
one-stack is not a replacement , its a lightweight Express backend accelerator built for developers who want fast, secure, and maintainable APIs without sacrificing control.
Whether you're building an MVP, launching a prototype, or scaffolding a production-ready API, one-stack gives you the essentials in a composable and transparent package.
Why use one-stack?
one-stack is designed for developers who want:
- clean Express setup with no hidden framework behavior
- native Mongoose model creation with optional password hashing
- ready-to-use auth routes and JWT protection
- auto-generated CRUD endpoints with filters, pagination, and search
- production-ready defaults with error handling and logging
What it includes
createApp()— Express app starter with JSON parsing, CORS, security headers, and request loggingconnectDB()— Mongoose MongoDB connection with retries and connection loggingcreateModel()— native Mongoose model creation with timestamps and optional password hashingsetupAuth()— built-in auth routes plus JWT protection middlewarecreateCRUDRoutes()— auto-generated REST resources with pagination, sorting, filtering, and searchAppError+ centralized error handler for consistent API responses- CLI scaffolding for quick project and model generation
Installation
npm install @chinturai/one-stackQuick Start
const {
createApp,
connectDB,
createModel,
setupAuth,
createCRUDRoutes
} = require('@chinturai/one-stack');
const app = createApp();
connectDB(process.env.MONGO_URI);
const User = createModel(
'User',
{
name: { type: String, required: true },
email: { type: String, required: true, unique: true },
password: { type: String, required: true }
},
{ hashPassword: true }
);
setupAuth(app, {
userModel: User,
jwtSecret: process.env.JWT_SECRET,
routes: ['register', 'login', 'me']
});
createCRUDRoutes(app, '/users', User);
app.listen(3000);Usage Overview
createApp(options)
Creates an Express app with sensible defaults.
const app = createApp({
trustProxy: true,
cors: { origin: '*' },
logRequests: true
});connectDB(uri, options)
Connects to MongoDB with retry logic.
connectDB(process.env.MONGO_URI, {
retries: 5,
retryDelay: 3000
});createModel(name, schemaDefinition, options)
Builds a native Mongoose model and hides common boilerplate.
const User = createModel(
'User',
{
name: String,
email: { type: String, required: true, unique: true },
password: { type: String, required: true }
},
{
hashPassword: true,
timestamps: true
}
);setupAuth(app, config)
Adds auth endpoints and JWT handling.
setupAuth(app, {
userModel: User,
jwtSecret: process.env.JWT_SECRET,
routes: ['register', 'login', 'me'],
tokenExpiry: '2h',
routePrefix: '/auth'
});Supported routes:
POST /auth/registerPOST /auth/loginGET /auth/mePOST /auth/logout
protect(role)
Protect routes with JWT authentication.
const { protect } = require('@chinturai/one-stack');
app.get('/protected', protect(), (req, res) => {
res.json({ success: true, user: req.user });
});Use protect('admin') to enforce role-based access.
createCRUDRoutes(app, basePath, model, options)
Auto-generates RESTful endpoints for a model.
createCRUDRoutes(app, '/users', User, {
beforeCreate: (req) => {
// custom logic before creation
},
afterDelete: (doc) => {
// cleanup after delete
}
});Generated routes:
GET /usersGET /users/:idPOST /usersPUT /users/:idDELETE /users/:id
Query options include:
pageandlimitsortsearch- field filters
CLI
npx @chinturai/one-stack init
npx @chinturai/one-stack generate model User
npx @chinturai/one-stack generate crud UserRecommended workflow
npm install @chinturai/one-stackconst app = createApp()connectDB(process.env.MONGO_URI)const User = createModel(...)setupAuth(app, { userModel: User, jwtSecret: process.env.JWT_SECRET })createCRUDRoutes(app, '/users', User)
Get started quickly
one-stack is best for developers who want a fast, secure Express backend with minimal boilerplate.
If you want, add route protection, custom model hooks, or override auth handlers to match your application requirements.
