dien-cg
v0.3.5
Published
code generator
Downloads
367
Readme
코드 생성기
해당 모듈은 생산성을 높히기 위해서 만든 코드 생성기 입니다.
dien.config.json
실행시키는 위치에 dien.config.json 파일을 만들어야 됩니다.
| 필드 | 설명 | |--------------|------------------------------------------------------------| | type | api, web 중 하나를 선택 | | database | 데이터베이스 정보 | | templatePath | 템플릿 만들어서 out하는 폴더 경로. ex) "templates", "src/templates" etc | | templates | 템플릿들이 있는 경로 아래의 예제를 봐주세요. key는 그 경로에 파일명에 맞게 처리 함 |
예시는 아래와 같습니다.
{
"type": "api",
"database": {
"host": "",
"database": "",
"user": "",
"password": "",
"port": 3306
},
"outTemplatePath": "templates",
"templates": {
"service/{camelTableName}.service.ts": "temps/service.template.ejs",
"controllers/{camelTableName}.controller.ts": "temps/controller.template.ejs",
"service/{camelTableName}.dao.ts": "temps/dao.template.ejs",
"controllers/{camelTableName}.validator.ts": "temps/validator.template.ejs",
"http/{camelTableName}.http": "temps/http.template.ejs"
}
}
템플릿
템플릿은 ejs를 기반으로 만들어졌습니다. ejs에 대한 자세한 내용은 ejs를 참고해주세요.
템플릿를 만들 때 여기를 참고해주세요.
변수명
| 이름 | 설명 | |----------------|----------------------| | tableName | 테이블 이름 | | tableComment | 테이블 Comment | | camelTableName | 테이블 이름을 카멜케이스로 변경처리 것 | | columnSchemas | 테이블의 컬럼들에 대한 스키마 입니다. |
columnSchemas types
type columnSchemas = SchemaInterface[];
interface SchemaInterface {
column: {
name: string;
type: string;
key: string;
null: string;
extra: string;
comment: string;
};
field: string;
type: string;
ableNull: boolean;
primaryKey: boolean;
autoIncrement: boolean;
isDate: boolean;
hasDefault: boolean;
comment: string;
}