create-types-backend
Version:
A CLI tool to quickly setup an Express.js backend in TypeScript, using essential configurations and user's preferences.
16 lines (15 loc) • 525 B
JavaScript
import fs from "fs";
import { modelContent } from "../content/example-model.js";
export const createModel = (answers) => {
const userTypesContent = `interface UserTypes {
_id: Types.ObjectId;
name: string;
username: string;
password: string;
${answers.useAuth ? "matchPassword(enteredPassword: string): Promise<boolean>;" : ""}
createdAt: Date;
updatedAt: Date;
}`;
fs.writeFileSync("src/types/user.d.ts", userTypesContent);
fs.writeFileSync("src/models/user.ts", modelContent(answers));
};