nestforge-generator 0.6.0 → 0.6.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/README.md +1 -1
- package/README.pt-BR.md +1 -1
- package/dist/generator.js +3 -2
- package/dist/generator.js.map +1 -1
- package/dist/update-notifier.js +37 -13
- package/dist/update-notifier.js.map +1 -1
- package/package.json +1 -1
- package/templates/drizzle/eslint.config.mjs +47 -0
- package/templates/drizzle/src/app.module.ts +12 -5
- package/templates/drizzle/src/auth/auth.controller.ts +4 -1
- package/templates/drizzle/src/auth/auth.service.ts +15 -5
- package/templates/drizzle/src/database/schema/postgres.schema.ts +3 -1
- package/templates/drizzle/src/main.ts +3 -1
- package/templates/prisma/eslint.config.mjs +47 -0
- package/templates/prisma/src/app.module.ts +12 -5
- package/templates/prisma/src/auth/auth.controller.ts +4 -1
- package/templates/prisma/src/auth/auth.service.ts +7 -2
- package/templates/typeorm/eslint.config.mjs +47 -0
- package/templates/typeorm/src/app.module.ts +12 -5
- package/templates/typeorm/src/auth/auth.controller.ts +4 -1
- package/templates/typeorm/src/auth/auth.service.ts +13 -5
package/README.md
CHANGED
|
@@ -48,7 +48,7 @@ Invalid values, contradictory toggles, and unsupported combinations terminate wi
|
|
|
48
48
|
|
|
49
49
|
When the CLI starts, it checks the npm registry for a newer stable version. If an update is available, you can:
|
|
50
50
|
|
|
51
|
-
-
|
|
51
|
+
- install the detected version in the current project and restart the CLI from that local installation;
|
|
52
52
|
- continue with the currently installed version;
|
|
53
53
|
- hide the reminder until the next local day.
|
|
54
54
|
|
package/README.pt-BR.md
CHANGED
|
@@ -48,7 +48,7 @@ Valores inválidos, toggles contraditórios e combinações não suportadas ence
|
|
|
48
48
|
|
|
49
49
|
Quando a CLI inicia, ela consulta o registro do npm em busca de uma versão estável mais recente. Se houver uma atualização, você pode:
|
|
50
50
|
|
|
51
|
-
*
|
|
51
|
+
* instalar a versão detectada no projeto atual e reiniciar a CLI usando a instalação local;
|
|
52
52
|
* continuar com a versão instalada atualmente;
|
|
53
53
|
* ocultar o lembrete até o próximo dia no horário local.
|
|
54
54
|
|
package/dist/generator.js
CHANGED
|
@@ -66,7 +66,7 @@ export async function generateProject(options) {
|
|
|
66
66
|
throw new Error(`The "${projectName}" directory already exists. Choose another name or remove the directory.`);
|
|
67
67
|
}
|
|
68
68
|
await fs.copy(templateDir, targetDir);
|
|
69
|
-
const enabledFeatures = buildEnabledFeatures(features, accessControl, database, authStrategy);
|
|
69
|
+
const enabledFeatures = buildEnabledFeatures(features, accessControl, database, authStrategy, language);
|
|
70
70
|
await applyDockerToggle(targetDir, enabledFeatures);
|
|
71
71
|
if (orm !== 'none') {
|
|
72
72
|
await applyDatabaseConfig(targetDir, database);
|
|
@@ -84,8 +84,9 @@ export async function generateProject(options) {
|
|
|
84
84
|
}
|
|
85
85
|
return targetDir;
|
|
86
86
|
}
|
|
87
|
-
function buildEnabledFeatures(features, accessControl, database, authStrategy) {
|
|
87
|
+
function buildEnabledFeatures(features, accessControl, database, authStrategy, language) {
|
|
88
88
|
const enabled = new Set(features);
|
|
89
|
+
enabled.add(`language:${language}`);
|
|
89
90
|
if (accessControl) {
|
|
90
91
|
enabled.add('rbac');
|
|
91
92
|
}
|
package/dist/generator.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,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AK,WAAW,EAAE,CACrB,CAAC;QAEF,MAAM,EAAE,CAAC,SAAS,CACd,UAAU,EACV,OAAO,EACP,OAAO,CACV,CAAC;IACN,CAAC;AACL,CAAC;AAED,KAAK,UAAU,eAAe,CAAC,SAAiB;IAC5C,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;IACzD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAE7C,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC;QACtC,OAAO;IACX,CAAC;IAED,MAAM,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;AACxC,CAAC"}
|
package/dist/update-notifier.js
CHANGED
|
@@ -3,7 +3,8 @@ import { isCancel, log, note, select } from '@clack/prompts';
|
|
|
3
3
|
import pc from 'picocolors';
|
|
4
4
|
import { readPackageInfo } from './package-info.js';
|
|
5
5
|
import { checkForUpdate, dismissUpdatesForToday, } from './update-check.js';
|
|
6
|
-
export function
|
|
6
|
+
export function getUpdateInstallProcess(latestVersion, platform = process.platform) {
|
|
7
|
+
const packageSpec = `nestforge-generator@${latestVersion}`;
|
|
7
8
|
if (platform === 'win32') {
|
|
8
9
|
return {
|
|
9
10
|
command: process.env.ComSpec ?? 'cmd.exe',
|
|
@@ -11,25 +12,38 @@ export function getUpdateProcess(platform = process.platform) {
|
|
|
11
12
|
'/d',
|
|
12
13
|
'/s',
|
|
13
14
|
'/c',
|
|
14
|
-
|
|
15
|
+
`npm install ${packageSpec}`,
|
|
16
|
+
],
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
command: 'npm',
|
|
21
|
+
args: ['install', packageSpec],
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export function getUpdateRestartProcess(platform = process.platform) {
|
|
25
|
+
if (platform === 'win32') {
|
|
26
|
+
return {
|
|
27
|
+
command: process.env.ComSpec ?? 'cmd.exe',
|
|
28
|
+
args: [
|
|
29
|
+
'/d',
|
|
30
|
+
'/s',
|
|
31
|
+
'/c',
|
|
32
|
+
'npx --no-install nestforge',
|
|
15
33
|
],
|
|
16
34
|
};
|
|
17
35
|
}
|
|
18
36
|
return {
|
|
19
37
|
command: 'npx',
|
|
20
|
-
args: ['--
|
|
38
|
+
args: ['--no-install', 'nestforge'],
|
|
21
39
|
};
|
|
22
40
|
}
|
|
23
|
-
|
|
41
|
+
function runChildProcess(childProcess, env = process.env) {
|
|
24
42
|
return new Promise((resolve) => {
|
|
25
|
-
const
|
|
26
|
-
const child = spawn(updateProcess.command, updateProcess.args, {
|
|
43
|
+
const child = spawn(childProcess.command, childProcess.args, {
|
|
27
44
|
stdio: 'inherit',
|
|
28
45
|
shell: false,
|
|
29
|
-
env
|
|
30
|
-
...process.env,
|
|
31
|
-
NESTFORGE_RESTART_ARGS: JSON.stringify(process.argv.slice(2)),
|
|
32
|
-
},
|
|
46
|
+
env,
|
|
33
47
|
});
|
|
34
48
|
let settled = false;
|
|
35
49
|
const finish = (success) => {
|
|
@@ -43,6 +57,16 @@ export async function runLatestVersion() {
|
|
|
43
57
|
child.once('exit', (code) => finish(code === 0));
|
|
44
58
|
});
|
|
45
59
|
}
|
|
60
|
+
export async function runLatestVersion(update) {
|
|
61
|
+
const installed = await runChildProcess(getUpdateInstallProcess(update.latestVersion));
|
|
62
|
+
if (!installed) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
return runChildProcess(getUpdateRestartProcess(), {
|
|
66
|
+
...process.env,
|
|
67
|
+
NESTFORGE_RESTART_ARGS: JSON.stringify(process.argv.slice(2)),
|
|
68
|
+
});
|
|
69
|
+
}
|
|
46
70
|
async function promptForUpdate(update) {
|
|
47
71
|
note(`${pc.dim(update.currentVersion)} ${pc.dim('→')} ${pc.green(update.latestVersion)}`, 'NestForge update available');
|
|
48
72
|
const choice = await select({
|
|
@@ -80,12 +104,12 @@ export async function handleUpdateNotification(options = {}) {
|
|
|
80
104
|
if (choice === 'continue') {
|
|
81
105
|
return 'continue';
|
|
82
106
|
}
|
|
83
|
-
log.info(
|
|
84
|
-
const updated = await (options.runLatest ?? runLatestVersion)();
|
|
107
|
+
log.info(`Installing NestForge ${update.latestVersion} in the current project...`);
|
|
108
|
+
const updated = await (options.runLatest ?? runLatestVersion)(update);
|
|
85
109
|
if (updated) {
|
|
86
110
|
return 'restarted';
|
|
87
111
|
}
|
|
88
|
-
log.warn('The update could not be
|
|
112
|
+
log.warn('The update could not be installed or restarted. Continuing with the current version.');
|
|
89
113
|
return 'continue';
|
|
90
114
|
}
|
|
91
115
|
catch {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-notifier.js","sourceRoot":"","sources":["../src/update-notifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EACH,cAAc,EACd,sBAAsB,GAEzB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"update-notifier.js","sourceRoot":"","sources":["../src/update-notifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EACH,cAAc,EACd,sBAAsB,GAEzB,MAAM,mBAAmB,CAAC;AAkB3B,MAAM,U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CAAC;IACtB,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import prettier from 'eslint-config-prettier';
|
|
2
|
+
// nestforge:feature:language:typescript
|
|
3
|
+
import tseslint from '@typescript-eslint/eslint-plugin';
|
|
4
|
+
import tsParser from '@typescript-eslint/parser';
|
|
5
|
+
// nestforge:feature:language:typescript:end
|
|
6
|
+
|
|
7
|
+
export default [
|
|
8
|
+
{
|
|
9
|
+
ignores: ['dist/', 'coverage/', 'node_modules/'],
|
|
10
|
+
},
|
|
11
|
+
// nestforge:feature:language:typescript
|
|
12
|
+
{
|
|
13
|
+
files: ['src/**/*.ts', 'test/**/*.ts'],
|
|
14
|
+
languageOptions: {
|
|
15
|
+
parser: tsParser,
|
|
16
|
+
parserOptions: {
|
|
17
|
+
ecmaVersion: 'latest',
|
|
18
|
+
sourceType: 'commonjs',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
plugins: {
|
|
22
|
+
'@typescript-eslint': tseslint,
|
|
23
|
+
},
|
|
24
|
+
rules: {
|
|
25
|
+
...tseslint.configs.recommended.rules,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
files: ['src/**/*.spec.ts', 'test/**/*.ts'],
|
|
30
|
+
rules: {
|
|
31
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
// nestforge:feature:language:typescript:end
|
|
35
|
+
// nestforge:feature:language:javascript
|
|
36
|
+
{
|
|
37
|
+
files: ['src/**/*.js', 'test/**/*.js'],
|
|
38
|
+
languageOptions: {
|
|
39
|
+
parserOptions: {
|
|
40
|
+
ecmaVersion: 'latest',
|
|
41
|
+
sourceType: 'commonjs',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
// nestforge:feature:language:javascript:end
|
|
46
|
+
prettier,
|
|
47
|
+
];
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Module } from '@nestjs/common';
|
|
2
|
+
// nestforge:feature:auth:session
|
|
3
|
+
import { MiddlewareConsumer, NestModule } from '@nestjs/common';
|
|
4
|
+
// nestforge:feature:auth:session:end
|
|
2
5
|
import { ConfigModule } from '@nestjs/config';
|
|
3
6
|
import { ThrottlerModule } from '@nestjs/throttler';
|
|
4
7
|
// nestforge:feature:redis
|
|
@@ -61,12 +64,16 @@ import { validateEnv } from './config/env.validation';
|
|
|
61
64
|
MetricsModule,
|
|
62
65
|
],
|
|
63
66
|
})
|
|
64
|
-
export class AppModule
|
|
67
|
+
export class AppModule
|
|
68
|
+
// nestforge:feature:auth:session
|
|
69
|
+
implements NestModule
|
|
70
|
+
// nestforge:feature:auth:session:end
|
|
71
|
+
{
|
|
72
|
+
// nestforge:feature:auth:session
|
|
65
73
|
configure(consumer: MiddlewareConsumer) {
|
|
66
|
-
// nestforge:feature:auth:session
|
|
67
74
|
if (process.env.ENABLE_CSRF === 'true') {
|
|
68
75
|
consumer.apply(CsrfMiddleware).forRoutes('*');
|
|
69
76
|
}
|
|
70
|
-
// nestforge:feature:auth:session:end
|
|
71
77
|
}
|
|
72
|
-
|
|
78
|
+
// nestforge:feature:auth:session:end
|
|
79
|
+
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import { Body, Controller, Get, HttpCode, HttpStatus, Post,
|
|
1
|
+
import { Body, Controller, Get, HttpCode, HttpStatus, Post, Req, UseGuards } from '@nestjs/common';
|
|
2
|
+
// nestforge:feature:redis,auth:password
|
|
3
|
+
import { Query } from '@nestjs/common';
|
|
4
|
+
// nestforge:feature:redis,auth:password:end
|
|
2
5
|
// nestforge:feature:swagger
|
|
3
6
|
import { ApiExcludeEndpoint, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
|
|
4
7
|
// nestforge:feature:swagger:end
|
|
@@ -1,19 +1,27 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
// nestforge:feature:auth:password
|
|
1
3
|
import {
|
|
2
4
|
ConflictException,
|
|
3
|
-
Injectable,
|
|
4
5
|
UnauthorizedException,
|
|
5
6
|
} from '@nestjs/common';
|
|
7
|
+
// nestforge:feature:auth:password:end
|
|
6
8
|
import {
|
|
7
9
|
and,
|
|
8
10
|
eq,
|
|
9
|
-
isNull,
|
|
10
11
|
} from 'drizzle-orm';
|
|
12
|
+
// nestforge:feature:redis,auth:password
|
|
13
|
+
import { isNull } from 'drizzle-orm';
|
|
14
|
+
// nestforge:feature:redis,auth:password:end
|
|
15
|
+
// nestforge:feature:auth:password
|
|
11
16
|
import * as bcrypt from 'bcryptjs';
|
|
17
|
+
// nestforge:feature:auth:password:end
|
|
18
|
+
import { randomUUID } from 'node:crypto';
|
|
19
|
+
// nestforge:feature:redis,auth:password
|
|
12
20
|
import {
|
|
13
21
|
createHash,
|
|
14
22
|
randomBytes,
|
|
15
|
-
randomUUID,
|
|
16
23
|
} from 'node:crypto';
|
|
24
|
+
// nestforge:feature:redis,auth:password:end
|
|
17
25
|
import { Role } from '../common/constants/role.enum';
|
|
18
26
|
import { InjectDatabase } from '../database/database.decorators';
|
|
19
27
|
import type { DrizzleDatabase } from '../database/database.types';
|
|
@@ -22,9 +30,9 @@ import {
|
|
|
22
30
|
users,
|
|
23
31
|
} from '../database/schema';
|
|
24
32
|
|
|
25
|
-
// nestforge:feature:auth:token
|
|
33
|
+
// nestforge:feature:redis,auth:password,auth:token
|
|
26
34
|
import { refreshTokens } from '../database/schema';
|
|
27
|
-
// nestforge:feature:auth:token:end
|
|
35
|
+
// nestforge:feature:redis,auth:password,auth:token:end
|
|
28
36
|
|
|
29
37
|
// nestforge:feature:redis,auth:password
|
|
30
38
|
import { MailService } from '../mail/mail.service';
|
|
@@ -623,9 +631,11 @@ export class AuthService {
|
|
|
623
631
|
};
|
|
624
632
|
}
|
|
625
633
|
|
|
634
|
+
// nestforge:feature:redis,auth:password
|
|
626
635
|
private hashToken(token: string): string {
|
|
627
636
|
return createHash('sha256')
|
|
628
637
|
.update(token)
|
|
629
638
|
.digest('hex');
|
|
630
639
|
}
|
|
640
|
+
// nestforge:feature:redis,auth:password:end
|
|
631
641
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import prettier from 'eslint-config-prettier';
|
|
2
|
+
// nestforge:feature:language:typescript
|
|
3
|
+
import tseslint from '@typescript-eslint/eslint-plugin';
|
|
4
|
+
import tsParser from '@typescript-eslint/parser';
|
|
5
|
+
// nestforge:feature:language:typescript:end
|
|
6
|
+
|
|
7
|
+
export default [
|
|
8
|
+
{
|
|
9
|
+
ignores: ['dist/', 'coverage/', 'node_modules/'],
|
|
10
|
+
},
|
|
11
|
+
// nestforge:feature:language:typescript
|
|
12
|
+
{
|
|
13
|
+
files: ['src/**/*.ts', 'test/**/*.ts'],
|
|
14
|
+
languageOptions: {
|
|
15
|
+
parser: tsParser,
|
|
16
|
+
parserOptions: {
|
|
17
|
+
ecmaVersion: 'latest',
|
|
18
|
+
sourceType: 'commonjs',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
plugins: {
|
|
22
|
+
'@typescript-eslint': tseslint,
|
|
23
|
+
},
|
|
24
|
+
rules: {
|
|
25
|
+
...tseslint.configs.recommended.rules,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
files: ['src/**/*.spec.ts', 'test/**/*.ts'],
|
|
30
|
+
rules: {
|
|
31
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
// nestforge:feature:language:typescript:end
|
|
35
|
+
// nestforge:feature:language:javascript
|
|
36
|
+
{
|
|
37
|
+
files: ['src/**/*.js', 'test/**/*.js'],
|
|
38
|
+
languageOptions: {
|
|
39
|
+
parserOptions: {
|
|
40
|
+
ecmaVersion: 'latest',
|
|
41
|
+
sourceType: 'commonjs',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
// nestforge:feature:language:javascript:end
|
|
46
|
+
prettier,
|
|
47
|
+
];
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Module } from '@nestjs/common';
|
|
2
|
+
// nestforge:feature:auth:session
|
|
3
|
+
import { MiddlewareConsumer, NestModule } from '@nestjs/common';
|
|
4
|
+
// nestforge:feature:auth:session:end
|
|
2
5
|
import { ConfigModule } from '@nestjs/config';
|
|
3
6
|
import { ThrottlerModule } from '@nestjs/throttler';
|
|
4
7
|
// nestforge:feature:redis
|
|
@@ -61,12 +64,16 @@ import { validateEnv } from './config/env.validation';
|
|
|
61
64
|
MetricsModule,
|
|
62
65
|
],
|
|
63
66
|
})
|
|
64
|
-
export class AppModule
|
|
67
|
+
export class AppModule
|
|
68
|
+
// nestforge:feature:auth:session
|
|
69
|
+
implements NestModule
|
|
70
|
+
// nestforge:feature:auth:session:end
|
|
71
|
+
{
|
|
72
|
+
// nestforge:feature:auth:session
|
|
65
73
|
configure(consumer: MiddlewareConsumer) {
|
|
66
|
-
// nestforge:feature:auth:session
|
|
67
74
|
if (process.env.ENABLE_CSRF === 'true') {
|
|
68
75
|
consumer.apply(CsrfMiddleware).forRoutes('*');
|
|
69
76
|
}
|
|
70
|
-
// nestforge:feature:auth:session:end
|
|
71
77
|
}
|
|
72
|
-
|
|
78
|
+
// nestforge:feature:auth:session:end
|
|
79
|
+
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import { Body, Controller, Get, HttpCode, HttpStatus, Post,
|
|
1
|
+
import { Body, Controller, Get, HttpCode, HttpStatus, Post, Req, UseGuards } from '@nestjs/common';
|
|
2
|
+
// nestforge:feature:redis,auth:password
|
|
3
|
+
import { Query } from '@nestjs/common';
|
|
4
|
+
// nestforge:feature:redis,auth:password:end
|
|
2
5
|
// nestforge:feature:swagger
|
|
3
6
|
import { ApiExcludeEndpoint, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
|
|
4
7
|
// nestforge:feature:swagger:end
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
// nestforge:feature:auth:password
|
|
1
3
|
import {
|
|
2
4
|
ConflictException,
|
|
3
|
-
Injectable,
|
|
4
5
|
UnauthorizedException,
|
|
5
6
|
} from '@nestjs/common';
|
|
6
7
|
import * as bcrypt from 'bcryptjs';
|
|
8
|
+
// nestforge:feature:auth:password:end
|
|
9
|
+
// nestforge:feature:redis,auth:password
|
|
7
10
|
import { createHash, randomBytes } from 'crypto';
|
|
11
|
+
// nestforge:feature:redis,auth:password:end
|
|
8
12
|
import { PrismaService } from '../database/prisma.service';
|
|
9
13
|
// nestforge:feature:redis,auth:password
|
|
10
14
|
import { MailService } from '../mail/mail.service';
|
|
@@ -217,8 +221,9 @@ export class AuthService {
|
|
|
217
221
|
role: user.role,
|
|
218
222
|
};
|
|
219
223
|
}
|
|
220
|
-
|
|
224
|
+
// nestforge:feature:redis,auth:password
|
|
221
225
|
private hashToken(token: string): string {
|
|
222
226
|
return createHash('sha256').update(token).digest('hex');
|
|
223
227
|
}
|
|
228
|
+
// nestforge:feature:redis,auth:password:end
|
|
224
229
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import prettier from 'eslint-config-prettier';
|
|
2
|
+
// nestforge:feature:language:typescript
|
|
3
|
+
import tseslint from '@typescript-eslint/eslint-plugin';
|
|
4
|
+
import tsParser from '@typescript-eslint/parser';
|
|
5
|
+
// nestforge:feature:language:typescript:end
|
|
6
|
+
|
|
7
|
+
export default [
|
|
8
|
+
{
|
|
9
|
+
ignores: ['dist/', 'coverage/', 'node_modules/'],
|
|
10
|
+
},
|
|
11
|
+
// nestforge:feature:language:typescript
|
|
12
|
+
{
|
|
13
|
+
files: ['src/**/*.ts', 'test/**/*.ts'],
|
|
14
|
+
languageOptions: {
|
|
15
|
+
parser: tsParser,
|
|
16
|
+
parserOptions: {
|
|
17
|
+
ecmaVersion: 'latest',
|
|
18
|
+
sourceType: 'commonjs',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
plugins: {
|
|
22
|
+
'@typescript-eslint': tseslint,
|
|
23
|
+
},
|
|
24
|
+
rules: {
|
|
25
|
+
...tseslint.configs.recommended.rules,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
files: ['src/**/*.spec.ts', 'test/**/*.ts'],
|
|
30
|
+
rules: {
|
|
31
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
// nestforge:feature:language:typescript:end
|
|
35
|
+
// nestforge:feature:language:javascript
|
|
36
|
+
{
|
|
37
|
+
files: ['src/**/*.js', 'test/**/*.js'],
|
|
38
|
+
languageOptions: {
|
|
39
|
+
parserOptions: {
|
|
40
|
+
ecmaVersion: 'latest',
|
|
41
|
+
sourceType: 'commonjs',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
// nestforge:feature:language:javascript:end
|
|
46
|
+
prettier,
|
|
47
|
+
];
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Module } from '@nestjs/common';
|
|
2
|
+
// nestforge:feature:auth:session
|
|
3
|
+
import { MiddlewareConsumer, NestModule } from '@nestjs/common';
|
|
4
|
+
// nestforge:feature:auth:session:end
|
|
2
5
|
import { ConfigModule } from '@nestjs/config';
|
|
3
6
|
import { ThrottlerModule } from '@nestjs/throttler';
|
|
4
7
|
// nestforge:feature:redis
|
|
@@ -61,12 +64,16 @@ import { validateEnv } from './config/env.validation';
|
|
|
61
64
|
MetricsModule,
|
|
62
65
|
],
|
|
63
66
|
})
|
|
64
|
-
export class AppModule
|
|
67
|
+
export class AppModule
|
|
68
|
+
// nestforge:feature:auth:session
|
|
69
|
+
implements NestModule
|
|
70
|
+
// nestforge:feature:auth:session:end
|
|
71
|
+
{
|
|
72
|
+
// nestforge:feature:auth:session
|
|
65
73
|
configure(consumer: MiddlewareConsumer) {
|
|
66
|
-
// nestforge:feature:auth:session
|
|
67
74
|
if (process.env.ENABLE_CSRF === 'true') {
|
|
68
75
|
consumer.apply(CsrfMiddleware).forRoutes('*');
|
|
69
76
|
}
|
|
70
|
-
// nestforge:feature:auth:session:end
|
|
71
77
|
}
|
|
72
|
-
|
|
78
|
+
// nestforge:feature:auth:session:end
|
|
79
|
+
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import { Body, Controller, Get, HttpCode, HttpStatus, Post,
|
|
1
|
+
import { Body, Controller, Get, HttpCode, HttpStatus, Post, Req, UseGuards } from '@nestjs/common';
|
|
2
|
+
// nestforge:feature:redis,auth:password
|
|
3
|
+
import { Query } from '@nestjs/common';
|
|
4
|
+
// nestforge:feature:redis,auth:password:end
|
|
2
5
|
// nestforge:feature:swagger
|
|
3
6
|
import { ApiExcludeEndpoint, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
|
|
4
7
|
// nestforge:feature:swagger:end
|
|
@@ -1,22 +1,28 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
// nestforge:feature:auth:password
|
|
1
3
|
import {
|
|
2
4
|
ConflictException,
|
|
3
|
-
Injectable,
|
|
4
5
|
UnauthorizedException,
|
|
5
6
|
} from '@nestjs/common';
|
|
7
|
+
import * as bcrypt from 'bcryptjs';
|
|
8
|
+
// nestforge:feature:auth:password:end
|
|
6
9
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
7
10
|
import {
|
|
8
11
|
DataSource,
|
|
9
|
-
IsNull,
|
|
10
12
|
Repository,
|
|
11
13
|
} from 'typeorm';
|
|
12
|
-
|
|
14
|
+
// nestforge:feature:redis,auth:password,auth:token
|
|
15
|
+
import { IsNull } from 'typeorm';
|
|
16
|
+
// nestforge:feature:redis,auth:password,auth:token:end
|
|
17
|
+
// nestforge:feature:redis,auth:password
|
|
13
18
|
import { createHash, randomBytes } from 'crypto';
|
|
19
|
+
// nestforge:feature:redis,auth:password:end
|
|
14
20
|
import { UserEntity } from '../users/entities/user.entity';
|
|
15
21
|
import { OAuthAccountEntity } from './entities/oauth-account.entity';
|
|
16
22
|
|
|
17
|
-
// nestforge:feature:auth:token
|
|
23
|
+
// nestforge:feature:redis,auth:password,auth:token
|
|
18
24
|
import { RefreshTokenEntity } from './entities/refresh-token.entity';
|
|
19
|
-
// nestforge:feature:auth:token:end
|
|
25
|
+
// nestforge:feature:redis,auth:password,auth:token:end
|
|
20
26
|
|
|
21
27
|
// nestforge:feature:redis,auth:password
|
|
22
28
|
import { MailService } from '../mail/mail.service';
|
|
@@ -338,9 +344,11 @@ export class AuthService {
|
|
|
338
344
|
};
|
|
339
345
|
}
|
|
340
346
|
|
|
347
|
+
// nestforge:feature:redis,auth:password
|
|
341
348
|
private hashToken(token: string): string {
|
|
342
349
|
return createHash('sha256')
|
|
343
350
|
.update(token)
|
|
344
351
|
.digest('hex');
|
|
345
352
|
}
|
|
353
|
+
// nestforge:feature:redis,auth:password:end
|
|
346
354
|
}
|