@nestledjs/api 0.0.10 → 0.1.0
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestledjs/api",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"generators": "./generators.json",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -17,14 +17,14 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"tslib": "^2.3.0",
|
|
20
|
-
"@nx/devkit": "21.2.
|
|
21
|
-
"@nx/js": "21.2.
|
|
20
|
+
"@nx/devkit": "21.2.1",
|
|
21
|
+
"@nx/js": "21.2.1",
|
|
22
22
|
"@prisma/internals": "^6.9.0",
|
|
23
23
|
"pluralize": "^8.0.0",
|
|
24
24
|
"dotenv": "16.4.5",
|
|
25
25
|
"pg": "^8.13.0"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@nestledjs/utils": "0.0
|
|
28
|
+
"@nestledjs/utils": "0.1.0"
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MiddlewareConsumer, Module, NestModule, RequestMethod } from '@nestjs/common'
|
|
2
2
|
import { LoggerMiddleware } from './applogger.middleware'
|
|
3
3
|
import { ConfigModule } from '@nestjs/config'
|
|
4
|
-
import {
|
|
4
|
+
import { configuration, validationSchema } from '@<%= npmScope %>/api/config'
|
|
5
5
|
|
|
6
6
|
// Auto-generated modules with special functions
|
|
7
7
|
export const coreModules = [
|
|
@@ -25,7 +25,7 @@ export const appModules = [
|
|
|
25
25
|
@Module({
|
|
26
26
|
imports: [
|
|
27
27
|
ConfigModule.forRoot({
|
|
28
|
-
load: [
|
|
28
|
+
load: [configuration],
|
|
29
29
|
validationSchema: validationSchema,
|
|
30
30
|
validationOptions: {
|
|
31
31
|
allowUnknown: true,
|
package/src/app/generator.js
CHANGED
|
@@ -33,11 +33,11 @@ function default_1(tree, schema) {
|
|
|
33
33
|
try {
|
|
34
34
|
// Get the workspace root directory
|
|
35
35
|
const workspaceRoot = tree.root;
|
|
36
|
-
// Create apps directory if it doesn't exist
|
|
36
|
+
// Create the apps directory if it doesn't exist
|
|
37
37
|
if (!tree.exists('apps')) {
|
|
38
38
|
tree.write('apps/.gitkeep', '');
|
|
39
39
|
}
|
|
40
|
-
// Run the Nx generator command directly from the workspace root with proper workspace layout
|
|
40
|
+
// Run the Nx generator command directly from the workspace root with the proper workspace layout
|
|
41
41
|
(0, child_process_1.execSync)('nx g @nx/nest:application --name api --directory apps/api --no-interactive', {
|
|
42
42
|
stdio: 'inherit',
|
|
43
43
|
cwd: workspaceRoot,
|
|
@@ -50,13 +50,12 @@ function default_1(tree, schema) {
|
|
|
50
50
|
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, './files'), path.join('apps', 'api'), Object.assign(Object.assign({}, schema), { tmpl: '', npmScope: (0, get_npm_scope_1.getNpmScope)(tree) }));
|
|
51
51
|
// Add dev:api script to package.json
|
|
52
52
|
(0, devkit_1.updateJson)(tree, 'package.json', (json) => {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
53
|
+
var _a;
|
|
54
|
+
(_a = json.scripts) !== null && _a !== void 0 ? _a : (json.scripts = {});
|
|
56
55
|
json.scripts['dev:api'] = 'nx serve api --skip-nx-cache';
|
|
57
56
|
return json;
|
|
58
57
|
});
|
|
59
|
-
// Update the build target in apps/api/project.json to use custom webpack command
|
|
58
|
+
// Update the build target in apps/api/project.json to use the custom webpack command
|
|
60
59
|
const projectJsonPath = path.join('apps', 'api', 'project.json');
|
|
61
60
|
if (tree.exists(projectJsonPath)) {
|
|
62
61
|
(0, devkit_1.updateJson)(tree, projectJsonPath, (json) => {
|
package/src/app/generator.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../generators/api/src/app/generator.ts"],"names":[],"mappings":";;AA+BA,
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../generators/api/src/app/generator.ts"],"names":[],"mappings":";;AA+BA,4BAsEC;;AArGD,uCAA+E;AAC/E,iDAAwC;AACxC,mDAA4B;AAC5B,+EAAyE;AAEzE;;;GAGG;AACH,SAAS,iBAAiB,CAAC,IAAU;IACnC,MAAM,YAAY,GAAG,4BAA4B,CAAA;IACjD,IAAI,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC;QAC9B,IAAA,mBAAU,EAAC,IAAI,EAAE,YAAY,EAAE,CAAC,IAAI,EAAE,EAAE;YACtC,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;gBACzB,kEAAkE;gBAClE,OAAO,IAAI,CAAC,eAAe,CAAC,MAAM,CAAA;gBAClC,OAAO,IAAI,CAAC,eAAe,CAAC,gBAAgB,CAAA;gBAC5C,OAAO,IAAI,CAAC,eAAe,CAAC,qBAAqB,CAAA;gBACjD,OAAO,IAAI,CAAC,eAAe,CAAC,sBAAsB,CAAA;YACpD,CAAC;YACD,OAAO,IAAI,CAAA;QACb,CAAC,CAAC,CAAA;IACJ,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,IAAI,CAAC,mCAAmC,YAAY,EAAE,CAAC,CAAA;IACjE,CAAC;AACH,CAAC;AAMD,mBAA+B,IAAU,EAAE,MAAc;;QACvD,IAAI,CAAC;YACH,mCAAmC;YACnC,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAA;YAE/B,gDAAgD;YAChD,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;gBACzB,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,EAAE,CAAC,CAAA;YACjC,CAAC;YAED,iGAAiG;YACjG,IAAA,wBAAQ,EA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cAAc,EAAE;4BACd,WAAW,EAAE;gCACX,OAAO,EAAE,sEAAsE;6BAChF;yBACF;qBACF,CAAA;oBACD,OAAO,IAAI,CAAA;gBACb,CAAC,CAAC,CAAA;YACJ,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,IAAI,CAAC,8BAA8B,eAAe,EAAE,CAAC,CAAA;YAC/D,CAAC;YAED,gEAAgE;YAChE,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,CAAA;YAClD,MAAM,aAAa,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAA;YACrF,aAAa,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;gBACjC,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;oBAC1B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;gBACvB,CAAC;YACH,CAAC,CAAC,CAAA;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,2BAA2B,EAAE,KAAK,CAAC,CAAA;YACjD,MAAM,KAAK,CAAA;QACb,CAAC;IACH,CAAC;CAAA"}
|
package/src/setup/generator.js
CHANGED
|
@@ -44,11 +44,11 @@ function apiSetupGenerator(tree) {
|
|
|
44
44
|
'cookie-parser': '^1.4.7',
|
|
45
45
|
'passport-jwt': '^4.0.1',
|
|
46
46
|
}, {
|
|
47
|
-
nx: '21.2.
|
|
48
|
-
'@nx/js': '21.2.
|
|
49
|
-
'@nx/nest': '21.2.
|
|
50
|
-
'@nx/node': '21.2.
|
|
51
|
-
'@nx/webpack': '21.2.
|
|
47
|
+
nx: '21.2.1',
|
|
48
|
+
'@nx/js': '21.2.1',
|
|
49
|
+
'@nx/nest': '21.2.1',
|
|
50
|
+
'@nx/node': '21.2.1',
|
|
51
|
+
'@nx/webpack': '21.2.1',
|
|
52
52
|
'@nestjs/schematics': '^11.0.5',
|
|
53
53
|
'@nestjs/testing': '^11.1.3',
|
|
54
54
|
'@prisma/extension-optimize': '2.0.0',
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { registerAs } from '@nestjs/config'
|
|
2
|
-
import Joi from 'joi'
|
|
3
|
-
|
|
4
|
-
export const appConfig = registerAs('app', () => ({
|
|
5
|
-
prefix: 'api',
|
|
6
|
-
environment: process.env.NODE_ENV,
|
|
7
|
-
host: process.env.HOST,
|
|
8
|
-
port: process.env.PORT ? parseInt(process.env.PORT, 10) : 3000,
|
|
9
|
-
apiUrl: process.env.API_URL,
|
|
10
|
-
webPort: process.env.WEB_PORT ? parseInt(process.env.WEB_PORT, 10) : 4200,
|
|
11
|
-
api: {
|
|
12
|
-
cookie: {
|
|
13
|
-
name: process.env.API_COOKIE_NAME,
|
|
14
|
-
secret: process.env.API_COOKIE_SECRET,
|
|
15
|
-
options: {
|
|
16
|
-
domain: process.env.API_COOKIE_DOMAIN,
|
|
17
|
-
httpOnly: true,
|
|
18
|
-
secure: true,
|
|
19
|
-
sameSite: 'none',
|
|
20
|
-
path: '/',
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
cors: {
|
|
24
|
-
origin: [process.env.SITE_URL],
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
siteUrl: process.env.SITE_URL || (process.env.API_URL ? process.env.API_URL.replace('/api', '') : ''),
|
|
28
|
-
app: {
|
|
29
|
-
email: process.env.APP_EMAIL,
|
|
30
|
-
supportEmail: process.env.APP_SUPPORT_EMAIL,
|
|
31
|
-
adminEmails: process.env.APP_ADMIN_EMAILS,
|
|
32
|
-
name: process.env.APP_NAME,
|
|
33
|
-
},
|
|
34
|
-
smtp: {
|
|
35
|
-
host: process.env.SMTP_HOST,
|
|
36
|
-
port: process.env.SMTP_PORT ? parseInt(process.env.SMTP_PORT, 10) : 587,
|
|
37
|
-
user: process.env.SMTP_USER,
|
|
38
|
-
pass: process.env.SMTP_PASS,
|
|
39
|
-
ignoreTLS: true,
|
|
40
|
-
},
|
|
41
|
-
twilio: {
|
|
42
|
-
accountSid: process.env.TWILIO_ACCOUNT_SID,
|
|
43
|
-
authToken: process.env.TWILIO_AUTH_TOKEN,
|
|
44
|
-
fromNumber: process.env.TWILIO_FROM_NUMBER,
|
|
45
|
-
},
|
|
46
|
-
}))
|
|
47
|
-
|
|
48
|
-
export const validationSchema = Joi.object({
|
|
49
|
-
NODE_ENV: Joi.string().valid('development', 'production', 'test'),
|
|
50
|
-
HOST: Joi.string().alphanum().default('localhost'),
|
|
51
|
-
PORT: Joi.number().default(3000),
|
|
52
|
-
WEB_PORT: Joi.number().default(4200),
|
|
53
|
-
WEB_URL: Joi.string().default(`http://${process.env.HOST || 'localhost'}:${process.env.WEB_PORT}`),
|
|
54
|
-
API_COOKIE_DOMAIN: Joi.string().default('localhost'),
|
|
55
|
-
API_COOKIE_NAME: Joi.string().default('__session'),
|
|
56
|
-
API_URL: Joi.string().default(`http://${process.env.HOST || 'localhost'}:${process.env.PORT}/api`),
|
|
57
|
-
APP_NAME: Joi.string().required(),
|
|
58
|
-
APP_EMAIL: Joi.string().email().required(),
|
|
59
|
-
APP_SUPPORT_EMAIL: Joi.string().email().required(),
|
|
60
|
-
APP_ADMIN_EMAILS: Joi.string().required(),
|
|
61
|
-
SITE_URL: Joi.string().uri().required(),
|
|
62
|
-
SMTP_HOST: Joi.string().required(),
|
|
63
|
-
SMTP_PORT: Joi.string().required(),
|
|
64
|
-
SMTP_USER: Joi.string().required(),
|
|
65
|
-
SMTP_PASS: Joi.string().required(),
|
|
66
|
-
})
|