@oak-digital/types-4-strapi-2 0.5.4 → 1.0.0-beta.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.
Files changed (116) hide show
  1. package/.eslintrc.json +2 -1
  2. package/CHANGELOG.md +7 -0
  3. package/README.md +21 -8
  4. package/lib/attributes/Attributes.d.ts +4 -3
  5. package/lib/attributes/Attributes.js +102 -78
  6. package/lib/content-types/reader.js +49 -145
  7. package/lib/extra-types/ExtraType.d.ts +2 -2
  8. package/lib/extra-types/ExtraType.js +19 -38
  9. package/lib/extra-types/createExtraTypes.d.ts +1 -1
  10. package/lib/extra-types/createExtraTypes.js +11 -12
  11. package/lib/file/File.d.ts +1 -1
  12. package/lib/file/File.js +44 -43
  13. package/lib/index.js +57 -19
  14. package/lib/interface/BuiltinComponentInterface.js +9 -27
  15. package/lib/interface/BuiltinInterface.d.ts +0 -1
  16. package/lib/interface/BuiltinInterface.js +5 -26
  17. package/lib/interface/ComponentInterface.d.ts +2 -1
  18. package/lib/interface/ComponentInterface.js +30 -48
  19. package/lib/interface/Interface.d.ts +6 -2
  20. package/lib/interface/Interface.js +69 -70
  21. package/lib/interface/builtinInterfaces.d.ts +1941 -2
  22. package/lib/interface/builtinInterfaces.js +56 -46
  23. package/lib/plugins/PluginManager.d.ts +8 -2
  24. package/lib/plugins/PluginManager.js +28 -35
  25. package/lib/plugins/draft-and-publish/index.d.ts +1 -1
  26. package/lib/plugins/draft-and-publish/index.js +17 -21
  27. package/lib/plugins/i18n/index.d.ts +1 -1
  28. package/lib/plugins/i18n/index.js +17 -22
  29. package/lib/plugins/index.js +4 -4
  30. package/lib/plugins/types.d.ts +1 -1
  31. package/lib/plugins/types.js +1 -4
  32. package/lib/plugins/url-alias/index.js +12 -15
  33. package/lib/plugins/url-alias/type.js +21 -32
  34. package/lib/program/InterfaceManager.d.ts +374 -24
  35. package/lib/program/InterfaceManager.js +128 -376
  36. package/lib/readers/by-file.d.ts +321 -0
  37. package/lib/readers/by-file.js +116 -0
  38. package/lib/readers/load-strapi/index.d.ts +319 -0
  39. package/lib/readers/load-strapi/index.js +106 -0
  40. package/lib/readers/types/attributes.d.ts +1639 -0
  41. package/lib/readers/types/attributes.js +144 -0
  42. package/lib/readers/types/component.d.ts +723 -0
  43. package/lib/readers/types/component.js +11 -0
  44. package/lib/readers/types/content-type-reader.d.ts +16 -0
  45. package/lib/readers/types/content-type-reader.js +2 -0
  46. package/lib/readers/types/content-type.d.ts +766 -0
  47. package/lib/readers/types/content-type.js +16 -0
  48. package/lib/utils/casing/index.js +2 -2
  49. package/lib/utils/index.js +5 -39
  50. package/lib/writers/basic-writer.d.ts +24 -0
  51. package/lib/writers/basic-writer.js +75 -0
  52. package/lib/writers/types/writer.d.ts +4 -0
  53. package/lib/writers/types/writer.js +2 -0
  54. package/package.json +12 -9
  55. package/tests/strapi-project/.editorconfig +16 -0
  56. package/tests/strapi-project/.env.example +6 -0
  57. package/tests/strapi-project/README.md +57 -0
  58. package/tests/strapi-project/config/admin.ts +13 -0
  59. package/tests/strapi-project/config/api.ts +7 -0
  60. package/tests/strapi-project/config/database.ts +93 -0
  61. package/tests/strapi-project/config/middlewares.ts +12 -0
  62. package/tests/strapi-project/config/server.ts +10 -0
  63. package/tests/strapi-project/favicon.png +0 -0
  64. package/tests/strapi-project/package-lock.json +16125 -0
  65. package/tests/strapi-project/package.json +30 -0
  66. package/tests/strapi-project/public/robots.txt +3 -0
  67. package/tests/strapi-project/public/uploads/.gitkeep +0 -0
  68. package/tests/strapi-project/src/admin/app.example.tsx +35 -0
  69. package/tests/strapi-project/src/admin/webpack.config.example.js +9 -0
  70. package/tests/strapi-project/src/api/.gitkeep +0 -0
  71. package/tests/strapi-project/src/api/collection-1/content-types/collection-1/schema.json +18 -0
  72. package/tests/strapi-project/src/api/collection-1/content-types/generated-type/schema.json +18 -0
  73. package/tests/strapi-project/src/api/collection-1/controllers/collection-1.ts +7 -0
  74. package/tests/strapi-project/src/api/collection-1/controllers/generated-type.ts +7 -0
  75. package/tests/strapi-project/src/api/collection-1/routes/collection-1.ts +7 -0
  76. package/tests/strapi-project/src/api/collection-1/routes/generated-type.ts +7 -0
  77. package/tests/strapi-project/src/api/collection-1/services/collection-1.ts +7 -0
  78. package/tests/strapi-project/src/api/collection-1/services/generated-type.ts +7 -0
  79. package/tests/strapi-project/src/api/standalone-controller/controllers/standalone-controller.ts +13 -0
  80. package/tests/strapi-project/src/components/my-category/all-types.json +88 -0
  81. package/tests/strapi-project/src/components/other-category/sub-component.json +12 -0
  82. package/tests/strapi-project/src/extensions/.gitkeep +0 -0
  83. package/tests/strapi-project/src/index.ts +18 -0
  84. package/lib/.prettierrc.json +0 -7
  85. package/lib/case/index.d.ts +0 -4
  86. package/lib/case/index.js +0 -47
  87. package/lib/interface/Attributes.d.ts +0 -11
  88. package/lib/interface/Attributes.js +0 -167
  89. package/lib/interface/InterfaceManager.d.ts +0 -39
  90. package/lib/interface/InterfaceManager.js +0 -396
  91. package/lib/interface/interfaceCreator.js +0 -7
  92. package/lib/interface/interfaceWriter.d.ts +0 -2
  93. package/lib/interface/interfaceWriter.js +0 -46
  94. package/lib/interface/schemaReader.d.ts +0 -14
  95. package/lib/interface/schemaReader.js +0 -177
  96. package/lib/src/index.d.ts +0 -1
  97. package/lib/src/index.js +0 -25
  98. package/lib/src/interface/Attributes.d.ts +0 -11
  99. package/lib/src/interface/Attributes.js +0 -148
  100. package/lib/src/interface/BuiltinComponentInterface.d.ts +0 -5
  101. package/lib/src/interface/BuiltinComponentInterface.js +0 -36
  102. package/lib/src/interface/BuiltinInterface.d.ts +0 -5
  103. package/lib/src/interface/BuiltinInterface.js +0 -33
  104. package/lib/src/interface/ComponentInterface.d.ts +0 -8
  105. package/lib/src/interface/ComponentInterface.js +0 -58
  106. package/lib/src/interface/Interface.d.ts +0 -31
  107. package/lib/src/interface/Interface.js +0 -112
  108. package/lib/src/interface/InterfaceManager.d.ts +0 -25
  109. package/lib/src/interface/InterfaceManager.js +0 -288
  110. package/lib/src/interface/builtinInterfaces.d.ts +0 -4
  111. package/lib/src/interface/builtinInterfaces.js +0 -81
  112. package/lib/src/interface/schemaReader.d.ts +0 -14
  113. package/lib/src/interface/schemaReader.js +0 -172
  114. package/lib/src/utils/index.d.ts +0 -3
  115. package/lib/src/utils/index.js +0 -67
  116. /package/{lib/interface/interfaceCreator.d.ts → tests/strapi-project/database/migrations/.gitkeep} +0 -0
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.strapiContentType = void 0;
4
+ const zod_1 = require("zod");
5
+ const attributes_1 = require("./attributes");
6
+ exports.strapiContentType = zod_1.z.object({
7
+ attributes: zod_1.z.record(attributes_1.contentTypeAttribute),
8
+ collectionName: zod_1.z.string(),
9
+ options: zod_1.z
10
+ .object({
11
+ draftAndPublish: zod_1.z.boolean().optional().default(false),
12
+ })
13
+ .optional(),
14
+ pluginOptions: zod_1.z.record(zod_1.z.any()).optional(),
15
+ uid: zod_1.z.string().optional(),
16
+ });
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.changeCase = exports.checkCaseType = exports.caseTypesArray = void 0;
4
- var change_case_1 = require("change-case");
4
+ const change_case_1 = require("change-case");
5
5
  exports.caseTypesArray = [
6
6
  'camel',
7
7
  'capital',
@@ -16,7 +16,7 @@ function checkCaseType(caseName) {
16
16
  }
17
17
  exports.checkCaseType = checkCaseType;
18
18
  function changeCase(text, caseName) {
19
- var name = text;
19
+ let name = text;
20
20
  switch (caseName) {
21
21
  case 'dot':
22
22
  name = (0, change_case_1.dotCase)(name);
@@ -8,51 +8,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
11
  Object.defineProperty(exports, "__esModule", { value: true });
39
12
  exports.prefixDotSlash = exports.readDirFiltered = void 0;
40
- var promises_1 = require("fs/promises");
13
+ const promises_1 = require("fs/promises");
41
14
  function readDirFiltered(dir) {
42
- return __awaiter(this, void 0, void 0, function () {
43
- var folders;
44
- return __generator(this, function (_a) {
45
- switch (_a.label) {
46
- case 0: return [4 /*yield*/, (0, promises_1.readdir)(dir)];
47
- case 1:
48
- folders = _a.sent();
49
- return [2 /*return*/, folders.filter(function (folder) { return !folder.startsWith('.'); })];
50
- }
51
- });
15
+ return __awaiter(this, void 0, void 0, function* () {
16
+ const folders = yield (0, promises_1.readdir)(dir);
17
+ return folders.filter((folder) => !folder.startsWith('.'));
52
18
  });
53
19
  }
54
20
  exports.readDirFiltered = readDirFiltered;
55
21
  function prefixDotSlash(path) {
56
- return (/^\.?\.\//).test(path) ? path : './' + path;
22
+ return /^\.?\.\//.test(path) ? path : './' + path;
57
23
  }
58
24
  exports.prefixDotSlash = prefixDotSlash;
@@ -0,0 +1,24 @@
1
+ import { File } from '../file/File';
2
+ import { InterfaceWriter } from './types/writer';
3
+ import prettier from 'prettier';
4
+ declare type BasicWriterOptions = {
5
+ /**
6
+ * Warning: this will delete all files in the output directory!
7
+ * @default false
8
+ * @type {boolean}
9
+ */
10
+ deleteOld?: boolean;
11
+ prettierOptions?: prettier.Options;
12
+ indexFile?: boolean;
13
+ };
14
+ export declare class BasicWriter implements InterfaceWriter {
15
+ protected OutRootPath: string;
16
+ private DeleteOld;
17
+ private PrettierOptions;
18
+ private IndexFile;
19
+ constructor(outRootPath: string, { deleteOld, indexFile, prettierOptions, }: BasicWriterOptions);
20
+ write(data: File[]): Promise<void>;
21
+ writeIndexFile(data: File[]): Promise<void>;
22
+ makeFolders(data: File[]): Promise<void>;
23
+ }
24
+ export {};
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.BasicWriter = void 0;
16
+ const promises_1 = require("fs/promises");
17
+ const posix_1 = require("path/posix");
18
+ const prettier_1 = __importDefault(require("prettier"));
19
+ class BasicWriter {
20
+ constructor(outRootPath, { deleteOld = false, indexFile = true, prettierOptions = { parser: 'typescript' }, }) {
21
+ this.OutRootPath = outRootPath;
22
+ this.DeleteOld = deleteOld;
23
+ this.IndexFile = indexFile;
24
+ this.PrettierOptions = prettierOptions;
25
+ }
26
+ write(data) {
27
+ return __awaiter(this, void 0, void 0, function* () {
28
+ if (this.DeleteOld) {
29
+ yield (0, promises_1.rm)(this.OutRootPath, { recursive: true, force: true });
30
+ }
31
+ // make folders
32
+ yield this.makeFolders(data);
33
+ // write files
34
+ const promises = data.map((file) => __awaiter(this, void 0, void 0, function* () {
35
+ const fileData = file.toString();
36
+ const formattedFileData = prettier_1.default.format(fileData, this.PrettierOptions);
37
+ const filePath = (0, posix_1.join)(this.OutRootPath, file.getRelativeRootPathFile());
38
+ yield (0, promises_1.mkdir)((0, posix_1.dirname)(filePath), {
39
+ recursive: true,
40
+ });
41
+ yield (0, promises_1.writeFile)(filePath, formattedFileData);
42
+ }));
43
+ if (this.IndexFile) {
44
+ yield this.writeIndexFile(data);
45
+ }
46
+ yield Promise.all(promises);
47
+ });
48
+ }
49
+ writeIndexFile(data) {
50
+ return __awaiter(this, void 0, void 0, function* () {
51
+ const strings = data.map((inter) => {
52
+ return `export * from '${inter.getRelativeRootPath()}'`;
53
+ });
54
+ const fileData = strings.join('\n');
55
+ const formattedFileData = prettier_1.default.format(fileData, this.PrettierOptions);
56
+ const filePath = (0, posix_1.join)(this.OutRootPath, 'index.ts');
57
+ yield (0, promises_1.writeFile)(filePath, formattedFileData);
58
+ });
59
+ }
60
+ makeFolders(data) {
61
+ return __awaiter(this, void 0, void 0, function* () {
62
+ const folderPaths = new Set();
63
+ data.map((file) => {
64
+ const filePath = (0, posix_1.join)(this.OutRootPath, file.getRelativeRootPathFile());
65
+ const folderPath = (0, posix_1.dirname)(filePath);
66
+ folderPaths.add(folderPath);
67
+ });
68
+ const promises = Array.from(folderPaths).map((folderPath) => {
69
+ return (0, promises_1.mkdir)(folderPath, { recursive: true });
70
+ });
71
+ yield Promise.all(promises);
72
+ });
73
+ }
74
+ }
75
+ exports.BasicWriter = BasicWriter;
@@ -0,0 +1,4 @@
1
+ import { File } from '../../file/File';
2
+ export interface InterfaceWriter {
3
+ write(data: File[]): Promise<void>;
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,16 +1,10 @@
1
1
  {
2
2
  "name": "@oak-digital/types-4-strapi-2",
3
- "version": "0.5.4",
3
+ "version": "1.0.0-beta.1",
4
4
  "description": "Typescript interface generator for Strapi 4 models",
5
5
  "bin": {
6
6
  "t4s": "./bin/index.js"
7
7
  },
8
- "scripts": {
9
- "build": "tsc -p .",
10
- "testtypes": "node ./bin/index.js",
11
- "lint": "eslint src/",
12
- "t4s": "node ./bin/index.js"
13
- },
14
8
  "repository": {
15
9
  "type": "git",
16
10
  "url": "git+https://github.com/Oak-Digital/types-4-strapi-2.git"
@@ -33,11 +27,20 @@
33
27
  "@typescript-eslint/eslint-plugin": "^5.33.1",
34
28
  "@typescript-eslint/parser": "^5.33.1",
35
29
  "eslint": "^8.22.0",
30
+ "rimraf": "^4.4.1",
36
31
  "typescript": "^4.7.4"
37
32
  },
38
33
  "dependencies": {
39
34
  "change-case": "^4.1.2",
40
35
  "commander": "^9.4.0",
41
- "prettier": "^2.7.1"
36
+ "prettier": "^2.7.1",
37
+ "zod": "^3.21.4"
38
+ },
39
+ "scripts": {
40
+ "build": "rimraf lib && tsc -p .",
41
+ "testtypes": "node ./bin/index.js",
42
+ "lint": "eslint src/",
43
+ "prettier": "prettier --write \"src/**/*.ts\"",
44
+ "t4s": "node ./bin/index.js"
42
45
  }
43
- }
46
+ }
@@ -0,0 +1,16 @@
1
+ root = true
2
+
3
+ [*]
4
+ indent_style = space
5
+ indent_size = 2
6
+ end_of_line = lf
7
+ charset = utf-8
8
+ trim_trailing_whitespace = true
9
+ insert_final_newline = true
10
+
11
+ [{package.json,*.yml}]
12
+ indent_style = space
13
+ indent_size = 2
14
+
15
+ [*.md]
16
+ trim_trailing_whitespace = false
@@ -0,0 +1,6 @@
1
+ HOST=0.0.0.0
2
+ PORT=1337
3
+ APP_KEYS="toBeModified1,toBeModified2"
4
+ API_TOKEN_SALT=tobemodified
5
+ ADMIN_JWT_SECRET=tobemodified
6
+ JWT_SECRET=tobemodified
@@ -0,0 +1,57 @@
1
+ # 🚀 Getting started with Strapi
2
+
3
+ Strapi comes with a full featured [Command Line Interface](https://docs.strapi.io/developer-docs/latest/developer-resources/cli/CLI.html) (CLI) which lets you scaffold and manage your project in seconds.
4
+
5
+ ### `develop`
6
+
7
+ Start your Strapi application with autoReload enabled. [Learn more](https://docs.strapi.io/developer-docs/latest/developer-resources/cli/CLI.html#strapi-develop)
8
+
9
+ ```
10
+ npm run develop
11
+ # or
12
+ yarn develop
13
+ ```
14
+
15
+ ### `start`
16
+
17
+ Start your Strapi application with autoReload disabled. [Learn more](https://docs.strapi.io/developer-docs/latest/developer-resources/cli/CLI.html#strapi-start)
18
+
19
+ ```
20
+ npm run start
21
+ # or
22
+ yarn start
23
+ ```
24
+
25
+ ### `build`
26
+
27
+ Build your admin panel. [Learn more](https://docs.strapi.io/developer-docs/latest/developer-resources/cli/CLI.html#strapi-build)
28
+
29
+ ```
30
+ npm run build
31
+ # or
32
+ yarn build
33
+ ```
34
+
35
+ ## ⚙️ Deployment
36
+
37
+ Strapi gives you many possible deployment options for your project. Find the one that suits you on the [deployment section of the documentation](https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/deployment.html).
38
+
39
+ ## 📚 Learn more
40
+
41
+ - [Resource center](https://strapi.io/resource-center) - Strapi resource center.
42
+ - [Strapi documentation](https://docs.strapi.io) - Official Strapi documentation.
43
+ - [Strapi tutorials](https://strapi.io/tutorials) - List of tutorials made by the core team and the community.
44
+ - [Strapi blog](https://docs.strapi.io) - Official Strapi blog containing articles made by the Strapi team and the community.
45
+ - [Changelog](https://strapi.io/changelog) - Find out about the Strapi product updates, new features and general improvements.
46
+
47
+ Feel free to check out the [Strapi GitHub repository](https://github.com/strapi/strapi). Your feedback and contributions are welcome!
48
+
49
+ ## ✨ Community
50
+
51
+ - [Discord](https://discord.strapi.io) - Come chat with the Strapi community including the core team.
52
+ - [Forum](https://forum.strapi.io/) - Place to discuss, ask questions and find answers, show your Strapi project and get feedback or just talk with other Community members.
53
+ - [Awesome Strapi](https://github.com/strapi/awesome-strapi) - A curated list of awesome things related to Strapi.
54
+
55
+ ---
56
+
57
+ <sub>🤫 Psst! [Strapi is hiring](https://strapi.io/careers).</sub>
@@ -0,0 +1,13 @@
1
+ export default ({ env }) => ({
2
+ auth: {
3
+ secret: env('ADMIN_JWT_SECRET'),
4
+ },
5
+ apiToken: {
6
+ salt: env('API_TOKEN_SALT'),
7
+ },
8
+ transfer: {
9
+ token: {
10
+ salt: env('TRANSFER_TOKEN_SALT'),
11
+ },
12
+ },
13
+ });
@@ -0,0 +1,7 @@
1
+ export default {
2
+ rest: {
3
+ defaultLimit: 25,
4
+ maxLimit: 100,
5
+ withCount: true,
6
+ },
7
+ };
@@ -0,0 +1,93 @@
1
+ import path from 'path';
2
+
3
+ export default ({ env }) => {
4
+ const client = env('DATABASE_CLIENT', 'sqlite');
5
+
6
+ const connections = {
7
+ mysql: {
8
+ connection: {
9
+ connectionString: env('DATABASE_URL'),
10
+ host: env('DATABASE_HOST', 'localhost'),
11
+ port: env.int('DATABASE_PORT', 3306),
12
+ database: env('DATABASE_NAME', 'strapi'),
13
+ user: env('DATABASE_USERNAME', 'strapi'),
14
+ password: env('DATABASE_PASSWORD', 'strapi'),
15
+ ssl: env.bool('DATABASE_SSL', false) && {
16
+ key: env('DATABASE_SSL_KEY', undefined),
17
+ cert: env('DATABASE_SSL_CERT', undefined),
18
+ ca: env('DATABASE_SSL_CA', undefined),
19
+ capath: env('DATABASE_SSL_CAPATH', undefined),
20
+ cipher: env('DATABASE_SSL_CIPHER', undefined),
21
+ rejectUnauthorized: env.bool(
22
+ 'DATABASE_SSL_REJECT_UNAUTHORIZED',
23
+ true
24
+ ),
25
+ },
26
+ },
27
+ pool: { min: env.int('DATABASE_POOL_MIN', 2), max: env.int('DATABASE_POOL_MAX', 10) },
28
+ },
29
+ mysql2: {
30
+ connection: {
31
+ host: env('DATABASE_HOST', 'localhost'),
32
+ port: env.int('DATABASE_PORT', 3306),
33
+ database: env('DATABASE_NAME', 'strapi'),
34
+ user: env('DATABASE_USERNAME', 'strapi'),
35
+ password: env('DATABASE_PASSWORD', 'strapi'),
36
+ ssl: env.bool('DATABASE_SSL', false) && {
37
+ key: env('DATABASE_SSL_KEY', undefined),
38
+ cert: env('DATABASE_SSL_CERT', undefined),
39
+ ca: env('DATABASE_SSL_CA', undefined),
40
+ capath: env('DATABASE_SSL_CAPATH', undefined),
41
+ cipher: env('DATABASE_SSL_CIPHER', undefined),
42
+ rejectUnauthorized: env.bool(
43
+ 'DATABASE_SSL_REJECT_UNAUTHORIZED',
44
+ true
45
+ ),
46
+ },
47
+ },
48
+ pool: { min: env.int('DATABASE_POOL_MIN', 2), max: env.int('DATABASE_POOL_MAX', 10) },
49
+ },
50
+ postgres: {
51
+ connection: {
52
+ connectionString: env('DATABASE_URL'),
53
+ host: env('DATABASE_HOST', 'localhost'),
54
+ port: env.int('DATABASE_PORT', 5432),
55
+ database: env('DATABASE_NAME', 'strapi'),
56
+ user: env('DATABASE_USERNAME', 'strapi'),
57
+ password: env('DATABASE_PASSWORD', 'strapi'),
58
+ ssl: env.bool('DATABASE_SSL', false) && {
59
+ key: env('DATABASE_SSL_KEY', undefined),
60
+ cert: env('DATABASE_SSL_CERT', undefined),
61
+ ca: env('DATABASE_SSL_CA', undefined),
62
+ capath: env('DATABASE_SSL_CAPATH', undefined),
63
+ cipher: env('DATABASE_SSL_CIPHER', undefined),
64
+ rejectUnauthorized: env.bool(
65
+ 'DATABASE_SSL_REJECT_UNAUTHORIZED',
66
+ true
67
+ ),
68
+ },
69
+ schema: env('DATABASE_SCHEMA', 'public'),
70
+ },
71
+ pool: { min: env.int('DATABASE_POOL_MIN', 2), max: env.int('DATABASE_POOL_MAX', 10) },
72
+ },
73
+ sqlite: {
74
+ connection: {
75
+ filename: path.join(
76
+ __dirname,
77
+ '..',
78
+ '..',
79
+ env('DATABASE_FILENAME', 'data.db')
80
+ ),
81
+ },
82
+ useNullAsDefault: true,
83
+ },
84
+ };
85
+
86
+ return {
87
+ connection: {
88
+ client,
89
+ ...connections[client],
90
+ acquireConnectionTimeout: env.int('DATABASE_CONNECTION_TIMEOUT', 60000),
91
+ },
92
+ };
93
+ };
@@ -0,0 +1,12 @@
1
+ export default [
2
+ 'strapi::errors',
3
+ 'strapi::security',
4
+ 'strapi::cors',
5
+ 'strapi::poweredBy',
6
+ 'strapi::logger',
7
+ 'strapi::query',
8
+ 'strapi::body',
9
+ 'strapi::session',
10
+ 'strapi::favicon',
11
+ 'strapi::public',
12
+ ];
@@ -0,0 +1,10 @@
1
+ export default ({ env }) => ({
2
+ host: env('HOST', '0.0.0.0'),
3
+ port: env.int('PORT', 1337),
4
+ app: {
5
+ keys: env.array('APP_KEYS'),
6
+ },
7
+ webhooks: {
8
+ populateRelations: env.bool('WEBHOOKS_POPULATE_RELATIONS', false),
9
+ },
10
+ });
Binary file