Last active
December 30, 2021 15:04
-
-
Save markodayan/f477ce84433b843c322e80cec52dff64 to your computer and use it in GitHub Desktop.
TypeScript Starter script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"main": "index.js", | |
"scripts": { | |
"clean": "rimraf dist", | |
"start": "NODE_ENV=production node -r ts-node/register/transpile-only -r tsconfig-paths/register ./dist/index.js", | |
"build": "npm run clean && tsc", | |
"dev": "NODE_ENV=development ts-node-dev -r tsconfig-paths/register ./src/index.ts", | |
"test": "mocha -r ts-node/register \"src/test/**/*.spec.ts\"", | |
"pm2:dev": "npm run build && pm2 start pm2_dev.config.js", | |
"pm2:prod": "npm run build && pm2 start pm2_prod.config.js", | |
"debug": "ts-node -r tsconfig-paths/register" | |
}, | |
"repository": { | |
"type": "git", | |
"url": "git+https://github.com/markodayan/typescript-snippets.git" | |
}, | |
"engines": { | |
"node": ">=16.6.0" | |
}, | |
"keywords": [], | |
"author": "", | |
"license": "ISC", | |
"bugs": { | |
"url": "https://github.com/markodayan/typescript-snippets/issues" | |
}, | |
"homepage": "https://github.com/markodayan/typescript-snippets#readme", | |
"devDependencies": { | |
"@testdeck/mocha": "^0.1.2", | |
"@types/axios": "^0.14.0", | |
"@types/chai": "^4.2.22", | |
"@types/express": "^4.17.13", | |
"@types/lodash": "^4.14.176", | |
"@types/mocha": "^9.0.0", | |
"@types/node": "^16.11.7", | |
"@types/supertest": "^2.0.11", | |
"chai": "^4.3.4", | |
"mocha": "^9.1.3", | |
"nyc": "^15.1.0", | |
"prettier": "^2.4.1", | |
"rimraf": "^2.7.1", | |
"supertest": "^6.1.6", | |
"ts-mockito": "^2.6.1", | |
"ts-node": "^10.4.0", | |
"ts-node-dev": "^1.1.8", | |
"typescript": "^4.5.2" | |
}, | |
"dependencies": { | |
"@7urtle/lambda": "^1.3.8", | |
"@types/morgan": "^1.9.3", | |
"axios": "^0.24.0", | |
"dotenv": "^10.0.0", | |
"express": "^4.17.1", | |
"lodash": "^4.17.21", | |
"morgan": "^1.10.0", | |
"tsconfig-paths": "^3.12.0", | |
"winston": "^3.3.3" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm init -y | |
tsc --init | |
echo "node_modules\n.env\ndist" > .gitignore | |
echo "# TypeScript Boilerplate" > README.md | |
touch .env | |
mkdir -p src/test && touch src/index.ts | |
mkdir -p src/lib | |
mkdir -p src/config | |
mkdir -p .github/workflows && touch .github/workflows/actions.yaml | |
mkdir .vscode && touch .vscode/settings.json | |
touch .prettierrc | |
touch .eslintrc | |
touch pm2_dev.config.js | |
touch pm2_prod.config.js | |
git init | |
chmod +x .git/hooks/pre-commit | |
# install some dependencies | |
npm i express dotenv tsconfig-paths ts-node | |
npm i -D @types/express @types/node typescript ts-node ts-node-dev mocha chai @types/chai @types/mocha nyc prettier tsconfig-paths | |
npm i -D eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin | |
npm i -D eslint-config-prettier eslint-plugin-prettier | |
npm i -D [email protected] | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"ts-node": { | |
"files": true | |
}, | |
"compilerOptions": { | |
"target": "ES2021", | |
"module": "commonjs", | |
"strict": true, | |
"rootDir": "src", | |
"outDir": "dist", | |
"moduleResolution": "node", | |
"sourceMap": true, | |
"esModuleInterop": true, | |
"skipLibCheck": true, | |
"forceConsistentCasingInFileNames": true, | |
"noImplicitReturns": true, | |
"strictFunctionTypes": true, | |
"strictPropertyInitialization": false, | |
"baseUrl": "./", | |
"paths": { | |
"@src/*": ["src/*"], | |
"@lib/*": ["src/lib/*"] | |
} | |
} | |
} |
npm run build && npm run start:prod
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add these lines to package.json:
"start:dev": "NODE_ENV=development ts-node-dev -r tsconfig-paths/register ./src/index.ts",
"start:prod": "NODE_ENV=production node -r ts-node/register/transpile-only -r tsconfig-paths/register ./dist/index.js"