Skip to content

Instantly share code, notes, and snippets.

@wmakeev
Last active August 5, 2023 11:28
Show Gist options
  • Save wmakeev/5862c825dee7da01b9fd251d43dde520 to your computer and use it in GitHub Desktop.
Save wmakeev/5862c825dee7da01b9fd251d43dde520 to your computer and use it in GitHub Desktop.
[01 - Node.js base template] #template #env

Params

Parameter Default Description
PROJECT_NAME FOLDER_NAME Name of current folder
PACKAGE_NAME PROJECT_NAME Package name
PKG_PUBLISH_CONFIG undefined restricted or public for scoped packages
PROJECT_DESCRIPTION Description
AUTHOR Vitaliy V. Makeev
LICENCE MIT
global.FOLDER_NAME = __dirname // TODO
npm i -D @types/node@20 prettier dotenv auto-changelog envalid && git init
root = true
[*]
indent_style = space
indent_size = 2
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch JS",
"skipFiles": ["<node_internals>/**"],
"envFile": "${workspaceFolder}/.env",
"program": "${file}",
"internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std"
}
]
}
{
"files.exclude": {
"node_modules": true
},
"explorer.autoRevealExclude": {
"**/node_modules": true
},
"editor.formatOnSave": true,
"editor.formatOnPaste": false,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.formatOnSaveMode": "file"
}
.DS_Store
# Logs
logs
*.log
npm-debug.log*
# npm
node_modules
# env
.env*
!.env.example
# temp
/__temp
DEBUG=true
import { cleanEnv, num, str } from "envalid";
export const env = cleanEnv(process.env, {
FOO: str(),
BAR: num({ default: 0 }),
});

%PROJECT_NAME%

%PROJECT_DESCRIPTION%

{
"name": "%PACKAGE_NAME%",
"version": "0.0.0",
"description": "%PROJECT_DESCRIPTION%",
"scripts": {
"env:example": "npx [email protected]",
"test": "echo 'No tests'",
"version": "npm run env:example && auto-changelog -p && git add CHANGELOG.md .env.example",
"release": "np"
},
"publishConfig": {
"access": "%PKG_PUBLISH_CONFIG%"
},
"engines": {
"node": ">=14"
},
"prettier": {
"semi": false,
"singleQuote": true,
"quoteProps": "consistent",
"trailingComma": "none",
"arrowParens": "avoid"
},
"np": {
"yarn": false
},
"author": {
"name": "%AUTHOR%",
"email": "%AUTHOR_EMAIL%"
},
"license": "%LICENCE%"
}
{
"compilerOptions": {
"lib": [
"ES2021"
],
"noEmit": true,
"strict": true,
"allowJs": true,
"alwaysStrict": true,
"checkJs": true,
"moduleResolution": "Node",
"module": "CommonJS"
},
"include": [
"./**/*"
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment