miqro 1.6.8 → 1.7.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 -11
- package/dist/cli.js +2 -3
- package/dist/cmds/config-bash.js +0 -1
- package/dist/cmds/config-env.js +0 -1
- package/dist/cmds/config-init.js +0 -1
- package/dist/cmds/config.js +0 -1
- package/dist/cmds/db-console.js +0 -1
- package/dist/cmds/db-createmodel.js +0 -1
- package/dist/cmds/db-dump-data.js +0 -1
- package/dist/cmds/db-init.js +0 -1
- package/dist/cmds/db-makemigrations.js +0 -1
- package/dist/cmds/db-push-data.js +0 -1
- package/dist/cmds/db-sync-makemigrations.js +0 -1
- package/dist/cmds/doc-json.js +0 -1
- package/dist/cmds/doc-md.js +0 -1
- package/dist/cmds/handler-apiroute-new.js +0 -1
- package/dist/cmds/handler-main-new.js +0 -1
- package/dist/cmds/new.js +0 -1
- package/dist/cmds/start.js +0 -1
- package/dist/cmds/test.js +56 -20
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -13
- package/dist/utils/db/automigrations/index.js +14 -18
- package/dist/utils/db/automigrations/migrate.js +6 -10
- package/dist/utils/db/index.js +0 -1
- package/dist/utils/doc/index.d.ts +1 -1
- package/dist/utils/doc/index.js +1 -2
- package/dist/utils/index.d.ts +26 -2
- package/dist/utils/index.js +84 -7
- package/dist/utils/templates.js +0 -1
- package/package.json +9 -9
- package/dist/cli.js.map +0 -1
- package/dist/cmds/config-bash.js.map +0 -1
- package/dist/cmds/config-env.js.map +0 -1
- package/dist/cmds/config-init.js.map +0 -1
- package/dist/cmds/config.js.map +0 -1
- package/dist/cmds/db-console.js.map +0 -1
- package/dist/cmds/db-createmodel.js.map +0 -1
- package/dist/cmds/db-dump-data.js.map +0 -1
- package/dist/cmds/db-init.js.map +0 -1
- package/dist/cmds/db-makemigrations.js.map +0 -1
- package/dist/cmds/db-push-data.js.map +0 -1
- package/dist/cmds/db-sync-makemigrations.js.map +0 -1
- package/dist/cmds/doc-json.js.map +0 -1
- package/dist/cmds/doc-md.js.map +0 -1
- package/dist/cmds/handler-apiroute-new.js.map +0 -1
- package/dist/cmds/handler-main-new.js.map +0 -1
- package/dist/cmds/new.js.map +0 -1
- package/dist/cmds/start.js.map +0 -1
- package/dist/cmds/test.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/test/common/app.d.ts +0 -5
- package/dist/test/common/app.js +0 -51
- package/dist/test/common/app.js.map +0 -1
- package/dist/test/common/common.d.ts +0 -6
- package/dist/test/common/common.js +0 -15
- package/dist/test/common/common.js.map +0 -1
- package/dist/test/common/index.d.ts +0 -3
- package/dist/test/common/index.js +0 -16
- package/dist/test/common/index.js.map +0 -1
- package/dist/test/common/runner.d.ts +0 -34
- package/dist/test/common/runner.js +0 -88
- package/dist/test/common/runner.js.map +0 -1
- package/dist/test/index.d.ts +0 -1
- package/dist/test/index.js +0 -14
- package/dist/test/index.js.map +0 -1
- package/dist/utils/db/automigrations/deep-diff/index.d.ts +0 -24
- package/dist/utils/db/automigrations/deep-diff/index.js +0 -240
- package/dist/utils/db/automigrations/deep-diff/index.js.map +0 -1
- package/dist/utils/db/automigrations/index.js.map +0 -1
- package/dist/utils/db/automigrations/migrate.js.map +0 -1
- package/dist/utils/db/index.js.map +0 -1
- package/dist/utils/doc/index.js.map +0 -1
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/templates.js.map +0 -1
- package/src/cli.ts +0 -62
- package/src/cmds/config-bash.ts +0 -18
- package/src/cmds/config-env.ts +0 -18
- package/src/cmds/config-init.ts +0 -35
- package/src/cmds/config.ts +0 -16
- package/src/cmds/db-console.ts +0 -35
- package/src/cmds/db-createmodel.ts +0 -44
- package/src/cmds/db-dump-data.ts +0 -44
- package/src/cmds/db-init.ts +0 -42
- package/src/cmds/db-makemigrations.ts +0 -12
- package/src/cmds/db-push-data.ts +0 -77
- package/src/cmds/db-sync-makemigrations.ts +0 -12
- package/src/cmds/doc-json.ts +0 -16
- package/src/cmds/doc-md.ts +0 -241
- package/src/cmds/handler-apiroute-new.ts +0 -67
- package/src/cmds/handler-main-new.ts +0 -85
- package/src/cmds/new.ts +0 -128
- package/src/cmds/start.ts +0 -16
- package/src/cmds/test.ts +0 -45
- package/src/index.ts +0 -1
- package/src/test/common/app.ts +0 -47
- package/src/test/common/common.ts +0 -17
- package/src/test/common/index.ts +0 -3
- package/src/test/common/runner.ts +0 -121
- package/src/test/index.ts +0 -1
- package/src/utils/db/automigrations/deep-diff/index.ts +0 -264
- package/src/utils/db/automigrations/index.ts +0 -151
- package/src/utils/db/automigrations/migrate.ts +0 -888
- package/src/utils/db/index.ts +0 -128
- package/src/utils/doc/index.ts +0 -36
- package/src/utils/index.ts +0 -9
- package/src/utils/templates.ts +0 -189
- package/tsconfig.json +0 -32
package/src/utils/db/index.ts
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import { makemigrationsImpl, syncMakeMigrationsImpl } from "./automigrations";
|
|
2
|
-
import { existsSync, mkdirSync, writeFileSync } from "fs";
|
|
3
|
-
import { resolve } from "path";
|
|
4
|
-
import { templates } from "../../utils/templates";
|
|
5
|
-
import { ConfigFileNotFoundError, ConfigPathResolver, getLogger, Logger, parse } from "@miqro/core";
|
|
6
|
-
|
|
7
|
-
const logger = console;
|
|
8
|
-
|
|
9
|
-
export interface SequelizeRC {
|
|
10
|
-
// noinspection SpellCheckingInspection
|
|
11
|
-
config: string;
|
|
12
|
-
"migrations-path": string;
|
|
13
|
-
"seeders-path": string;
|
|
14
|
-
"models-path": string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const loadSequelizeRC = (sequelizercPath: string = ConfigPathResolver.getSequelizeRCFilePath(), logger?: Logger): SequelizeRC => {
|
|
18
|
-
// noinspection SpellCheckingInspection
|
|
19
|
-
if (!existsSync(sequelizercPath)) {
|
|
20
|
-
// noinspection SpellCheckingInspection
|
|
21
|
-
throw new ConfigFileNotFoundError(`missing ${sequelizercPath} file. maybe you didnt init your db config.`);
|
|
22
|
-
} else {
|
|
23
|
-
if (logger) {
|
|
24
|
-
logger.debug(`loading sequelize config from [${sequelizercPath}]`);
|
|
25
|
-
}
|
|
26
|
-
// noinspection SpellCheckingInspection
|
|
27
|
-
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
28
|
-
const sequelizerc: SequelizeRC = require(sequelizercPath);
|
|
29
|
-
return parse(sequelizercPath, sequelizerc, [
|
|
30
|
-
{ name: "config", type: "string", required: true },
|
|
31
|
-
{ name: "migrations-path", type: "string", required: true },
|
|
32
|
-
{ name: "seeders-path", type: "string", required: true },
|
|
33
|
-
{ name: "models-path", type: "string", required: true }
|
|
34
|
-
], "no_extra") as SequelizeRC;
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export const loadModels = (args?: { "models-path": string }): { path: string; modelsModule: any } => {
|
|
39
|
-
const sequelizerc = args ? args : loadSequelizeRC();
|
|
40
|
-
const modelsModule = require(sequelizerc["models-path"]);
|
|
41
|
-
return {
|
|
42
|
-
path: sequelizerc["models-path"],
|
|
43
|
-
modelsModule
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export const loadSequelize = (args?: { "models-path": string }, l?: Logger): any => {
|
|
48
|
-
const logger = l ? l : getLogger("Database");
|
|
49
|
-
const { modelsModule, path } = loadModels();
|
|
50
|
-
if (!modelsModule.sequelize || typeof modelsModule.sequelize !== "object" || typeof modelsModule.sequelize.models !== "object") {
|
|
51
|
-
throw new Error(`${path} doesnt export sequelize`);
|
|
52
|
-
}
|
|
53
|
-
modelsModule.sequelize.log = (text: string): void => {
|
|
54
|
-
logger.info(text);
|
|
55
|
-
};
|
|
56
|
-
return modelsModule.sequelize;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
// noinspection SpellCheckingInspection
|
|
61
|
-
export const initDBConfig = (): boolean => {
|
|
62
|
-
try {
|
|
63
|
-
const initDir = (p: string): void => {
|
|
64
|
-
if (!existsSync(p)) {
|
|
65
|
-
logger.warn(`creating ${p}`);
|
|
66
|
-
mkdirSync(p);
|
|
67
|
-
} else {
|
|
68
|
-
logger.warn(`${p} already exists!. init will not create it.`);
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
const initFile = (p: string, template: string): void => {
|
|
73
|
-
if (!existsSync(p)) {
|
|
74
|
-
logger.warn(`creating ${p} file`);
|
|
75
|
-
writeFileSync(p, template);
|
|
76
|
-
} else {
|
|
77
|
-
logger.warn(`${p} already exists!. init will not create it.`);
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
// noinspection SpellCheckingInspection
|
|
82
|
-
const sequelizercPath = resolve(ConfigPathResolver.getBaseDirname(), ".sequelizerc");
|
|
83
|
-
if (existsSync(sequelizercPath)) {
|
|
84
|
-
logger.warn(`.sequelizerc already exists!. init will do nothing.`);
|
|
85
|
-
return false;
|
|
86
|
-
} else {
|
|
87
|
-
// disable experimental typescript support
|
|
88
|
-
const typescript = false; //existsSync(resolve(ConfigPathResolver.getBaseDirname(), "tsconfig.json")) ? true : false;
|
|
89
|
-
const dbFolder = resolve(ConfigPathResolver.getBaseDirname(), "db");
|
|
90
|
-
const migrationsFolder = resolve(dbFolder, "migrations");
|
|
91
|
-
const modelsFolder = typescript ? resolve("src", "models") : resolve(dbFolder, "models");
|
|
92
|
-
const seedersFolder = resolve(dbFolder, "seeders");
|
|
93
|
-
const modelLoaderPath = resolve(modelsFolder, typescript ? "index.ts" : "index.js");
|
|
94
|
-
const dbConfigFilePath = resolve(dbFolder, "connection.js");
|
|
95
|
-
// noinspection SpellCheckingInspection
|
|
96
|
-
initFile(sequelizercPath, templates.sequelizerc(typescript));
|
|
97
|
-
initDir(dbFolder);
|
|
98
|
-
initFile(dbConfigFilePath, templates.dbConfig);
|
|
99
|
-
initDir(migrationsFolder);
|
|
100
|
-
initDir(modelsFolder);
|
|
101
|
-
initFile(modelLoaderPath, templates.modelsIndex);
|
|
102
|
-
initDir(seedersFolder);
|
|
103
|
-
}
|
|
104
|
-
return true;
|
|
105
|
-
} catch (e: any) {
|
|
106
|
-
logger.error(e.message);
|
|
107
|
-
throw e;
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
// noinspection SpellCheckingInspection
|
|
112
|
-
export const makemigrations = (): void => {
|
|
113
|
-
try {
|
|
114
|
-
makemigrationsImpl();
|
|
115
|
-
} catch (e: any) {
|
|
116
|
-
logger.error(e.message);
|
|
117
|
-
throw e;
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
export const syncMakeMigrations = (): void => {
|
|
122
|
-
try {
|
|
123
|
-
syncMakeMigrationsImpl();
|
|
124
|
-
} catch (e: any) {
|
|
125
|
-
logger.error(e.message);
|
|
126
|
-
throw e;
|
|
127
|
-
}
|
|
128
|
-
};
|
package/src/utils/doc/index.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { SessionHandlerOptions, ConfigPathResolver, GroupPolicy, Logger, Method, ParseOptions } from "@miqro/core";
|
|
2
|
-
import { traverseAPIRouteDir } from "@miqro/core/dist/handler/api-router-utils";
|
|
3
|
-
import { basename, resolve } from "path";
|
|
4
|
-
|
|
5
|
-
export const getDOCJSON = ({ dirname, subPath }: { dirname: string; subPath: string; }, logger: Logger): {
|
|
6
|
-
path?: string | string[];
|
|
7
|
-
method?: Method | Method[];
|
|
8
|
-
description?: string;
|
|
9
|
-
policy?: GroupPolicy;
|
|
10
|
-
headers?: ParseOptions | ParseOptions[];
|
|
11
|
-
session?: false | true | SessionHandlerOptions;
|
|
12
|
-
params?: false | ParseOptions | ParseOptions[];
|
|
13
|
-
query?: false | ParseOptions | ParseOptions[];
|
|
14
|
-
body?: false | ParseOptions | ParseOptions[];
|
|
15
|
-
result?: ParseOptions | ParseOptions[];
|
|
16
|
-
featureName: string;
|
|
17
|
-
}[] => {
|
|
18
|
-
const apiTraverse = traverseAPIRouteDir(basename(dirname).toUpperCase(), resolve(ConfigPathResolver.getBaseDirname(), dirname), subPath, undefined, logger);
|
|
19
|
-
const docJSON = Object.keys(apiTraverse).map(featureName => {
|
|
20
|
-
const { path, method, options } = apiTraverse[featureName];
|
|
21
|
-
const { session, policy, description } = options ? options : { session: undefined, policy: undefined, description: undefined };
|
|
22
|
-
const { params, query, body, headers } = options && options.request ? options.request : { params: undefined, query: undefined, body: undefined, headers: undefined };
|
|
23
|
-
const result = options && options.response !== true ? options.response : undefined;
|
|
24
|
-
return {
|
|
25
|
-
path,
|
|
26
|
-
method,
|
|
27
|
-
headers,
|
|
28
|
-
session: session ? typeof session === "function" ? true : session : false,
|
|
29
|
-
policy,
|
|
30
|
-
params,
|
|
31
|
-
description, query, body, result,
|
|
32
|
-
featureName
|
|
33
|
-
};
|
|
34
|
-
});
|
|
35
|
-
return docJSON;
|
|
36
|
-
}
|
package/src/utils/index.ts
DELETED
package/src/utils/templates.ts
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
// noinspection SpellCheckingInspection
|
|
2
|
-
|
|
3
|
-
export const logEnvFile = `####################
|
|
4
|
-
## logging
|
|
5
|
-
LOG_LEVEL=info
|
|
6
|
-
LOG_LEVEL_Database=error
|
|
7
|
-
#LOG_FILE=./logs/dev.log
|
|
8
|
-
`;
|
|
9
|
-
|
|
10
|
-
export const featuresEnvFile = `####################
|
|
11
|
-
## features
|
|
12
|
-
#MY_CUSTOM_FEATURE=false
|
|
13
|
-
`;
|
|
14
|
-
|
|
15
|
-
export const dbEnvFile = `####################
|
|
16
|
-
## db
|
|
17
|
-
DB_URI=sqlite://user:password@localhost:3306/devdb
|
|
18
|
-
DB_DIALECT_SSL=true
|
|
19
|
-
DB_POOL_MAX=5
|
|
20
|
-
DB_POOL_MIN=0
|
|
21
|
-
DB_POOL_ACQUIRE=30000
|
|
22
|
-
DB_POOL_IDDLE=10000
|
|
23
|
-
DB_STORAGE=./dev.sqlite3
|
|
24
|
-
`;
|
|
25
|
-
|
|
26
|
-
export const authEnvFile = `####################
|
|
27
|
-
## Auth
|
|
28
|
-
TOKEN_LOCATION=header
|
|
29
|
-
#TOKEN_LOCATION=query
|
|
30
|
-
TOKEN_VERIFY_LOCATION=header
|
|
31
|
-
#TOKEN_VERIFY_LOCATION=query
|
|
32
|
-
TOKEN_HEADER=Authorization
|
|
33
|
-
#TOKEN_QUERY=Authorization
|
|
34
|
-
#TOKEN_VERIFY_ENDPOINT=
|
|
35
|
-
TOKEN_VERIFY_ENDPOINT_METHOD=GET
|
|
36
|
-
`;
|
|
37
|
-
|
|
38
|
-
// noinspection SpellCheckingInspection
|
|
39
|
-
const modelsIndex =
|
|
40
|
-
`'use strict';
|
|
41
|
-
|
|
42
|
-
const fs = require('fs');
|
|
43
|
-
const path = require('path');
|
|
44
|
-
const Sequelize = require('sequelize');
|
|
45
|
-
const basename = path.basename(__filename);
|
|
46
|
-
|
|
47
|
-
const sequelizerc = require(path.resolve(__dirname, "..", "..", ".sequelizerc"));
|
|
48
|
-
|
|
49
|
-
const config = require(sequelizerc.config);
|
|
50
|
-
const modelsPath = sequelizerc['models-path'];
|
|
51
|
-
const db = {};
|
|
52
|
-
|
|
53
|
-
let sequelize;
|
|
54
|
-
if (config.use_env_variable) {
|
|
55
|
-
sequelize = new Sequelize(process.env[config.use_env_variable], config);
|
|
56
|
-
} else {
|
|
57
|
-
sequelize = new Sequelize(config.database, config.username, config.password, config);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
fs
|
|
61
|
-
.readdirSync(modelsPath)
|
|
62
|
-
.filter(file => {
|
|
63
|
-
return (file.indexOf('.') !== 0) && (file !== basename) && (file.slice(-3) === '.js');
|
|
64
|
-
})
|
|
65
|
-
.forEach(file => {
|
|
66
|
-
const model = require(path.join(modelsPath, file))(sequelize, Sequelize.DataTypes);
|
|
67
|
-
db[model.name] = model;
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
Object.keys(db).forEach(modelName => {
|
|
71
|
-
if (db[modelName].associate) {
|
|
72
|
-
db[modelName].associate(db);
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
module.exports = db;
|
|
77
|
-
module.exports.sequelize = sequelize;
|
|
78
|
-
module.exports.Sequelize = Sequelize;
|
|
79
|
-
|
|
80
|
-
`;
|
|
81
|
-
// noinspection SpellCheckingInspection
|
|
82
|
-
const dbConfig =
|
|
83
|
-
`const { loadConfig, checkEnvVariables } = require("@miqro/core");
|
|
84
|
-
|
|
85
|
-
loadConfig();
|
|
86
|
-
|
|
87
|
-
const { URL } = require("url");
|
|
88
|
-
|
|
89
|
-
const [DB_URI] = checkEnvVariables(["DB_URI"]);
|
|
90
|
-
const [DB_POOL, DB_POOL_ACQUIRE, DB_POOL_IDDLE, DB_POOL_MAX, DB_POOL_MIN] = checkEnvVariables(["DB_POOL", "DB_POOL_ACQUIRE", "DB_POOL_IDDLE", "DB_POOL_MAX", "DB_POOL_MIN"], ["false", "30000", "10000", "5", "0"]);
|
|
91
|
-
|
|
92
|
-
const pool = DB_POOL === "true" ? {
|
|
93
|
-
acquire: parseInt(DB_POOL_ACQUIRE, 10),
|
|
94
|
-
idle: parseInt(DB_POOL_IDDLE, 10),
|
|
95
|
-
max: parseInt(DB_POOL_MAX, 10),
|
|
96
|
-
min: parseInt(DB_POOL_MIN, 10)
|
|
97
|
-
} : undefined;
|
|
98
|
-
|
|
99
|
-
const parsed = new URL(process.env.DB_URI);
|
|
100
|
-
|
|
101
|
-
module.exports = {
|
|
102
|
-
database: parsed.pathname.substr(1),
|
|
103
|
-
host: parsed.hostname,
|
|
104
|
-
port: parsed.port,
|
|
105
|
-
username: parsed.username,
|
|
106
|
-
password: parsed.password,
|
|
107
|
-
dialect: parsed.protocol.substring(0, parsed.protocol.length - 1),
|
|
108
|
-
dialectOptions: {
|
|
109
|
-
ssl: process.env.DB_DIALECT_SSL === "true" || process.env.DB_DIALECT_SSL === undefined ? true : false
|
|
110
|
-
},
|
|
111
|
-
pool,
|
|
112
|
-
storage: process.env.DB_STORAGE
|
|
113
|
-
};
|
|
114
|
-
`;
|
|
115
|
-
// noinspection SpellCheckingInspection
|
|
116
|
-
const sequelizerc = (typescript?: boolean): string =>
|
|
117
|
-
`const path = require("path");
|
|
118
|
-
|
|
119
|
-
module.exports = {
|
|
120
|
-
"config": path.resolve(__dirname, "db", "connection.js"),
|
|
121
|
-
"migrations-path": path.resolve(__dirname, "db", "migrations"),
|
|
122
|
-
"seeders-path": path.resolve(__dirname, "db", "seeders"),
|
|
123
|
-
${typescript ? `"models-path": path.resolve(__dirname, "dist", "models")` : `"models-path": path.resolve(__dirname, "db", "models")`},
|
|
124
|
-
};
|
|
125
|
-
`;
|
|
126
|
-
|
|
127
|
-
const exampleModel = (modelName: string, typescript?: boolean): string => {
|
|
128
|
-
return typescript ? `import { Sequelize, DataTypes, ModelCtor, Model } from "sequelize";
|
|
129
|
-
|
|
130
|
-
export interface ${modelName.charAt(0).toUpperCase()}${modelName.substring(1)} {
|
|
131
|
-
name: string;
|
|
132
|
-
timestamp: number;
|
|
133
|
-
};
|
|
134
|
-
export type ${modelName.charAt(0).toUpperCase()}${modelName.substring(1)}Model = Model<${modelName.charAt(0).toUpperCase()}${modelName.substring(1)}>;
|
|
135
|
-
export type ${modelName.charAt(0).toUpperCase()}${modelName.substring(1)}ModelCtor = ModelCtor<${modelName.charAt(0).toUpperCase()}${modelName.substring(1)}Model>;
|
|
136
|
-
|
|
137
|
-
module.exports = (sequelize: Sequelize): ${modelName.charAt(0).toUpperCase()}${modelName.substring(1)}ModelCtor => {
|
|
138
|
-
const ${modelName} = sequelize.define<${modelName.charAt(0).toUpperCase()}${modelName.substring(1)}Model>("${modelName}", {
|
|
139
|
-
name: {
|
|
140
|
-
type: DataTypes.STRING,
|
|
141
|
-
allowNull: false,
|
|
142
|
-
defaultValue: ""
|
|
143
|
-
},
|
|
144
|
-
timestamp: {
|
|
145
|
-
type: DataTypes.INTEGER,
|
|
146
|
-
allowNull: false,
|
|
147
|
-
defaultValue: 0
|
|
148
|
-
}
|
|
149
|
-
}, {});
|
|
150
|
-
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
151
|
-
// @ts-ignore
|
|
152
|
-
${modelName}.associate = function (models) {
|
|
153
|
-
// associations can be defined here
|
|
154
|
-
// ${modelName}.belongsTo(models.....)
|
|
155
|
-
};
|
|
156
|
-
return ${modelName};
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
` : `module.exports = (sequelize, DataTypes) => {
|
|
161
|
-
const ${modelName} = sequelize.define("${modelName}", {
|
|
162
|
-
name: {
|
|
163
|
-
type: DataTypes.STRING,
|
|
164
|
-
allowNull: false,
|
|
165
|
-
defaultValue: ""
|
|
166
|
-
},
|
|
167
|
-
surname: DataTypes.STRING,
|
|
168
|
-
email: DataTypes.STRING,
|
|
169
|
-
password: DataTypes.STRING
|
|
170
|
-
}, {});
|
|
171
|
-
${modelName}.associate = function(models) {
|
|
172
|
-
// associations can be defined here
|
|
173
|
-
// ${modelName}.belongsTo(models.....)
|
|
174
|
-
};
|
|
175
|
-
return ${modelName};
|
|
176
|
-
};`;
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
// noinspection SpellCheckingInspection
|
|
180
|
-
export const templates = {
|
|
181
|
-
modelsIndex,
|
|
182
|
-
dbConfig,
|
|
183
|
-
sequelizerc,
|
|
184
|
-
exampleModel,
|
|
185
|
-
logEnvFile,
|
|
186
|
-
authEnvFile,
|
|
187
|
-
dbEnvFile,
|
|
188
|
-
featuresEnvFile
|
|
189
|
-
};
|
package/tsconfig.json
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"typedocOptions": {
|
|
3
|
-
"entryPoints": ["src/index.ts"],
|
|
4
|
-
"out": "docs"
|
|
5
|
-
},
|
|
6
|
-
"compileOnSave": true,
|
|
7
|
-
"compilerOptions": {
|
|
8
|
-
"lib": ["es2021"],
|
|
9
|
-
"module": "commonjs",
|
|
10
|
-
"target": "es2021",
|
|
11
|
-
|
|
12
|
-
"strict": true,
|
|
13
|
-
"esModuleInterop": true,
|
|
14
|
-
"skipLibCheck": true,
|
|
15
|
-
"forceConsistentCasingInFileNames": true,
|
|
16
|
-
|
|
17
|
-
"outDir": "./dist/",
|
|
18
|
-
"removeComments": false,
|
|
19
|
-
"noImplicitAny": true,
|
|
20
|
-
"preserveConstEnums": true,
|
|
21
|
-
"sourceMap": true,
|
|
22
|
-
"declaration": true,
|
|
23
|
-
"moduleResolution": "node"
|
|
24
|
-
},
|
|
25
|
-
"include": [
|
|
26
|
-
"src/**/*"
|
|
27
|
-
],
|
|
28
|
-
"exclude": [
|
|
29
|
-
"node_modules",
|
|
30
|
-
"test/**/*"
|
|
31
|
-
]
|
|
32
|
-
}
|