-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mike Valeriano
committed
May 29, 2024
0 parents
commit 9d4d857
Showing
26 changed files
with
6,939 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": ["@commitlint/config-conventional"] | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 2 | ||
trim_trailing_whitespace = true | ||
max_line_length = 100 | ||
charset = utf-8 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "npm" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: checks | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
run-checks: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
- run: yarn install | ||
- run: yarn tsc --noEmit | ||
- run: yarn eslint src | ||
- run: yarn prettier src | ||
- run: yarn test |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# output | ||
.next | ||
build | ||
dist | ||
out | ||
|
||
# dependencies | ||
node_modules | ||
.pnp | ||
.pnp.js | ||
.yarn/install-state.gz | ||
|
||
# tests | ||
.nyc_output | ||
coverage | ||
|
||
# environment variables | ||
.env | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
.env.local | ||
|
||
# logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
pnpm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
|
||
# temp directory | ||
.temp | ||
.tmp | ||
temp | ||
tmp | ||
|
||
# ides & editors | ||
.idea | ||
.project | ||
.classpath | ||
.c9 | ||
*.launch | ||
.settings | ||
*.sublime-workspace | ||
|
||
# typescript | ||
*.tsbuildinfo | ||
|
||
# vercel | ||
.vercel |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
npx commitlint --edit $1 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
npx tsc --noemit | ||
npx lint-staged | ||
npm run test |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"*.(ts|tsx)": ["eslint --fix", "prettier --write"], | ||
"*.(json)": ["prettier --write"] | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"@mkvlrn/prettier-config" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"$schema": "https://json.schemastore.org/swcrc", | ||
"module": { | ||
"type": "es6", | ||
"strict": true, | ||
"strictMode": true | ||
}, | ||
"jsc": { | ||
"experimental": { | ||
"keepImportAssertions": true | ||
}, | ||
"target": "esnext", | ||
"parser": { | ||
"syntax": "typescript", | ||
"tsx": true, | ||
"decorators": true, | ||
"dynamicImport": true, | ||
"importAssertions": true | ||
}, | ||
"minify": { | ||
"compress": false, | ||
"mangle": false | ||
}, | ||
"baseUrl": ".", | ||
"paths": { | ||
"#/*": ["./src/*"] | ||
} | ||
}, | ||
"isModule": true | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"recommendations": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode"] | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"[javascript][typescript][javascriptreact][typescriptreact]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll": "explicit" | ||
}, | ||
"editor.formatOnPaste": true, | ||
"editor.formatOnSave": true, | ||
"editor.formatOnType": true, | ||
"editor.rulers": [100], | ||
"editor.wordWrapColumn": 100, | ||
"editor.wordWrap": "wordWrapColumn", | ||
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"], | ||
"typescript.preferences.importModuleSpecifier": "non-relative", | ||
"typescript.suggest.paths": true, | ||
"typescript.tsdk": "./node_modules/typescript/lib" | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from "@mkvlrn/eslint-config"; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"$schema": "https://json.schemastore.org/nest-cli", | ||
"collection": "@nestjs/schematics", | ||
"sourceRoot": "src", | ||
"compilerOptions": { | ||
"deleteOutDir": true, | ||
"builder": "swc" | ||
}, | ||
"generateOptions": { | ||
"spec": false | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{ | ||
"name": "template-nest", | ||
"description": "A template for NestJS projects", | ||
"version": "1.0.0", | ||
"private": true, | ||
"type": "module", | ||
"author": "Mike Valeriano <mkvlrn@gmail.com>", | ||
"repository": { | ||
"type": "git", | ||
"url": "git@github.com:mkvlrn/template-nest" | ||
}, | ||
"keywords": [ | ||
"nest", | ||
"template" | ||
], | ||
"scripts": { | ||
"test": "vitest --run", | ||
"test:cov": "rm -rf coverage && vitest run --coverage", | ||
"prepare": "husky", | ||
"dev": "node --import @swc-node/register/esm-register --watch src/index.ts", | ||
"build": "rm -rf dist && nest build && find dist -type f -name '*.spec.js' -delete", | ||
"start": "node dist" | ||
}, | ||
"devDependencies": { | ||
"@commitlint/cli": "^19.3.0", | ||
"@commitlint/config-conventional": "^19.2.2", | ||
"@mkvlrn/eslint-config": "^24.5.4", | ||
"@mkvlrn/prettier-config": "^24.5.2", | ||
"@nestjs/cli": "^10.3.2", | ||
"@nestjs/schematics": "^10.1.1", | ||
"@nestjs/testing": "^10.3.8", | ||
"@swc-node/register": "^1.9.1", | ||
"@swc/cli": "^0.3.12", | ||
"@swc/core": "1.5.7", | ||
"@swc/types": "^0.1.7", | ||
"@types/express": "^4.17.21", | ||
"@types/node": "^20.12.12", | ||
"@types/supertest": "^6.0.2", | ||
"@vitest/coverage-v8": "^1.6.0", | ||
"husky": "^9.0.11", | ||
"lint-staged": "^15.2.5", | ||
"supertest": "^7.0.0", | ||
"typescript": "^5.4.5", | ||
"typescript-eslint": "^7.11.0", | ||
"unplugin-swc": "^1.4.5", | ||
"vite-tsconfig-paths": "^4.3.2", | ||
"vitest": "^1.6.0" | ||
}, | ||
"dependencies": { | ||
"@nestjs/common": "^10.3.8", | ||
"@nestjs/core": "^10.3.8", | ||
"@nestjs/platform-express": "^10.3.8", | ||
"reflect-metadata": "^0.2.2", | ||
"rxjs": "^7.8.1" | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# template-nest | ||
|
||
A sane, opinionated template for nestjs projects. | ||
|
||
Uses typescript, eslint, prettier, commitlint, vitest, lint-staged, husky, swc, and more. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { INestApplication } from '@nestjs/common'; | ||
import { Test } from '@nestjs/testing'; | ||
import supertest from 'supertest'; | ||
import { afterEach, beforeEach, describe, expect, test } from 'vitest'; | ||
import { AppModule } from '#/app.module.js'; | ||
|
||
describe('AppController', () => { | ||
let app: INestApplication; | ||
|
||
beforeEach(async () => { | ||
const module = await Test.createTestingModule({ | ||
imports: [AppModule], | ||
}).compile(); | ||
|
||
app = module.createNestApplication(); | ||
await app.init(); | ||
}); | ||
|
||
afterEach(async () => { | ||
await app.close(); | ||
}); | ||
|
||
test('GET /', async () => { | ||
const response = await supertest(app.getHttpServer()).get('/'); | ||
|
||
expect(response.status).toBe(200); | ||
expect(response.text).toBe('Hello World!'); | ||
}); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Controller, Get } from '@nestjs/common'; | ||
import { AppService } from '#/app.service.js'; | ||
|
||
@Controller() | ||
export class AppController { | ||
constructor(private appService: AppService) {} | ||
|
||
@Get() | ||
async getHello(): Promise<string> { | ||
return this.appService.getHello(); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { AppController } from '#/app.controller.js'; | ||
import { AppService } from '#/app.service.js'; | ||
|
||
@Module({ | ||
imports: [], | ||
controllers: [AppController], | ||
providers: [AppService], | ||
}) | ||
// eslint-disable-next-line @typescript-eslint/no-extraneous-class | ||
export class AppModule {} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Test } from '@nestjs/testing'; | ||
import { beforeEach, describe, expect, test } from 'vitest'; | ||
import { AppService } from '#/app.service.js'; | ||
|
||
describe('AppService', () => { | ||
let appService: AppService; | ||
|
||
beforeEach(async () => { | ||
const module = await Test.createTestingModule({ | ||
providers: [AppService], | ||
}).compile(); | ||
|
||
appService = module.get<AppService>(AppService); | ||
}); | ||
|
||
test('should return "Hello World!"', async () => { | ||
const result = await appService.getHello(); | ||
|
||
expect(result).toBe('Hello World!'); | ||
}); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
|
||
@Injectable() | ||
export class AppService { | ||
async getHello(): Promise<string> { | ||
return 'Hello World!'; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { NestFactory } from '@nestjs/core'; | ||
import { AppModule } from '#/app.module.js'; | ||
|
||
async function bootstrap(): Promise<void> { | ||
const app = await NestFactory.create(AppModule); | ||
await app.listen(3000); | ||
} | ||
bootstrap(); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"compilerOptions": { | ||
"allowJs": true, | ||
"allowSyntheticDefaultImports": true, | ||
"baseUrl": ".", | ||
"declaration": false, | ||
"emitDecoratorMetadata": true, | ||
"esModuleInterop": true, | ||
"experimentalDecorators": true, | ||
"isolatedModules": true, | ||
"lib": ["Dom", "DOM.Iterable", "ESNext", "ESNext.Decorators"], | ||
"module": "NodeNext", | ||
"moduleResolution": "NodeNext", | ||
"noEmit": true, | ||
"outDir": "dist", | ||
"paths": { "#/*": ["./src/*"] }, | ||
"preserveSymlinks": true, | ||
"removeComments": true, | ||
"resolveJsonModule": true, | ||
"rootDir": ".", | ||
"skipLibCheck": true, | ||
"strict": true, | ||
"target": "esnext" | ||
}, | ||
|
||
"exclude": ["node_modules"], | ||
|
||
"include": ["./src/**/*.*", "*.d.ts", "**/*.d.ts", "*.js", "*.ts"] | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import swc from 'unplugin-swc'; | ||
import tsconfigPaths from 'vite-tsconfig-paths'; | ||
import { defineConfig } from 'vitest/config'; | ||
|
||
export default defineConfig({ | ||
plugins: [swc.vite({ module: { type: 'es6' } }), tsconfigPaths()], | ||
test: { | ||
coverage: { | ||
reportsDirectory: 'coverage', | ||
reporter: ['lcov', 'html', 'text'], | ||
all: true, | ||
include: ['src'], | ||
exclude: ['**/*.{test,spec}.?(c|m)[jt]s?(x)', '**/*.d.ts', 'src/index.ts?(x)'], | ||
}, | ||
env: { NODE_ENV: 'test' }, | ||
environment: 'node', | ||
passWithNoTests: true, | ||
setupFiles: ['./vitest.setup.ts'], | ||
}, | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {}; |
Oops, something went wrong.