@ahmadubaidillah/cli 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +289 -276
- package/dist/templates/ai_wrapper/files/README.md +3 -0
- package/dist/templates/ai_wrapper/files/package.json +16 -0
- package/dist/templates/ai_wrapper/files/src/app.ts +23 -0
- package/dist/templates/ai_wrapper/files/src/modules/prompts/prompts.routes.ts +64 -0
- package/dist/templates/ai_wrapper/files/src/modules/usage/usage.routes.ts +12 -0
- package/dist/templates/ai_wrapper/template.config.json +16 -0
- package/dist/templates/booking/files/README.md +3 -0
- package/dist/templates/booking/files/package.json +16 -0
- package/dist/templates/booking/files/src/app.ts +23 -0
- package/dist/templates/booking/files/src/modules/availability/availability.routes.ts +12 -0
- package/dist/templates/booking/files/src/modules/calendar/calendar.routes.ts +12 -0
- package/dist/templates/booking/template.config.json +17 -0
- package/dist/templates/cms/files/frontend/src/components/editor/Editor.tsx +36 -0
- package/dist/templates/cms/files/package.json +22 -0
- package/dist/templates/cms/files/src/app.ts +23 -0
- package/dist/templates/cms/files/src/modules/media/media.routes.ts +26 -0
- package/dist/templates/cms/files/src/modules/posts/post.routes.ts +33 -0
- package/dist/templates/cms/template.config.json +17 -0
- package/dist/templates/crm/files/README.md +3 -0
- package/dist/templates/crm/files/package.json +16 -0
- package/dist/templates/crm/files/src/app.ts +23 -0
- package/dist/templates/crm/files/src/modules/contacts/contacts.routes.ts +12 -0
- package/dist/templates/crm/files/src/modules/pipelines/pipelines.routes.ts +12 -0
- package/dist/templates/crm/template.config.json +19 -0
- package/dist/templates/finance/files/README.md +3 -0
- package/dist/templates/finance/files/package.json +16 -0
- package/dist/templates/finance/files/src/app.ts +23 -0
- package/dist/templates/finance/files/src/modules/reports/reports.routes.ts +12 -0
- package/dist/templates/finance/files/src/modules/transactions/transactions.routes.ts +12 -0
- package/dist/templates/finance/template.config.json +15 -0
- package/dist/templates/landing/files/README.md +10 -0
- package/dist/templates/landing/files/package.json +17 -0
- package/dist/templates/landing/template.config.json +15 -0
- package/dist/templates/marketplace/files/README.md +3 -0
- package/dist/templates/marketplace/files/package.json +16 -0
- package/dist/templates/marketplace/files/src/app.ts +25 -0
- package/dist/templates/marketplace/files/src/modules/orders/orders.routes.ts +12 -0
- package/dist/templates/marketplace/files/src/modules/products/products.routes.ts +12 -0
- package/dist/templates/marketplace/files/src/modules/vendors/vendors.routes.ts +12 -0
- package/dist/templates/marketplace/template.config.json +25 -0
- package/dist/templates/preact/files/package.json +18 -0
- package/dist/templates/preact/files/src/main.jsx +4 -0
- package/dist/templates/preact/template.config.json +11 -0
- package/dist/templates/saas/files/package.json +24 -0
- package/dist/templates/saas/files/playwright.config.ts +25 -0
- package/dist/templates/saas/files/src/app.ts +32 -0
- package/dist/templates/saas/files/src/core/env.ts +24 -0
- package/dist/templates/saas/files/src/core/errors.ts +39 -0
- package/dist/templates/saas/files/src/modules/users/repositories/user.repository.ts +25 -0
- package/dist/templates/saas/files/src/modules/users/routes/user.routes.ts +33 -0
- package/dist/templates/saas/files/src/modules/users/services/user.service.ts +24 -0
- package/dist/templates/saas/files/src/modules/users/validators/user.validator.ts +17 -0
- package/dist/templates/saas/files/tests/e2e/basic.spec.ts +13 -0
- package/dist/templates/saas/template.config.json +26 -0
- package/dist/templates/templates/ai_wrapper/files/README.md +3 -0
- package/dist/templates/templates/ai_wrapper/files/package.json +16 -0
- package/dist/templates/templates/ai_wrapper/files/src/app.ts +23 -0
- package/dist/templates/templates/ai_wrapper/files/src/modules/prompts/prompts.routes.ts +64 -0
- package/dist/templates/templates/ai_wrapper/files/src/modules/usage/usage.routes.ts +12 -0
- package/dist/templates/templates/ai_wrapper/template.config.json +16 -0
- package/dist/templates/templates/booking/files/README.md +3 -0
- package/dist/templates/templates/booking/files/package.json +16 -0
- package/dist/templates/templates/booking/files/src/app.ts +23 -0
- package/dist/templates/templates/booking/files/src/modules/availability/availability.routes.ts +12 -0
- package/dist/templates/templates/booking/files/src/modules/calendar/calendar.routes.ts +12 -0
- package/dist/templates/templates/booking/template.config.json +17 -0
- package/dist/templates/templates/cms/files/frontend/src/components/editor/Editor.tsx +36 -0
- package/dist/templates/templates/cms/files/package.json +22 -0
- package/dist/templates/templates/cms/files/src/app.ts +23 -0
- package/dist/templates/templates/cms/files/src/modules/media/media.routes.ts +26 -0
- package/dist/templates/templates/cms/files/src/modules/posts/post.routes.ts +33 -0
- package/dist/templates/templates/cms/template.config.json +17 -0
- package/dist/templates/templates/crm/files/README.md +3 -0
- package/dist/templates/templates/crm/files/package.json +16 -0
- package/dist/templates/templates/crm/files/src/app.ts +23 -0
- package/dist/templates/templates/crm/files/src/modules/contacts/contacts.routes.ts +12 -0
- package/dist/templates/templates/crm/files/src/modules/pipelines/pipelines.routes.ts +12 -0
- package/dist/templates/templates/crm/template.config.json +19 -0
- package/dist/templates/templates/finance/files/README.md +3 -0
- package/dist/templates/templates/finance/files/package.json +16 -0
- package/dist/templates/templates/finance/files/src/app.ts +23 -0
- package/dist/templates/templates/finance/files/src/modules/reports/reports.routes.ts +12 -0
- package/dist/templates/templates/finance/files/src/modules/transactions/transactions.routes.ts +12 -0
- package/dist/templates/templates/finance/template.config.json +15 -0
- package/dist/templates/templates/landing/files/README.md +10 -0
- package/dist/templates/templates/landing/files/package.json +17 -0
- package/dist/templates/templates/landing/template.config.json +15 -0
- package/dist/templates/templates/marketplace/files/README.md +3 -0
- package/dist/templates/templates/marketplace/files/package.json +16 -0
- package/dist/templates/templates/marketplace/files/src/app.ts +25 -0
- package/dist/templates/templates/marketplace/files/src/modules/orders/orders.routes.ts +12 -0
- package/dist/templates/templates/marketplace/files/src/modules/products/products.routes.ts +12 -0
- package/dist/templates/templates/marketplace/files/src/modules/vendors/vendors.routes.ts +12 -0
- package/dist/templates/templates/marketplace/template.config.json +25 -0
- package/dist/templates/templates/preact/files/package.json +18 -0
- package/dist/templates/templates/preact/files/src/main.jsx +4 -0
- package/dist/templates/templates/preact/template.config.json +11 -0
- package/dist/templates/templates/saas/files/package.json +24 -0
- package/dist/templates/templates/saas/files/playwright.config.ts +25 -0
- package/dist/templates/templates/saas/files/src/app.ts +32 -0
- package/dist/templates/templates/saas/files/src/core/env.ts +24 -0
- package/dist/templates/templates/saas/files/src/core/errors.ts +39 -0
- package/dist/templates/templates/saas/files/src/modules/users/repositories/user.repository.ts +25 -0
- package/dist/templates/templates/saas/files/src/modules/users/routes/user.routes.ts +33 -0
- package/dist/templates/templates/saas/files/src/modules/users/services/user.service.ts +24 -0
- package/dist/templates/templates/saas/files/src/modules/users/validators/user.validator.ts +17 -0
- package/dist/templates/templates/saas/files/tests/e2e/basic.spec.ts +13 -0
- package/dist/templates/templates/saas/template.config.json +26 -0
- package/package.json +2 -2
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Context } from 'hono';
|
|
2
|
+
import { HTTPException } from 'hono/http-exception';
|
|
3
|
+
|
|
4
|
+
export class AppError extends Error {
|
|
5
|
+
constructor(
|
|
6
|
+
public message: string,
|
|
7
|
+
public statusCode: number = 400,
|
|
8
|
+
public code?: string
|
|
9
|
+
) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = 'AppError';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const errorHandler = (err: Error, c: Context) => {
|
|
16
|
+
if (err instanceof AppError) {
|
|
17
|
+
return c.json({
|
|
18
|
+
success: false,
|
|
19
|
+
error: {
|
|
20
|
+
message: err.message,
|
|
21
|
+
code: err.code,
|
|
22
|
+
}
|
|
23
|
+
}, err.statusCode as any);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (err instanceof HTTPException) {
|
|
27
|
+
return err.getResponse();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
console.error('[Unhandled Error]:', err);
|
|
31
|
+
|
|
32
|
+
return c.json({
|
|
33
|
+
success: false,
|
|
34
|
+
error: {
|
|
35
|
+
message: 'Internal Server Error',
|
|
36
|
+
code: 'INTERNAL_ERROR',
|
|
37
|
+
}
|
|
38
|
+
}, 500);
|
|
39
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { User, CreateUserInput } from '../validators/user.validator';
|
|
2
|
+
|
|
3
|
+
export class UserRepository {
|
|
4
|
+
// In a real app, this would use Drizzle or Prisma
|
|
5
|
+
// For the template, we show the pattern
|
|
6
|
+
|
|
7
|
+
async findById(id: string): Promise<User | null> {
|
|
8
|
+
console.log(`[UserRepository] Finding user by id: ${id}`);
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async findByEmail(email: string): Promise<User | null> {
|
|
13
|
+
console.log(`[UserRepository] Finding user by email: ${email}`);
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async create(data: CreateUserInput): Promise<User> {
|
|
18
|
+
console.log(`[UserRepository] Creating user:`, data);
|
|
19
|
+
return {
|
|
20
|
+
id: crypto.randomUUID(),
|
|
21
|
+
...data,
|
|
22
|
+
createdAt: new Date(),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Hono } from 'hono';
|
|
2
|
+
import { zValidator } from '@hono/zod-validator';
|
|
3
|
+
import { createUserSchema } from '../validators/user.validator';
|
|
4
|
+
import { UserService } from '../services/user.service';
|
|
5
|
+
import { UserRepository } from '../repositories/user.repository';
|
|
6
|
+
|
|
7
|
+
const userRoutes = new Hono();
|
|
8
|
+
|
|
9
|
+
// Dependency Injection (Pattern manual for template)
|
|
10
|
+
const userRepository = new UserRepository();
|
|
11
|
+
const userService = new UserService(userRepository);
|
|
12
|
+
|
|
13
|
+
userRoutes.post('/register', zValidator('json', createUserSchema), async (c) => {
|
|
14
|
+
const data = c.req.valid('json');
|
|
15
|
+
const user = await userService.registerUser(data);
|
|
16
|
+
|
|
17
|
+
return c.json({
|
|
18
|
+
success: true,
|
|
19
|
+
data: user
|
|
20
|
+
}, 201);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
userRoutes.get('/:id', async (c) => {
|
|
24
|
+
const id = c.req.param('id');
|
|
25
|
+
const user = await userService.getUserProfile(id);
|
|
26
|
+
|
|
27
|
+
return c.json({
|
|
28
|
+
success: true,
|
|
29
|
+
data: user
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export { userRoutes };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { UserRepository } from '../repositories/user.repository';
|
|
2
|
+
import { CreateUserInput, User } from '../validators/user.validator';
|
|
3
|
+
import { AppError } from '../../../core/errors';
|
|
4
|
+
|
|
5
|
+
export class UserService {
|
|
6
|
+
constructor(private userRepository: UserRepository) {}
|
|
7
|
+
|
|
8
|
+
async registerUser(data: CreateUserInput): Promise<User> {
|
|
9
|
+
const existing = await this.userRepository.findByEmail(data.email);
|
|
10
|
+
if (existing) {
|
|
11
|
+
throw new AppError('User with this email already exists', 409, 'USER_EXISTS');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return this.userRepository.create(data);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async getUserProfile(id: string): Promise<User> {
|
|
18
|
+
const user = await this.userRepository.findById(id);
|
|
19
|
+
if (!user) {
|
|
20
|
+
throw new AppError('User not found', 404, 'USER_NOT_FOUND');
|
|
21
|
+
}
|
|
22
|
+
return user;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export const userSchema = z.object({
|
|
4
|
+
id: z.string().uuid(),
|
|
5
|
+
email: z.string().email(),
|
|
6
|
+
name: z.string().min(2),
|
|
7
|
+
createdAt: z.date(),
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export type User = z.infer<typeof userSchema>;
|
|
11
|
+
|
|
12
|
+
export const createUserSchema = userSchema.pick({
|
|
13
|
+
email: true,
|
|
14
|
+
name: true,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export type CreateUserInput = z.infer<typeof createUserSchema>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { test, expect } from '@playwright/test';
|
|
2
|
+
|
|
3
|
+
test('has title', async ({ page }) => {
|
|
4
|
+
await page.goto('/');
|
|
5
|
+
await expect(page).toHaveTitle(/DevForge/);
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
test('api is running', async ({ request }) => {
|
|
9
|
+
const response = await request.get('/');
|
|
10
|
+
expect(response.ok()).toBeTruthy();
|
|
11
|
+
const body = await response.json();
|
|
12
|
+
expect(body.status).toBe('running');
|
|
13
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "saas",
|
|
3
|
+
"description": "Multi-tenant SaaS application",
|
|
4
|
+
"stack": {
|
|
5
|
+
"runtime": "bun",
|
|
6
|
+
"backend": "hono",
|
|
7
|
+
"frontend": "solidjs",
|
|
8
|
+
"database": "postgres"
|
|
9
|
+
},
|
|
10
|
+
"supportedPlugins": [
|
|
11
|
+
"admin-panel",
|
|
12
|
+
"openapi",
|
|
13
|
+
"websocket",
|
|
14
|
+
"queue",
|
|
15
|
+
"openapi",
|
|
16
|
+
"websocket",
|
|
17
|
+
"queue",
|
|
18
|
+
"auth",
|
|
19
|
+
"payment",
|
|
20
|
+
"email",
|
|
21
|
+
"analytics",
|
|
22
|
+
"search",
|
|
23
|
+
"file-upload",
|
|
24
|
+
"github-actions"
|
|
25
|
+
]
|
|
26
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ahmadubaidillah/cli",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "The elite modular boilerplate engine for agentic applications.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"devforge-cli": "dist/bin.js"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@ahmadubaidillah/core": "^1.1.
|
|
19
|
+
"@ahmadubaidillah/core": "^1.1.2",
|
|
20
20
|
"@inquirer/prompts": "latest",
|
|
21
21
|
"chalk": "latest",
|
|
22
22
|
"commander": "latest",
|