UNPKG

@ancxkush/create-ts-express-mongo-starter-code

Version:

NodeJS/Express starter code with - TypeScript, MongoDB setup, Exception Handler, Logger, HTTP testing example, Swagger Docs example, Mongoose model example, JOI validation example, CRUD operations example

32 lines (25 loc) 1.04 kB
#!/usr/bin/env node const spawn = require('cross-spawn') const fs = require('fs') const path = require('path') const runCommand = (command) => { try { spawn.sync(`${command}`, { stdio: 'inherit' }) } catch (err) { console.error(`Failed to execute ${command}`, err) return false } return true } const repoName = process.argv.slice(2) || 'ts-express-mongo-starter-code' const gitCheckoutCommand = `git clone https://github.com/ankushknr19/create-ts-express-mongo-starter-code.git ${repoName}` const installDepsCommand = `cd ${repoName} && cd backend && npm install` console.log(`Cloning the repository with name ${repoName}`) const checkedOut = runCommand(gitCheckoutCommand) if (!checkedOut) process.exit(-1) console.log(`Installing dependencies for ${repoName}`) const installedDeps = runCommand(installDepsCommand) if (!installedDeps) process.exit(-1) console.log('You are ready to rock! Follow these commands to get started:') console.log(`cd ${repoName}`) console.log('cd backend && npm start')