simpledi-app-generator 0.0.1
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/README.md +96 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +53 -0
- package/dist/cli.js.map +1 -0
- package/dist/create_module.d.ts +2 -0
- package/dist/create_module.d.ts.map +1 -0
- package/dist/create_module.js +439 -0
- package/dist/create_module.js.map +1 -0
- package/dist/generate_skeleton.d.ts +2 -0
- package/dist/generate_skeleton.d.ts.map +1 -0
- package/dist/generate_skeleton.js +249 -0
- package/dist/generate_skeleton.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/templates/.env.development +3 -0
- package/dist/templates/AppModule.ts +7 -0
- package/dist/templates/Config.ts +98 -0
- package/dist/templates/UseCaseModule.ts +5 -0
- package/dist/templates/config/getConfigModule.ts +12 -0
- package/dist/templates/db/DbService.ts +18 -0
- package/dist/templates/db/getDb.ts +11 -0
- package/dist/templates/db/getDbModule.ts +15 -0
- package/dist/templates/db/initDb.ts +11 -0
- package/dist/templates/main.routes.ts +10 -0
- package/dist/templates/main.ts +91 -0
- package/dist/templates/package.json +51 -0
- package/dist/templates/schema.ts +1 -0
- package/dist/templates/src/BaseRepository.ts +136 -0
- package/dist/templates/src/BaseService.ts +78 -0
- package/dist/templates/src/IRepository.ts +11 -0
- package/dist/templates/src/IService.ts +6 -0
- package/dist/templates/src/core/baseSchema.ts +13 -0
- package/dist/templates/src/lib/AuthenticationUtils.ts +49 -0
- package/dist/templates/src/lib/errors/BadRequestException.ts +11 -0
- package/dist/templates/src/lib/errors/ConflictException.ts +9 -0
- package/dist/templates/src/lib/errors/ForbiddenException.ts +11 -0
- package/dist/templates/src/lib/errors/HttpException.ts +22 -0
- package/dist/templates/src/lib/errors/InternalServerException.ts +13 -0
- package/dist/templates/src/lib/errors/NotFoundException.ts +11 -0
- package/dist/templates/src/lib/errors/UnauthorizedException.ts +11 -0
- package/dist/templates/src/lib/functions/getEnvFile.ts +19 -0
- package/dist/templates/src/lib/functions/getHostname.ts +18 -0
- package/dist/templates/src/lib/functions/isNotNullNorUndefined.ts +5 -0
- package/dist/templates/src/lib/functions/tableName.ts +5 -0
- package/dist/templates/src/lib/functions/withBaseSchema.ts +30 -0
- package/dist/templates/src/lib/types/BaseEntityInterface.ts +9 -0
- package/dist/templates/src/lib/types/EnvFileNames.ts +7 -0
- package/dist/templates/src/lib/types/Envs.ts +7 -0
- package/dist/templates/src/lib/types/FailedOperation.ts +9 -0
- package/dist/templates/src/lib/types/OperationResult.ts +5 -0
- package/dist/templates/src/lib/types/SharedStubs.ts +16 -0
- package/dist/templates/src/lib/types/SuccessfullOperation.ts +9 -0
- package/dist/templates/src/lib/types/TableNameToken.ts +1 -0
- package/dist/templates/src/lib/types/TokenPayload.ts +6 -0
- package/dist/templates/src/lib/types/UserInterface.ts +10 -0
- package/dist/templates/src/lib/types/getCorsOrigin.ts +20 -0
- package/dist/templates/src/main.routes.ts +11 -0
- package/dist/templates/src/use-case/IUseCase.ts +3 -0
- package/dist/templates/src/use-case/UseCaseModule.ts +6 -0
- package/dist/templates/src/use-case/health-check/HealthCheck.ts +24 -0
- package/dist/templates/src/use-case/health-check/healthCheckRoutes.ts +23 -0
- package/dist/templates/src/use-case/health-check/outputs/HealthCheckSuccess.ts +14 -0
- package/dist/templates/tsconfig.json +46 -0
- package/package.json +41 -0
- package/src/templates/.env.development +3 -0
- package/src/templates/package.json +51 -0
- package/src/templates/tsconfig.json +46 -0
- package/tsconfig.json +40 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Hono } from 'hono';
|
|
2
|
+
import { inject } from '@kanian77/simple-di';
|
|
3
|
+
import { StatusCodes } from 'http-status-codes';
|
|
4
|
+
import { FailedOperation } from '@root/lib';
|
|
5
|
+
import { HealthCheck, HEALTH_CHECK_USE_CASE_TOKEN } from './HealthCheck';
|
|
6
|
+
|
|
7
|
+
const healthCheckRoutes = new Hono();
|
|
8
|
+
|
|
9
|
+
healthCheckRoutes.get('/', async (c) => {
|
|
10
|
+
try {
|
|
11
|
+
const useCase = inject<HealthCheck>(HEALTH_CHECK_USE_CASE_TOKEN);
|
|
12
|
+
const result = await useCase.execute();
|
|
13
|
+
return c.json(result, StatusCodes.OK);
|
|
14
|
+
} catch (e) {
|
|
15
|
+
return c.json(
|
|
16
|
+
new FailedOperation('Internal Server Error'),
|
|
17
|
+
StatusCodes.INTERNAL_SERVER_ERROR,
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const healthCheckRoutesPath = '/health';
|
|
23
|
+
export { healthCheckRoutes, healthCheckRoutesPath };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SuccessfullOperation } from '@root/lib';
|
|
2
|
+
|
|
3
|
+
export type HealthCheckPayload = {
|
|
4
|
+
status: string;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export class HealthCheckSuccess extends SuccessfullOperation {
|
|
8
|
+
constructor(
|
|
9
|
+
public readonly result: HealthCheckPayload,
|
|
10
|
+
public readonly message: string = 'Service is healthy',
|
|
11
|
+
) {
|
|
12
|
+
super();
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"outDir": "./dist",
|
|
4
|
+
"rootDir": ".",
|
|
5
|
+
"baseUrl": ".",
|
|
6
|
+
"paths": {
|
|
7
|
+
"@root/*": ["./src/*"],
|
|
8
|
+
"config/*": ["./config/*"],
|
|
9
|
+
"db/*": ["./db/*"]
|
|
10
|
+
},
|
|
11
|
+
"composite": true,
|
|
12
|
+
"experimentalDecorators": true,
|
|
13
|
+
"emitDecoratorMetadata": true,
|
|
14
|
+
"lib": ["ESNext"],
|
|
15
|
+
"target": "ESNext",
|
|
16
|
+
"module": "Preserve",
|
|
17
|
+
"moduleDetection": "force",
|
|
18
|
+
"jsx": "react-jsx",
|
|
19
|
+
"allowJs": true,
|
|
20
|
+
|
|
21
|
+
// Bundler mode
|
|
22
|
+
"moduleResolution": "bundler",
|
|
23
|
+
"allowImportingTsExtensions": true,
|
|
24
|
+
"verbatimModuleSyntax": true,
|
|
25
|
+
"noEmit": true,
|
|
26
|
+
|
|
27
|
+
// Best practices
|
|
28
|
+
"strict": true,
|
|
29
|
+
"skipLibCheck": true,
|
|
30
|
+
"noFallthroughCasesInSwitch": true,
|
|
31
|
+
"noUncheckedIndexedAccess": true,
|
|
32
|
+
"noImplicitOverride": true,
|
|
33
|
+
|
|
34
|
+
"esModuleInterop": true,
|
|
35
|
+
"forceConsistentCasingInFileNames": true,
|
|
36
|
+
"isolatedModules": true,
|
|
37
|
+
"resolveJsonModule": true,
|
|
38
|
+
"declaration": true,
|
|
39
|
+
"declarationMap": true,
|
|
40
|
+
"sourceMap": true,
|
|
41
|
+
// Some stricter flags (disabled by default)
|
|
42
|
+
"noUnusedLocals": false,
|
|
43
|
+
"noUnusedParameters": false,
|
|
44
|
+
"noPropertyAccessFromIndexSignature": false
|
|
45
|
+
}
|
|
46
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "simpledi-app-generator",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "generates a @kanian77/simple-di app",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Patrick Assoa Adou",
|
|
7
|
+
"email": "kanian77@gmail.com"
|
|
8
|
+
},
|
|
9
|
+
"module": "src/index.ts",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"main": "./dist/cli.js",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"bin": {
|
|
14
|
+
"simpledi": "./dist/cli.js"
|
|
15
|
+
},
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"import": "./dist/cli.js",
|
|
19
|
+
"require": "./dist/cli.js",
|
|
20
|
+
"types": "./dist/index.d.ts"
|
|
21
|
+
},
|
|
22
|
+
"./dist/*": {
|
|
23
|
+
"import": "./dist/*.js",
|
|
24
|
+
"require": "./dist/*.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"clean": "rm -rf dist tsconfig.tsbuildinfo",
|
|
29
|
+
"build": "tsc --build --verbose",
|
|
30
|
+
"copy-templates": "cp -r src/templates dist/templates",
|
|
31
|
+
"dev": "tsc --build --verbose --watch",
|
|
32
|
+
"prepare": "bun run clean && bun run build && bun run copy-templates",
|
|
33
|
+
"release": "bun run prepare && npm publish --userconfig .npmrc --access public"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/bun": "latest"
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"typescript": "^5"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "testing-stric",
|
|
3
|
+
"module": "main.ts",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"devDependencies": {
|
|
6
|
+
"@hono/node-server": "^1.13.7",
|
|
7
|
+
"@types/bun": "latest",
|
|
8
|
+
"@types/jsdom": "^21.1.7",
|
|
9
|
+
"@types/jsonwebtoken": "^9.0.7",
|
|
10
|
+
"@types/supertest": "^6.0.2",
|
|
11
|
+
"bun-types": "^1.2.5",
|
|
12
|
+
"drizzle-kit": "^0.30.1",
|
|
13
|
+
"husky": "^9.1.7",
|
|
14
|
+
"jsdom": "^26.0.0",
|
|
15
|
+
"slugify": "^1.6.6",
|
|
16
|
+
"supertest": "^7.0.0"
|
|
17
|
+
},
|
|
18
|
+
"peerDependencies": {
|
|
19
|
+
"typescript": "^5.0.0"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@kanian77/simple-di": "^0.1.1",
|
|
23
|
+
"@neondatabase/serverless": "^0.10.4",
|
|
24
|
+
"concurrently": "^9.1.0",
|
|
25
|
+
"dotenv": "^16.4.7",
|
|
26
|
+
"drizzle-orm": "^0.38.2",
|
|
27
|
+
"drizzle-zod": "^0.6.0",
|
|
28
|
+
"hono": "^4.8.0",
|
|
29
|
+
"http-status-codes": "^2.3.0",
|
|
30
|
+
"jsonwebtoken": "^9.0.2",
|
|
31
|
+
"reflect-metadata": "^0.2.2",
|
|
32
|
+
"uuid": "^11.1.0",
|
|
33
|
+
"zod": "3.24.2"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"dev": "BUN_ENV=dev bun run --hot --watch ./main.ts ",
|
|
37
|
+
"debug": "concurrently 'BUN_ENV=debug bun run --hot --watch --inspect ./main.ts'",
|
|
38
|
+
"create-module": "bun run scripts/create_module.ts",
|
|
39
|
+
"migrate:dev": "BUN_ENV=dev bunx drizzle-kit --config=drizzle.dev.config.ts migrate",
|
|
40
|
+
"generate:dev": "BUN_ENV=dev bunx drizzle-kit --config=drizzle.dev.config.ts generate",
|
|
41
|
+
"migrate:prod": "BUN_ENV=prod bunx drizzle-kit --config=drizzle.prod.config.ts migrate",
|
|
42
|
+
"generate:prod": "BUN_ENV=prod bunx drizzle-kit --config=drizzle.prod.config.ts generate",
|
|
43
|
+
"studio:dev": "BUN_ENV=dev bunx drizzle-kit --config=drizzle.dev.config.ts studio",
|
|
44
|
+
"seed-dev": "BUN_ENV=dev bun run ./db/seeds/plan-seeds.ts",
|
|
45
|
+
"build:staging": "BUN_ENV=staging bun build ./main.ts --target=bun --outdir ./dist",
|
|
46
|
+
"build:prod": "BUN_ENV=prod bun build ./main.ts --target=bun --outdir ./dist",
|
|
47
|
+
"start": "bun run ./dist/main.js",
|
|
48
|
+
"test": "BUN_ENV=test bun test",
|
|
49
|
+
"clean": "rm -rf dist && rm -rf node_modules"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"outDir": "./dist",
|
|
4
|
+
"rootDir": ".",
|
|
5
|
+
"baseUrl": ".",
|
|
6
|
+
"paths": {
|
|
7
|
+
"@root/*": ["./src/*"],
|
|
8
|
+
"config/*": ["./config/*"],
|
|
9
|
+
"db/*": ["./db/*"]
|
|
10
|
+
},
|
|
11
|
+
"composite": true,
|
|
12
|
+
"experimentalDecorators": true,
|
|
13
|
+
"emitDecoratorMetadata": true,
|
|
14
|
+
"lib": ["ESNext"],
|
|
15
|
+
"target": "ESNext",
|
|
16
|
+
"module": "Preserve",
|
|
17
|
+
"moduleDetection": "force",
|
|
18
|
+
"jsx": "react-jsx",
|
|
19
|
+
"allowJs": true,
|
|
20
|
+
|
|
21
|
+
// Bundler mode
|
|
22
|
+
"moduleResolution": "bundler",
|
|
23
|
+
"allowImportingTsExtensions": true,
|
|
24
|
+
"verbatimModuleSyntax": true,
|
|
25
|
+
"noEmit": true,
|
|
26
|
+
|
|
27
|
+
// Best practices
|
|
28
|
+
"strict": true,
|
|
29
|
+
"skipLibCheck": true,
|
|
30
|
+
"noFallthroughCasesInSwitch": true,
|
|
31
|
+
"noUncheckedIndexedAccess": true,
|
|
32
|
+
"noImplicitOverride": true,
|
|
33
|
+
|
|
34
|
+
"esModuleInterop": true,
|
|
35
|
+
"forceConsistentCasingInFileNames": true,
|
|
36
|
+
"isolatedModules": true,
|
|
37
|
+
"resolveJsonModule": true,
|
|
38
|
+
"declaration": true,
|
|
39
|
+
"declarationMap": true,
|
|
40
|
+
"sourceMap": true,
|
|
41
|
+
// Some stricter flags (disabled by default)
|
|
42
|
+
"noUnusedLocals": false,
|
|
43
|
+
"noUnusedParameters": false,
|
|
44
|
+
"noPropertyAccessFromIndexSignature": false
|
|
45
|
+
}
|
|
46
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"outDir": "./dist",
|
|
4
|
+
"rootDir": "./src",
|
|
5
|
+
"composite": true,
|
|
6
|
+
"experimentalDecorators": true,
|
|
7
|
+
"emitDecoratorMetadata": true,
|
|
8
|
+
"lib": ["ESNext"],
|
|
9
|
+
"target": "ESNext",
|
|
10
|
+
"module": "Preserve",
|
|
11
|
+
"moduleDetection": "force",
|
|
12
|
+
"jsx": "react-jsx",
|
|
13
|
+
"allowJs": true,
|
|
14
|
+
|
|
15
|
+
// Bundler mode
|
|
16
|
+
"moduleResolution": "bundler",
|
|
17
|
+
"verbatimModuleSyntax": true,
|
|
18
|
+
"noEmit": false,
|
|
19
|
+
|
|
20
|
+
// Best practices
|
|
21
|
+
"strict": true,
|
|
22
|
+
"skipLibCheck": true,
|
|
23
|
+
"noFallthroughCasesInSwitch": true,
|
|
24
|
+
"noUncheckedIndexedAccess": true,
|
|
25
|
+
"noImplicitOverride": true,
|
|
26
|
+
|
|
27
|
+
"esModuleInterop": true,
|
|
28
|
+
"forceConsistentCasingInFileNames": true,
|
|
29
|
+
"isolatedModules": true,
|
|
30
|
+
"resolveJsonModule": true,
|
|
31
|
+
"declaration": true,
|
|
32
|
+
"declarationMap": true,
|
|
33
|
+
"sourceMap": true,
|
|
34
|
+
// Some stricter flags (disabled by default)
|
|
35
|
+
"noUnusedLocals": false,
|
|
36
|
+
"noUnusedParameters": false,
|
|
37
|
+
"noPropertyAccessFromIndexSignature": false
|
|
38
|
+
},
|
|
39
|
+
"exclude": ["src/templates/**/*", "dist"]
|
|
40
|
+
}
|