sequelize-ts-boilerplate
Version:
A REST API scaffolding tool designed to scale and easily generate CRUD endpoints based on database schema design
70 lines (65 loc) • 2.35 kB
text/typescript
import { CONSTANT } from "./constants";
import * as path from "path";
export default function mergeConfig(config) {
const root = process.cwd();
const daosPath = `${root}/output/src/daos`;
const servicesPath = `${root}/output/src/services`;
const controllersPath = `${root}/output/src/controllers`;
const ormWrapperPath = `${root}/output/src/classes/Orm.ts`;
const sequelizeConfigPath = `${root}/output/src/datasources/sequelize-config.ts`;
const interfacesPath = `${root}/output/src/interfaces/interfaces.generated.ts`;
const envPath = `${root}/.env`;
const packageJSONPath = `${root}/package.json`;
return {
...{
// TODO need to remove env and "dev"
ENV: "dev",
DATABASE_CONNECTION_SETINGS: {
"dev": {
"host": "https://some-url",
"db": "databaseName",
"username": "dlemburg",
"password": "password",
"dialect": "mysql",
"port": "3306"
}
},
ORM_GENERATE: {
caseSensitiveProps: [],
skipTables: [],
manyToManyIdentifiers: ["map"],
lookup: {
tableName: "Lookup",
identifier: "lkp"
},
pkIdentifier: "id"
},
CRUD_GENERATE: {
shouldGenerate: true,
framework: "express",
controllerOverrides: {
user: {
routes: ["GET", "POST", "DELETE"]
},
company: {
routes: ["PUT"]
}
}
}
},
...config,
// not yet implemented as potential option
...{
path: {
daos: daosPath,
services: servicesPath,
interface: interfacesPath,
ormWrapper: ormWrapperPath,
controllers: controllersPath,
sequelizeConfig: sequelizeConfigPath,
env: envPath,
packageJSON: packageJSONPath
}
}
};
}