@appxdigital/appx-core-cli 1.0.10 → 1.0.12
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/package.json +4 -3
- package/scaffold/.env.template +33 -0
- package/scaffold/.eslintrc.js +26 -0
- package/scaffold/.gitattributes +2 -0
- package/scaffold/.prettierrc +9 -0
- package/scaffold/prisma/schema.prisma.template +47 -0
- package/scaffold/src/app.controller.ts +13 -0
- package/{templates/app.module.template.js → scaffold/src/app.module.ts} +6 -2
- package/scaffold/src/app.service.ts +8 -0
- package/{templates/adminjs/dashboard.template.js → scaffold/src/backoffice/components/dashboard.js} +10 -10
- package/{templates/admin.config.template.js → scaffold/src/config/admin.config.ts} +26 -26
- package/{templates/bootstrap.template.js → scaffold/src/main.ts} +3 -3
- package/wizard.js +406 -430
- package/README.md +0 -159
- package/utils/dependency-versions.json +0 -28
- /package/{templates/permissions.config.template.js → scaffold/src/config/permissions.config.ts} +0 -0
- /package/{templates/prisma.module.template.js → scaffold/src/prisma/prisma.module.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@appxdigital/appx-core-cli",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.12",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"npm:publish": "npm publish --access public",
|
|
@@ -15,12 +15,13 @@
|
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@inquirer/prompts": "^7.0.0",
|
|
18
|
-
"@nestjs/cli": "^11.0.6",
|
|
19
18
|
"cli-progress": "^3.12.0",
|
|
20
19
|
"commander": "^12.1.0",
|
|
21
20
|
"fs-extra": "^11.2.0",
|
|
22
21
|
"handlebars": "^4.7.8",
|
|
23
|
-
"inquirer": "^12.0.0"
|
|
22
|
+
"inquirer": "^12.0.0",
|
|
23
|
+
"mysql2": "^3.16.1",
|
|
24
|
+
"pg": "^8.17.1"
|
|
24
25
|
},
|
|
25
26
|
"description": ""
|
|
26
27
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
##DataBase Configurations##
|
|
2
|
+
DB_HOST={{DB_HOST}}
|
|
3
|
+
DB_PORT={{DB_PORT}}
|
|
4
|
+
DB_USER={{DB_USER}}
|
|
5
|
+
DB_PASSWORD={{DB_PASSWORD}}
|
|
6
|
+
DB_NAME={{DB_NAME}}
|
|
7
|
+
DB_PROVIDER={{DB_PROVIDER}}
|
|
8
|
+
DB_URL="${DB_PROVIDER}://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME}"
|
|
9
|
+
|
|
10
|
+
##Project configurations##
|
|
11
|
+
|
|
12
|
+
#Port
|
|
13
|
+
APP_PORT=3000
|
|
14
|
+
|
|
15
|
+
#Default behaviour for use of transactions
|
|
16
|
+
USE_TRANSACTION=true
|
|
17
|
+
|
|
18
|
+
#Session secret
|
|
19
|
+
SESSION_SECRET="{{SESSION_SECRET}}"
|
|
20
|
+
|
|
21
|
+
#Cookie name for the session token
|
|
22
|
+
SESSION_COOKIE_NAME="{{SESSION_COOKIE_NAME}}"
|
|
23
|
+
|
|
24
|
+
#Expiration time for the session token in seconds
|
|
25
|
+
SESSION_TTL=86400
|
|
26
|
+
|
|
27
|
+
# JWT expiration times
|
|
28
|
+
JWT_EXPIRES_IN=10d
|
|
29
|
+
JWT_REFRESH_EXPIRES_IN=1y
|
|
30
|
+
|
|
31
|
+
# JWT
|
|
32
|
+
JWT_SECRET="{{JWT_SECRET}}"
|
|
33
|
+
JWT_REFRESH_SECRET="{{JWT_REFRESH_SECRET}}"
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
parser: '@typescript-eslint/parser',
|
|
3
|
+
parserOptions: {
|
|
4
|
+
project: 'tsconfig.json',
|
|
5
|
+
tsconfigRootDir: __dirname,
|
|
6
|
+
sourceType: 'module',
|
|
7
|
+
},
|
|
8
|
+
plugins: ['@typescript-eslint/eslint-plugin'],
|
|
9
|
+
extends: [
|
|
10
|
+
'plugin:@typescript-eslint/recommended',
|
|
11
|
+
'plugin:prettier/recommended',
|
|
12
|
+
],
|
|
13
|
+
root: true,
|
|
14
|
+
env: {
|
|
15
|
+
node: true,
|
|
16
|
+
jest: true,
|
|
17
|
+
},
|
|
18
|
+
ignorePatterns: ['.eslintrc.js'],
|
|
19
|
+
rules: {
|
|
20
|
+
'@typescript-eslint/interface-name-prefix': 'off',
|
|
21
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
22
|
+
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
23
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
24
|
+
'prettier/prettier': ['error', {endOfLine: 'lf'}],
|
|
25
|
+
},
|
|
26
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
datasource db {
|
|
2
|
+
provider = "{{DB_PROVIDER}}"
|
|
3
|
+
url = env("DB_URL")
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
generator client {
|
|
7
|
+
provider = "prisma-client-js"
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
generator nestgraphql {
|
|
11
|
+
provider = "node node_modules/prisma-nestjs-graphql"
|
|
12
|
+
output = "../src/generated/"
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
model User {
|
|
16
|
+
id Int @id @default(autoincrement())
|
|
17
|
+
email String @unique
|
|
18
|
+
name String?
|
|
19
|
+
password String? /// @Role(none)
|
|
20
|
+
role Role @default(GUEST)
|
|
21
|
+
refreshTokens UserRefreshToken[]
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
model Session {
|
|
25
|
+
id String @id
|
|
26
|
+
sid String @unique
|
|
27
|
+
data String @db.Text
|
|
28
|
+
expiresAt DateTime
|
|
29
|
+
userId Int?
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
model UserRefreshToken {
|
|
33
|
+
id String @id @default(cuid())
|
|
34
|
+
token String @unique @db.VarChar(255)
|
|
35
|
+
userId Int
|
|
36
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
37
|
+
expiresAt DateTime
|
|
38
|
+
createdAt DateTime @default(now())
|
|
39
|
+
revokedAt DateTime?
|
|
40
|
+
|
|
41
|
+
@@index([userId])
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
enum Role {
|
|
45
|
+
ADMIN
|
|
46
|
+
GUEST
|
|
47
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {Controller, Get} from '@nestjs/common';
|
|
2
|
+
import {AppService} from './app.service';
|
|
3
|
+
|
|
4
|
+
@Controller()
|
|
5
|
+
export class AppController {
|
|
6
|
+
constructor(private readonly appService: AppService) {
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
@Get()
|
|
10
|
+
getHello(): string {
|
|
11
|
+
return this.appService.getHello();
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -2,8 +2,8 @@ import {MiddlewareConsumer, Module, NestModule, RequestMethod} from '@nestjs/com
|
|
|
2
2
|
import {AppController} from './app.controller';
|
|
3
3
|
import {AppService} from './app.service';
|
|
4
4
|
import {ConfigModule} from '@nestjs/config';
|
|
5
|
-
import {AuthModule, PrismaInterceptor, AppxCoreModule, AppxCoreAdminModule} from '@appxdigital/appx-core';
|
|
6
|
-
import {APP_INTERCEPTOR} from '@nestjs/core';
|
|
5
|
+
import {AuthModule, PrismaInterceptor, AppxCoreModule, AppxCoreAdminModule, UserPopulationGuard} from '@appxdigital/appx-core';
|
|
6
|
+
import {APP_INTERCEPTOR, APP_GUARD} from '@nestjs/core';
|
|
7
7
|
import {RequestContextModule, RequestContextMiddleware} from 'nestjs-request-context'
|
|
8
8
|
import {PermissionsConfig} from './config/permissions.config';
|
|
9
9
|
import {AdminConfig} from './config/admin.config';
|
|
@@ -28,6 +28,10 @@ import {AdminConfig} from './config/admin.config';
|
|
|
28
28
|
provide: APP_INTERCEPTOR,
|
|
29
29
|
useClass: PrismaInterceptor,
|
|
30
30
|
},
|
|
31
|
+
{
|
|
32
|
+
provide: APP_GUARD,
|
|
33
|
+
useClass: UserPopulationGuard,
|
|
34
|
+
},
|
|
31
35
|
],
|
|
32
36
|
})
|
|
33
37
|
export class AppModule implements NestModule {
|
package/{templates/adminjs/dashboard.template.js → scaffold/src/backoffice/components/dashboard.js}
RENAMED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
export const Dashboard = () => {
|
|
4
|
-
// Redirect to Users resource
|
|
5
|
-
window.location.href = window.location.href + '/resources/User';
|
|
6
|
-
|
|
7
|
-
return null;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export default Dashboard;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
export const Dashboard = () => {
|
|
4
|
+
// Redirect to Users resource
|
|
5
|
+
window.location.href = window.location.href + '/resources/User';
|
|
6
|
+
|
|
7
|
+
return null;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export default Dashboard;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import {AdminConfigType} from '@appxdigital/appx-core';
|
|
2
|
-
import {ComponentLoader} from 'adminjs';
|
|
3
|
-
|
|
4
|
-
const componentLoader = new ComponentLoader();
|
|
5
|
-
|
|
6
|
-
export const AdminConfig: AdminConfigType = {
|
|
7
|
-
componentLoader,
|
|
8
|
-
adminRoles: ['ADMIN'],
|
|
9
|
-
resources: [
|
|
10
|
-
{
|
|
11
|
-
name: 'User',
|
|
12
|
-
},
|
|
13
|
-
],
|
|
14
|
-
rootPath: '/admin',
|
|
15
|
-
branding: {
|
|
16
|
-
companyName: 'AppX Core',
|
|
17
|
-
logo: 'https://appx-website-assets.fra1.cdn.digitaloceanspaces.com/2024/04/logo_color.svg',
|
|
18
|
-
},
|
|
19
|
-
// As you can see below, you can customize the dashboard component, which is the first page you see when you access the AdminJS
|
|
20
|
-
dashboard: {
|
|
21
|
-
component: componentLoader.add(
|
|
22
|
-
'Dashboard',
|
|
23
|
-
'../backoffice/components/dashboard',
|
|
24
|
-
),
|
|
25
|
-
},
|
|
26
|
-
};
|
|
1
|
+
import {AdminConfigType} from '@appxdigital/appx-core';
|
|
2
|
+
import {ComponentLoader} from 'adminjs';
|
|
3
|
+
|
|
4
|
+
const componentLoader = new ComponentLoader();
|
|
5
|
+
|
|
6
|
+
export const AdminConfig: AdminConfigType = {
|
|
7
|
+
componentLoader,
|
|
8
|
+
adminRoles: ['ADMIN'],
|
|
9
|
+
resources: [
|
|
10
|
+
{
|
|
11
|
+
name: 'User',
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
rootPath: '/admin',
|
|
15
|
+
branding: {
|
|
16
|
+
companyName: 'AppX Core',
|
|
17
|
+
logo: 'https://appx-website-assets.fra1.cdn.digitaloceanspaces.com/2024/04/logo_color.svg',
|
|
18
|
+
},
|
|
19
|
+
// As you can see below, you can customize the dashboard component, which is the first page you see when you access the AdminJS
|
|
20
|
+
dashboard: {
|
|
21
|
+
component: componentLoader.add(
|
|
22
|
+
'Dashboard',
|
|
23
|
+
'../backoffice/components/dashboard',
|
|
24
|
+
),
|
|
25
|
+
},
|
|
26
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { NestFactory } from '@nestjs/core';
|
|
2
2
|
import { AppModule } from './app.module';
|
|
3
3
|
import { ConfigService } from '@nestjs/config';
|
|
4
|
-
import
|
|
5
|
-
import
|
|
4
|
+
import session from 'express-session';
|
|
5
|
+
import passport from 'passport';
|
|
6
6
|
import {PrismaService} from '@appxdigital/appx-core';
|
|
7
7
|
import { ValidationPipe } from '@nestjs/common';
|
|
8
8
|
import {CorePrismaSessionStore} from '@appxdigital/appx-core';
|
|
9
|
-
import
|
|
9
|
+
import morgan from 'morgan';
|
|
10
10
|
|
|
11
11
|
async function bootstrap() {
|
|
12
12
|
const app = await NestFactory.create(AppModule);
|