Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
abriginets authored Feb 12, 2024
0 parents commit a1e48ea
Show file tree
Hide file tree
Showing 22 changed files with 10,933 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SERVICE_NAME=
115 changes: 115 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
module.exports = {
parser: '@typescript-eslint/parser',
extends: [
'airbnb-base',
'plugin:@typescript-eslint/recommended',
'prettier',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
'plugin:jest/recommended',
'plugin:prettier/recommended',
],
plugins: ['@typescript-eslint', 'jest', 'prettier'],
parserOptions: {
ecmaVersion: 15,
sourceType: 'module',
},
env: {
node: true,
es6: true,
jest: true,
},
rules: {
'eol-last': ['error', 'always'],
'newline-before-return': 'warn',
'import/extensions': 0,
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: false,
optionalDependencies: false,
peerDependencies: false,
},
],
'semi': 'warn',
// comma-dangle controlled by @typescript-eslint below
'comma-dangle': 'off',
'@typescript-eslint/comma-dangle': ['error', 'always-multiline'],
// quotes controlled by @typescript-eslint below
'quotes': 'off',
'@typescript-eslint/quotes': [
'warn',
'single',
{
allowTemplateLiterals: true,
},
],
'no-shadow': 'off', // no-shadow controlled by @typescript-eslint below
'@typescript-eslint/no-shadow': ['error'],
'arrow-parens': ['warn', 'always'],
// indent controlled by prettier, no linters must be involved here
'indent': 'off',
'@typescript-eslint/indent': 'off',
// do not trust anybody, even yourself
'@typescript-eslint/no-non-null-assertion': 'off',
// unused vars are only allowed using preceeding underscore
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
},
],
// single whitespace before comment. Readability 📈📈📈
'spaced-comment': ['warn', 'always'],
// empty lines don't do anything, man
'no-multiple-empty-lines': [
'warn',
{
max: 2,
maxEOF: 0,
},
],
// no default export because why would you want to have one thing names differently across the app?
'import/prefer-default-export': 'off',
'import/export': 'off',
'import/order': [
'error',
{
'groups': [['external', 'internal', 'builtin'], ['sibling', 'parent'], 'index', 'object'],
'pathGroups': [
{
pattern: '@nestjs/**',
group: 'external',
position: 'after',
},
],
'pathGroupsExcludedImportTypes': ['builtin'],
'newlines-between': 'always',
'alphabetize': {
order: 'asc',
caseInsensitive: true,
},
},
],
// NestJS tends to have empty constructors
'no-useless-constructor': 'off',
// empty function = empty constructor as well
'no-empty-function': 'off',
// make sure to always have return type specified!
'@typescript-eslint/explicit-function-return-type': 'error',
// useless in NestJS
'class-methods-use-this': 'off',
// up to developer, feel free to disable
'consistent-return': 'off',
// NestJS tends to have circular dependencies
'import/no-cycle': 'off',
},
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.ts'],
},
},
},
};
18 changes: 18 additions & 0 deletions .github/workflows/on-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Build

on: [push]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version-file: .tool-versions
- name: install
run: npm install
- name: typecheck
run: npx tsc --noEmit
- name: lint
run: npm run lint
56 changes: 56 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# compiled output
/dist
/node_modules
/build

# Logs
logs
*.log
npm-debug.log*
pnpm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# OS
.DS_Store

# Tests
/coverage
/.nyc_output

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# temp directory
.temp
.tmp

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11 changes: 11 additions & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
printWidth: 120
tabWidth: 2
useTabs: false
semi: true
singleQuote: true
trailingComma: all
bracketSpacing: true
bracketSameLine: false
arrowParens: always
quoteProps: consistent
endOfLine: lf
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 20.11.0
29 changes: 29 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
// 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": "attach",
"name": "Attach NestJS WS",
"port": 9229,
"restart": true
},
{
"type": "node",
"request": "launch",
"name": "Launch",
"program": "${workspaceFolder}/src/main.ts",
"preLaunchTask": "tsc: watch - tsconfig.json",
"outFiles": [
"${workspaceFolder}/dist/**/*.js"
],
"skipFiles": [
"${workspaceFolder}/node_modules/**/*.js",
"<node_internals>/**/*.js"
]
}
],
}
17 changes: 17 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"editor.tabSize": 2,
"editor.insertSpaces": true,
"editor.formatOnSave": true,
"editor.trimAutoWhitespace": true,
"files.insertFinalNewline": true,
"files.encoding": "utf8",
"typescript.tsdk": "node_modules/typescript/lib",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"typescript.preferences.importModuleSpecifier": "relative",
"prettier.prettierPath": "./node_modules/prettier"
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Andrey Briginets

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<p align="center">
I've been starting so many NestJS projects lately. Now it's time to create a template and share it with the world.
</p>

## Features

- Automatic NodeJS version control through [asdf](https://asdf-vm.com/) 😎
- Prettier for making it pretty 👦
- [Airbnb](https://www.npmjs.com/package/eslint-config-airbnb)-based ESLint for keeping it consistent ⚡
- `.editorconfig` for making it cross-IDE ✅
- Automatic import sorting and grouping 💪
- VSCode config to kickstart all the linters and prettiers using `formatOnSave` 🤤
- Winston powered logging. Formatted and colored for devs, forced JSON for machines 😏
- Strictly typed handcrafted config service 👽

## Getting Started

Make sure you have [asdf](https://asdf-vm.com/guide/getting-started.html) installed along with [asdf-nodejs plugin](https://github.com/asdf-vm/asdf-nodejs/) before you get started

After checking out the repository execute the following command

```sh
$ asdf install
```

Check currently installed NodeJS version. It should match the one specified in `.tool-versions` file:

```sh
$ node -v
> v20.11.0
```

And that's it! You are good to go 🎆
8 changes: 8 additions & 0 deletions nest-cli.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"deleteOutDir": true
}
}
Loading

0 comments on commit a1e48ea

Please sign in to comment.