Initial commit
This commit is contained in:
		
							
								
								
									
										24
									
								
								.eslintrc.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								.eslintrc.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,24 @@ | ||||
| module.exports = { | ||||
|   parser: '@typescript-eslint/parser', | ||||
|   parserOptions: { | ||||
|     project: 'tsconfig.json', | ||||
|     sourceType: 'module', | ||||
|   }, | ||||
|   plugins: ['@typescript-eslint/eslint-plugin'], | ||||
|   extends: [ | ||||
|     'plugin:@typescript-eslint/recommended', | ||||
|     'plugin:prettier/recommended', | ||||
|   ], | ||||
|   root: true, | ||||
|   env: { | ||||
|     node: true, | ||||
|     jest: true, | ||||
|   }, | ||||
|   ignorePatterns: ['.eslintrc.js'], | ||||
|   rules: { | ||||
|     '@typescript-eslint/interface-name-prefix': 'off', | ||||
|     '@typescript-eslint/explicit-function-return-type': 'off', | ||||
|     '@typescript-eslint/explicit-module-boundary-types': 'off', | ||||
|     '@typescript-eslint/no-explicit-any': 'off', | ||||
|   }, | ||||
| }; | ||||
							
								
								
									
										398
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										398
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,398 @@ | ||||
| # Created by .ignore support plugin (hsz.mobi) | ||||
| ### JetBrains template | ||||
| # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm | ||||
| # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 | ||||
|  | ||||
| # User-specific stuff: | ||||
| .idea/**/workspace.xml | ||||
| .idea/**/tasks.xml | ||||
| .idea/dictionaries | ||||
|  | ||||
| # Sensitive or high-churn files: | ||||
| .idea/**/dataSources/ | ||||
| .idea/**/dataSources.ids | ||||
| .idea/**/dataSources.xml | ||||
| .idea/**/dataSources.local.xml | ||||
| .idea/**/sqlDataSources.xml | ||||
| .idea/**/dynamic.xml | ||||
| .idea/**/uiDesigner.xml | ||||
|  | ||||
| # Gradle: | ||||
| .idea/**/gradle.xml | ||||
| .idea/**/libraries | ||||
|  | ||||
| # CMake | ||||
| cmake-build-debug/ | ||||
|  | ||||
| # Mongo Explorer plugin: | ||||
| .idea/**/mongoSettings.xml | ||||
|  | ||||
| ## File-based project format: | ||||
| *.iws | ||||
|  | ||||
| ## Plugin-specific files: | ||||
|  | ||||
| # IntelliJ | ||||
| out/ | ||||
|  | ||||
| # mpeltonen/sbt-idea plugin | ||||
| .idea_modules/ | ||||
|  | ||||
| # JIRA plugin | ||||
| atlassian-ide-plugin.xml | ||||
|  | ||||
| # Cursive Clojure plugin | ||||
| .idea/replstate.xml | ||||
|  | ||||
| # Crashlytics plugin (for Android Studio and IntelliJ) | ||||
| com_crashlytics_export_strings.xml | ||||
| crashlytics.properties | ||||
| crashlytics-build.properties | ||||
| fabric.properties | ||||
| ### VisualStudio template | ||||
| ## Ignore Visual Studio temporary files, build results, and | ||||
| ## files generated by popular Visual Studio add-ons. | ||||
| ## | ||||
| ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore | ||||
|  | ||||
| # User-specific files | ||||
| *.suo | ||||
| *.user | ||||
| *.userosscache | ||||
| *.sln.docstates | ||||
|  | ||||
| # User-specific files (MonoDevelop/Xamarin Studio) | ||||
| *.userprefs | ||||
|  | ||||
| # Build results | ||||
| [Dd]ebug/ | ||||
| [Dd]ebugPublic/ | ||||
| [Rr]elease/ | ||||
| [Rr]eleases/ | ||||
| x64/ | ||||
| x86/ | ||||
| bld/ | ||||
| [Bb]in/ | ||||
| [Oo]bj/ | ||||
| [Ll]og/ | ||||
|  | ||||
| # Visual Studio 2015 cache/options directory | ||||
| .vs/ | ||||
| # Uncomment if you have tasks that create the project's static files in wwwroot | ||||
| #wwwroot/ | ||||
|  | ||||
| # MSTest test Results | ||||
| [Tt]est[Rr]esult*/ | ||||
| [Bb]uild[Ll]og.* | ||||
|  | ||||
| # NUNIT | ||||
| *.VisualState.xml | ||||
| TestResult.xml | ||||
|  | ||||
| # Build Results of an ATL Project | ||||
| [Dd]ebugPS/ | ||||
| [Rr]eleasePS/ | ||||
| dlldata.c | ||||
|  | ||||
| # Benchmark Results | ||||
| BenchmarkDotNet.Artifacts/ | ||||
|  | ||||
| # .NET Core | ||||
| project.lock.json | ||||
| project.fragment.lock.json | ||||
| artifacts/ | ||||
| **/Properties/launchSettings.json | ||||
|  | ||||
| *_i.c | ||||
| *_p.c | ||||
| *_i.h | ||||
| *.ilk | ||||
| *.meta | ||||
| *.obj | ||||
| *.pch | ||||
| *.pdb | ||||
| *.pgc | ||||
| *.pgd | ||||
| *.rsp | ||||
| *.sbr | ||||
| *.tlb | ||||
| *.tli | ||||
| *.tlh | ||||
| *.tmp | ||||
| *.tmp_proj | ||||
| *.log | ||||
| *.vspscc | ||||
| *.vssscc | ||||
| .builds | ||||
| *.pidb | ||||
| *.svclog | ||||
| *.scc | ||||
|  | ||||
| # Chutzpah Test files | ||||
| _Chutzpah* | ||||
|  | ||||
| # Visual C++ cache files | ||||
| ipch/ | ||||
| *.aps | ||||
| *.ncb | ||||
| *.opendb | ||||
| *.opensdf | ||||
| *.sdf | ||||
| *.cachefile | ||||
| *.VC.db | ||||
| *.VC.VC.opendb | ||||
|  | ||||
| # Visual Studio profiler | ||||
| *.psess | ||||
| *.vsp | ||||
| *.vspx | ||||
| *.sap | ||||
|  | ||||
| # Visual Studio Trace Files | ||||
| *.e2e | ||||
|  | ||||
| # TFS 2012 Local Workspace | ||||
| $tf/ | ||||
|  | ||||
| # Guidance Automation Toolkit | ||||
| *.gpState | ||||
|  | ||||
| # ReSharper is a .NET coding add-in | ||||
| _ReSharper*/ | ||||
| *.[Rr]e[Ss]harper | ||||
| *.DotSettings.user | ||||
|  | ||||
| # JustCode is a .NET coding add-in | ||||
| .JustCode | ||||
|  | ||||
| # TeamCity is a build add-in | ||||
| _TeamCity* | ||||
|  | ||||
| # DotCover is a Code Coverage Tool | ||||
| *.dotCover | ||||
|  | ||||
| # AxoCover is a Code Coverage Tool | ||||
| .axoCover/* | ||||
| !.axoCover/settings.json | ||||
|  | ||||
| # Visual Studio code coverage results | ||||
| *.coverage | ||||
| *.coveragexml | ||||
|  | ||||
| # NCrunch | ||||
| _NCrunch_* | ||||
| .*crunch*.local.xml | ||||
| nCrunchTemp_* | ||||
|  | ||||
| # MightyMoose | ||||
| *.mm.* | ||||
| AutoTest.Net/ | ||||
|  | ||||
| # Web workbench (sass) | ||||
| .sass-cache/ | ||||
|  | ||||
| # Installshield output folder | ||||
| [Ee]xpress/ | ||||
|  | ||||
| # DocProject is a documentation generator add-in | ||||
| DocProject/buildhelp/ | ||||
| DocProject/Help/*.HxT | ||||
| DocProject/Help/*.HxC | ||||
| DocProject/Help/*.hhc | ||||
| DocProject/Help/*.hhk | ||||
| DocProject/Help/*.hhp | ||||
| DocProject/Help/Html2 | ||||
| DocProject/Help/html | ||||
|  | ||||
| # Click-Once directory | ||||
| publish/ | ||||
|  | ||||
| # Publish Web Output | ||||
| *.[Pp]ublish.xml | ||||
| *.azurePubxml | ||||
| # Note: Comment the next line if you want to checkin your web deploy settings, | ||||
| # but database connection strings (with potential passwords) will be unencrypted | ||||
| *.pubxml | ||||
| *.publishproj | ||||
|  | ||||
| # Microsoft Azure Web App publish settings. Comment the next line if you want to | ||||
| # checkin your Azure Web App publish settings, but sensitive information contained | ||||
| # in these scripts will be unencrypted | ||||
| PublishScripts/ | ||||
|  | ||||
| # NuGet Packages | ||||
| *.nupkg | ||||
| # The packages folder can be ignored because of Package Restore | ||||
| **/[Pp]ackages/* | ||||
| # except build/, which is used as an MSBuild target. | ||||
| !**/[Pp]ackages/build/ | ||||
| # Uncomment if necessary however generally it will be regenerated when needed | ||||
| #!**/[Pp]ackages/repositories.config | ||||
| # NuGet v3's project.json files produces more ignorable files | ||||
| *.nuget.props | ||||
| *.nuget.targets | ||||
|  | ||||
| # Microsoft Azure Build Output | ||||
| csx/ | ||||
| *.build.csdef | ||||
|  | ||||
| # Microsoft Azure Emulator | ||||
| ecf/ | ||||
| rcf/ | ||||
|  | ||||
| # Windows Store app package directories and files | ||||
| AppPackages/ | ||||
| BundleArtifacts/ | ||||
| Package.StoreAssociation.xml | ||||
| _pkginfo.txt | ||||
| *.appx | ||||
|  | ||||
| # Visual Studio cache files | ||||
| # files ending in .cache can be ignored | ||||
| *.[Cc]ache | ||||
| # but keep track of directories ending in .cache | ||||
| !*.[Cc]ache/ | ||||
|  | ||||
| # Others | ||||
| ClientBin/ | ||||
| ~$* | ||||
| *~ | ||||
| *.dbmdl | ||||
| *.dbproj.schemaview | ||||
| *.jfm | ||||
| *.pfx | ||||
| *.publishsettings | ||||
| orleans.codegen.cs | ||||
|  | ||||
| # Since there are multiple workflows, uncomment next line to ignore bower_components | ||||
| # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) | ||||
| #bower_components/ | ||||
|  | ||||
| # RIA/Silverlight projects | ||||
| Generated_Code/ | ||||
|  | ||||
| # Backup & report files from converting an old project file | ||||
| # to a newer Visual Studio version. Backup files are not needed, | ||||
| # because we have git ;-) | ||||
| _UpgradeReport_Files/ | ||||
| Backup*/ | ||||
| UpgradeLog*.XML | ||||
| UpgradeLog*.htm | ||||
|  | ||||
| # SQL Server files | ||||
| *.mdf | ||||
| *.ldf | ||||
| *.ndf | ||||
|  | ||||
| # Business Intelligence projects | ||||
| *.rdl.data | ||||
| *.bim.layout | ||||
| *.bim_*.settings | ||||
|  | ||||
| # Microsoft Fakes | ||||
| FakesAssemblies/ | ||||
|  | ||||
| # GhostDoc plugin setting file | ||||
| *.GhostDoc.xml | ||||
|  | ||||
| # Node.js Tools for Visual Studio | ||||
| .ntvs_analysis.dat | ||||
| node_modules/ | ||||
|  | ||||
| # Typescript v1 declaration files | ||||
| typings/ | ||||
|  | ||||
| # Visual Studio 6 build log | ||||
| *.plg | ||||
|  | ||||
| # Visual Studio 6 workspace options file | ||||
| *.opt | ||||
|  | ||||
| # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) | ||||
| *.vbw | ||||
|  | ||||
| # Visual Studio LightSwitch build output | ||||
| **/*.HTMLClient/GeneratedArtifacts | ||||
| **/*.DesktopClient/GeneratedArtifacts | ||||
| **/*.DesktopClient/ModelManifest.xml | ||||
| **/*.Server/GeneratedArtifacts | ||||
| **/*.Server/ModelManifest.xml | ||||
| _Pvt_Extensions | ||||
|  | ||||
| # Paket dependency manager | ||||
| .paket/paket.exe | ||||
| paket-files/ | ||||
|  | ||||
| # FAKE - F# Make | ||||
| .fake/ | ||||
|  | ||||
| # JetBrains Rider | ||||
| .idea/ | ||||
| *.sln.iml | ||||
|  | ||||
| # IDE - VSCode | ||||
| .vscode/* | ||||
| !.vscode/settings.json | ||||
| !.vscode/tasks.json | ||||
| !.vscode/launch.json | ||||
| !.vscode/extensions.json | ||||
|  | ||||
| # CodeRush | ||||
| .cr/ | ||||
|  | ||||
| # Python Tools for Visual Studio (PTVS) | ||||
| __pycache__/ | ||||
| *.pyc | ||||
|  | ||||
| # Cake - Uncomment if you are using it | ||||
| # tools/** | ||||
| # !tools/packages.config | ||||
|  | ||||
| # Tabs Studio | ||||
| *.tss | ||||
|  | ||||
| # Telerik's JustMock configuration file | ||||
| *.jmconfig | ||||
|  | ||||
| # BizTalk build output | ||||
| *.btp.cs | ||||
| *.btm.cs | ||||
| *.odx.cs | ||||
| *.xsd.cs | ||||
|  | ||||
| # OpenCover UI analysis results | ||||
| OpenCover/ | ||||
| coverage/ | ||||
|  | ||||
| ### macOS template | ||||
| # General | ||||
| .DS_Store | ||||
| .AppleDouble | ||||
| .LSOverride | ||||
|  | ||||
| # Icon must end with two \r | ||||
| Icon | ||||
|  | ||||
| # Thumbnails | ||||
| ._* | ||||
|  | ||||
| # Files that might appear in the root of a volume | ||||
| .DocumentRevisions-V100 | ||||
| .fseventsd | ||||
| .Spotlight-V100 | ||||
| .TemporaryItems | ||||
| .Trashes | ||||
| .VolumeIcon.icns | ||||
| .com.apple.timemachine.donotpresent | ||||
|  | ||||
| # Directories potentially created on remote AFP share | ||||
| .AppleDB | ||||
| .AppleDesktop | ||||
| Network Trash Folder | ||||
| Temporary Items | ||||
| .apdisk | ||||
|  | ||||
| ======= | ||||
| # Local | ||||
| .env | ||||
| dist | ||||
							
								
								
									
										4
									
								
								.prettierrc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								.prettierrc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,4 @@ | ||||
| { | ||||
|   "singleQuote": true, | ||||
|   "trailingComma": "all" | ||||
| } | ||||
							
								
								
									
										73
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										73
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,73 @@ | ||||
| <p align="center"> | ||||
|   <a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo_text.svg" width="320" alt="Nest Logo" /></a> | ||||
| </p> | ||||
|  | ||||
| [circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456 | ||||
| [circleci-url]: https://circleci.com/gh/nestjs/nest | ||||
|    | ||||
|   <p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p> | ||||
|     <p align="center"> | ||||
| <a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a> | ||||
| <a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a> | ||||
| <a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a> | ||||
| <a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a> | ||||
| <a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a> | ||||
| <a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a> | ||||
| <a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a> | ||||
| <a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a> | ||||
|   <a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a> | ||||
|     <a href="https://opencollective.com/nest#sponsor"  target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a> | ||||
|   <a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a> | ||||
| </p> | ||||
|   <!--[](https://opencollective.com/nest#backer) | ||||
|   [](https://opencollective.com/nest#sponsor)--> | ||||
|  | ||||
| ## Description | ||||
|  | ||||
| [Nest](https://github.com/nestjs/nest) framework TypeScript starter repository. | ||||
|  | ||||
| ## Installation | ||||
|  | ||||
| ```bash | ||||
| $ npm install | ||||
| ``` | ||||
|  | ||||
| ## Running the app | ||||
|  | ||||
| ```bash | ||||
| # development | ||||
| $ npm run start | ||||
|  | ||||
| # watch mode | ||||
| $ npm run start:dev | ||||
|  | ||||
| # production mode | ||||
| $ npm run start:prod | ||||
| ``` | ||||
|  | ||||
| ## Test | ||||
|  | ||||
| ```bash | ||||
| # unit tests | ||||
| $ npm run test | ||||
|  | ||||
| # e2e tests | ||||
| $ npm run test:e2e | ||||
|  | ||||
| # test coverage | ||||
| $ npm run test:cov | ||||
| ``` | ||||
|  | ||||
| ## Support | ||||
|  | ||||
| Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support). | ||||
|  | ||||
| ## Stay in touch | ||||
|  | ||||
| - Author - [Kamil Myśliwiec](https://twitter.com/kammysliwiec) | ||||
| - Website - [https://nestjs.com](https://nestjs.com/) | ||||
| - Twitter - [@nestframework](https://twitter.com/nestframework) | ||||
|  | ||||
| ## License | ||||
|  | ||||
|   Nest is [MIT licensed](https://github.com/nestjs/nest/blob/master/LICENSE). | ||||
							
								
								
									
										13
									
								
								layer/serverless.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								layer/serverless.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,13 @@ | ||||
| org: '1315775011' | ||||
| app: web | ||||
| stage: dev | ||||
| component: layer | ||||
| name: web-layer | ||||
| inputs: | ||||
|   name: web-layer | ||||
|   region: ap-shanghai | ||||
|   src: | ||||
|     src: ../node_modules | ||||
|     targetDir: /node_modules | ||||
|   runtimes: | ||||
|     - Nodejs12.16 | ||||
							
								
								
									
										4
									
								
								nest-cli.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								nest-cli.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,4 @@ | ||||
| { | ||||
|   "collection": "@nestjs/schematics", | ||||
|   "sourceRoot": "src" | ||||
| } | ||||
							
								
								
									
										8758
									
								
								package-lock.json
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										8758
									
								
								package-lock.json
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										74
									
								
								package.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										74
									
								
								package.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,74 @@ | ||||
| { | ||||
|   "name": "serverless-nestjs", | ||||
|   "private": true, | ||||
|   "version": "1.0.0", | ||||
|   "description": "Nest TypeScript starter repository", | ||||
|   "license": "MIT", | ||||
|   "scripts": { | ||||
|     "prebuild": "rimraf dist", | ||||
|     "build": "nest build", | ||||
|     "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", | ||||
|     "start": "nest start", | ||||
|     "start:dev": "nest start --watch", | ||||
|     "start:debug": "nest start --debug --watch", | ||||
|     "start:prod": "node dist/main", | ||||
|     "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", | ||||
|     "test": "jest", | ||||
|     "test:watch": "jest --watch", | ||||
|     "test:cov": "jest --coverage", | ||||
|     "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", | ||||
|     "test:e2e": "jest --config ./test/jest-e2e.json" | ||||
|   }, | ||||
|   "dependencies": { | ||||
|     "@nestjs/common": "^8.0.0", | ||||
|     "@nestjs/core": "^8.0.0", | ||||
|     "@nestjs/platform-express": "^8.0.0", | ||||
|     "@nestjs/typeorm": "^10.0.0", | ||||
|     "hbs": "^4.1.2", | ||||
|     "mssql": "^10.0.1", | ||||
|     "mssql2": "^3.3.1", | ||||
|     "reflect-metadata": "^0.1.13", | ||||
|     "rimraf": "^3.0.2", | ||||
|     "rxjs": "^7.2.0", | ||||
|     "typeorm": "^0.3.17" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|     "@nestjs/cli": "^8.0.0", | ||||
|     "@nestjs/schematics": "^8.0.0", | ||||
|     "@nestjs/testing": "^8.0.0", | ||||
|     "@types/express": "^4.17.13", | ||||
|     "@types/jest": "^26.0.24", | ||||
|     "@types/node": "^16.0.0", | ||||
|     "@types/supertest": "^2.0.11", | ||||
|     "@typescript-eslint/eslint-plugin": "^4.28.2", | ||||
|     "@typescript-eslint/parser": "^4.28.2", | ||||
|     "eslint": "^7.30.0", | ||||
|     "eslint-config-prettier": "^8.3.0", | ||||
|     "eslint-plugin-prettier": "^3.4.0", | ||||
|     "jest": "^27.0.6", | ||||
|     "prettier": "^2.3.2", | ||||
|     "supertest": "^6.1.3", | ||||
|     "ts-jest": "^27.0.3", | ||||
|     "ts-loader": "^9.2.3", | ||||
|     "ts-node": "^10.0.0", | ||||
|     "tsconfig-paths": "^3.10.1", | ||||
|     "typescript": "^4.3.5" | ||||
|   }, | ||||
|   "jest": { | ||||
|     "moduleFileExtensions": [ | ||||
|       "js", | ||||
|       "json", | ||||
|       "ts" | ||||
|     ], | ||||
|     "rootDir": "src", | ||||
|     "testRegex": ".*\\.spec\\.ts$", | ||||
|     "transform": { | ||||
|       "^.+\\.(t|j)s$": "ts-jest" | ||||
|     }, | ||||
|     "collectCoverageFrom": [ | ||||
|       "**/*.(t|j)s" | ||||
|     ], | ||||
|     "coverageDirectory": "../coverage", | ||||
|     "testEnvironment": "node" | ||||
|   } | ||||
| } | ||||
							
								
								
									
										4
									
								
								scf_bootstrap
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										4
									
								
								scf_bootstrap
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,4 @@ | ||||
| #!/bin/bash | ||||
|  | ||||
| # SERVERLESS=1 /var/lang/node12/bin/npm run start -- -e /var/lang/node12/bin/node | ||||
| SERVERLESS=1 /var/lang/node12/bin/node ./dist/main.js | ||||
							
								
								
									
										33
									
								
								serverless.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								serverless.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,33 @@ | ||||
| component: http | ||||
| name: http-nestjs-SkOVVQEtOx | ||||
| inputs: | ||||
|   src: | ||||
|     dist: ./ | ||||
|     hook: npm run build | ||||
|     exclude: | ||||
|       - .env | ||||
|     src: ./ | ||||
|   faas: | ||||
|     runtime: Nodejs12.16 | ||||
|     framework: nestjs | ||||
|     name: '${name}' | ||||
|     eip: false | ||||
|     timeout: 3 | ||||
|     memorySize: 512 | ||||
|     tags: [] | ||||
|     environments: [] | ||||
|     layers: | ||||
|       - name: '${output:${stage}:${app}:web-layer.name}' | ||||
|         version: '${output:${stage}:${app}:web-layer.version}' | ||||
|   apigw: | ||||
|     protocols: | ||||
|       - http | ||||
|       - https | ||||
|     timeout: 60 | ||||
|     environment: release | ||||
|     customDomains: [] | ||||
|   region: ap-shanghai | ||||
|   isAutoCiDeploy: false | ||||
| org: '1315775011' | ||||
| app: web | ||||
| stage: dev | ||||
							
								
								
									
										21
									
								
								src/app.controller.spec.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								src/app.controller.spec.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,21 @@ | ||||
| import { Test, TestingModule } from '@nestjs/testing'; | ||||
| import { AppController } from './app.controller'; | ||||
| import { AppService } from './app.service'; | ||||
|  | ||||
| describe('AppController', () => { | ||||
|     let app: TestingModule; | ||||
|  | ||||
|     beforeAll(async () => { | ||||
|         app = await Test.createTestingModule({ | ||||
|             controllers: [AppController], | ||||
|             providers: [AppService], | ||||
|         }).compile(); | ||||
|     }); | ||||
|  | ||||
|     describe('getHello', () => { | ||||
|         it('should return "Hello World!"', () => { | ||||
|             const appController = app.get<AppController>(AppController); | ||||
|             expect(appController.getHello()).toBe('Hello World!'); | ||||
|         }); | ||||
|     }); | ||||
| }); | ||||
							
								
								
									
										18
									
								
								src/app.controller.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								src/app.controller.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,18 @@ | ||||
| import { Controller, Get, Render } from '@nestjs/common'; | ||||
| import { AppService } from './app.service'; | ||||
|  | ||||
| @Controller() | ||||
| export class AppController { | ||||
|     getHello(): any { | ||||
|         throw new Error('Method not implemented.'); | ||||
|     } | ||||
|     constructor(private readonly appService: AppService) { } | ||||
|  | ||||
|     @Get() | ||||
|     @Render('index') | ||||
|     root() { | ||||
|         return { | ||||
|             message: 'Serverless Framework', | ||||
|         }; | ||||
|     } | ||||
| } | ||||
							
								
								
									
										27
									
								
								src/app.module.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								src/app.module.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,27 @@ | ||||
| import { Module } from '@nestjs/common'; | ||||
| import { AppController } from './app.controller'; | ||||
| import { AppService } from './app.service'; | ||||
| import { TypeOrmModule } from '@nestjs/typeorm' | ||||
| import { Users } from './users/users.entity'; | ||||
|  | ||||
| @Module({ | ||||
|     imports: [], | ||||
|     controllers: [AppController], | ||||
|     providers: [AppService], | ||||
| }) | ||||
|  | ||||
| @Module({ | ||||
|     imports: [ | ||||
|         TypeOrmModule.forRoot({ | ||||
|             type: 'mssql', | ||||
|             host: 'intpointer.com', | ||||
|             port: 1433, | ||||
|             username: 'myh', | ||||
|             password: '20231103#MS_Sql', | ||||
|             database: 'Elm', | ||||
|             entities: [Users], | ||||
|             synchronize: false, | ||||
|         }), | ||||
|     ], | ||||
| }) | ||||
| export class AppModule { } | ||||
							
								
								
									
										8
									
								
								src/app.service.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								src/app.service.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| import { Injectable } from '@nestjs/common'; | ||||
|  | ||||
| @Injectable() | ||||
| export class AppService { | ||||
|     getHello(): string { | ||||
|         return 'Hello World!'; | ||||
|     } | ||||
| } | ||||
							
								
								
									
										16
									
								
								src/main.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								src/main.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,16 @@ | ||||
| import { NestFactory } from '@nestjs/core'; | ||||
| import { NestExpressApplication } from '@nestjs/platform-express' | ||||
| import { join } from 'path'; | ||||
| import { AppModule } from './app.module'; | ||||
|  | ||||
| async function bootstrap() { | ||||
|     const app = await NestFactory.create<NestExpressApplication>(AppModule); | ||||
|     app.enableCors(); | ||||
|     app.setBaseViewsDir(join(__dirname, '..', 'views')); | ||||
|     app.setViewEngine('hbs'); | ||||
|  | ||||
|     app.listen(9000, '0.0.0.0', () => { | ||||
|         console.log(`Server start on http://0.0.0.0:9000`); | ||||
|     }); | ||||
| } | ||||
| bootstrap(); | ||||
							
								
								
									
										6
									
								
								src/users/dto/add-users.dto.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								src/users/dto/add-users.dto.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,6 @@ | ||||
| export class AddUsersDto { | ||||
|     name: string | ||||
|     sex: string | ||||
|     phoneNumber: string | ||||
|     address: string | ||||
| } | ||||
							
								
								
									
										11
									
								
								src/users/users-http.module.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								src/users/users-http.module.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | ||||
| import { Module } from '@nestjs/common'; | ||||
| import { UsersModule } from './users.module'; | ||||
| import { UsersService } from './users.service'; | ||||
| import { UsersController } from './users.controller'; | ||||
|  | ||||
| @Module({ | ||||
|   imports: [UsersModule], | ||||
|   providers: [UsersService], | ||||
|   controllers: [UsersController] | ||||
| }) | ||||
| export class UserHttpModule {} | ||||
							
								
								
									
										39
									
								
								src/users/users.controller.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								src/users/users.controller.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,39 @@ | ||||
| import { | ||||
|     Body, | ||||
|     Controller, | ||||
|     Delete, | ||||
|     Get, | ||||
|     Param, | ||||
|     Post, | ||||
|     ParseIntPipe, | ||||
|     Render, | ||||
| } from '@nestjs/common'; | ||||
| import { UsersService } from "./users.service"; | ||||
| import { Users } from './users.entity'; | ||||
| import { AddUsersDto } from './dto/add-users.dto' | ||||
|  | ||||
| @Controller('Users') | ||||
| export class UsersController { | ||||
|     constructor(private readonly usersService: UsersService) { } | ||||
|  | ||||
|     @Post() | ||||
|     add(@Body() addUsersDto: AddUsersDto): Promise<Users> { | ||||
|         return this.usersService.add(addUsersDto); | ||||
|     } | ||||
|  | ||||
|     @Get() | ||||
|     findAll(): Promise<Users[]> { | ||||
|         return this.usersService.findAll(); | ||||
|     } | ||||
|  | ||||
|     @Get(':id') | ||||
|     findOne(@Param('id', ParseIntPipe) id: number): Promise<Users> { | ||||
|         return this.usersService.findOne(id); | ||||
|     } | ||||
|  | ||||
|     @Delete(':id') | ||||
|     delete(@Param('id') id: number): Promise<void> { | ||||
|         return this.usersService.delete(id); | ||||
|     } | ||||
|  | ||||
| } | ||||
							
								
								
									
										20
									
								
								src/users/users.entity.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								src/users/users.entity.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,20 @@ | ||||
| import { Entity, Column, PrimaryGeneratedColumn } from 'typeorm'; | ||||
|  | ||||
| @Entity() | ||||
| export class Users { | ||||
|     @PrimaryGeneratedColumn() | ||||
|     id: number; | ||||
|  | ||||
|     @Column({ type: 'nvarchar', length: 20 }) | ||||
|     name: string; | ||||
|  | ||||
|     @Column({ type: 'nvarchar', length: 2 }) | ||||
|     sex: string; | ||||
|  | ||||
|     @Column({ type: 'varchar', length: 13 }) | ||||
|     phoneNUmber: string; | ||||
|  | ||||
|     @Column('text') | ||||
|     address: string | ||||
|  | ||||
| } | ||||
							
								
								
									
										12
									
								
								src/users/users.module.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								src/users/users.module.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,12 @@ | ||||
| import { Module } from '@nestjs/common'; | ||||
| import { TypeOrmModule } from '@nestjs/typeorm'; | ||||
| import { UsersService } from './users.service'; | ||||
| import { UsersController } from './users.controller'; | ||||
| import { Users } from './users.entity'; | ||||
|  | ||||
| @Module({ | ||||
|   imports: [TypeOrmModule.forFeature([Users])], | ||||
|   providers: [UsersService], | ||||
|   controllers: [UsersController], | ||||
| }) | ||||
| export class UsersModule {} | ||||
							
								
								
									
										34
									
								
								src/users/users.service.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								src/users/users.service.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,34 @@ | ||||
| import { Injectable } from '@nestjs/common'; | ||||
| import { InjectRepository } from '@nestjs/typeorm'; | ||||
| import { Repository } from 'typeorm'; | ||||
| import { Users } from './users.entity'; | ||||
| import { AddUsersDto } from './dto/add-users.dto'; | ||||
|  | ||||
| @Injectable() | ||||
| export class UsersService { | ||||
|     constructor( | ||||
|         @InjectRepository(Users) | ||||
|         private usersRepository: Repository<Users>, | ||||
|     ) { } | ||||
|  | ||||
|     add(addUsersDto: AddUsersDto): Promise<Users> { | ||||
|         const users = new Users(); | ||||
|         users.name = addUsersDto.name; | ||||
|         users.sex = addUsersDto.sex; | ||||
|         users.phoneNUmber = addUsersDto.phoneNumber; | ||||
|         users.address = addUsersDto.phoneNumber; | ||||
|         return this.usersRepository.save(users); | ||||
|     } | ||||
|  | ||||
|     findAll(): Promise<Users[]> { | ||||
|         return this.usersRepository.find(); | ||||
|     } | ||||
|  | ||||
|     findOne(id: number): Promise<Users | null> { | ||||
|         return this.usersRepository.findOneBy({ id }); | ||||
|     } | ||||
|  | ||||
|     async delete(id: number): Promise<void> { | ||||
|         await this.usersRepository.delete(id); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										4
									
								
								tsconfig.build.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								tsconfig.build.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,4 @@ | ||||
| { | ||||
|   "extends": "./tsconfig.json", | ||||
|   "exclude": ["node_modules", "dist", "test", "**/*spec.ts"] | ||||
| } | ||||
							
								
								
									
										16
									
								
								tsconfig.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								tsconfig.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,16 @@ | ||||
| { | ||||
|   "compilerOptions": { | ||||
|     "module": "commonjs", | ||||
|     "declaration": true, | ||||
|     "removeComments": true, | ||||
|     "emitDecoratorMetadata": true, | ||||
|     "experimentalDecorators": true, | ||||
|     "allowSyntheticDefaultImports": true, | ||||
|     "target": "es2017", | ||||
|     "sourceMap": true, | ||||
|     "outDir": "./dist", | ||||
|     "baseUrl": "./", | ||||
|     "incremental": true, | ||||
|     "skipLibCheck": true | ||||
|   } | ||||
| } | ||||
							
								
								
									
										27
									
								
								views/index.hbs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								views/index.hbs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,27 @@ | ||||
| <!DOCTYPE html> | ||||
| <html lang="en"> | ||||
|   <head> | ||||
|     <meta charset="UTF-8" /> | ||||
|     <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||||
|     <meta name="description" content="Serverless Nest.js 应用"/> | ||||
|     <meta name="keywords" content="Nest,Nest.js,serverless,Serverless,无服务"/> | ||||
|     <title>Serverless - Nest.js</title> | ||||
|     <style lang="css"> | ||||
|       h1 { | ||||
|         text-align: center; | ||||
|         width: 600px; | ||||
|         margin: 300px auto; | ||||
|       } | ||||
|     </style> | ||||
|   </head> | ||||
|   <body> | ||||
|     <h1> | ||||
|       欢迎访问 Nest.js 应用 | ||||
|       <br /> | ||||
|       <a href="https://cloud.tencent.com/product/sls" target="_blank" rel="noopener noreferrer"> | ||||
|         腾讯云 Serverless | ||||
|       </a> | ||||
|       为您提供服务 | ||||
|     </h1> | ||||
|   </body> | ||||
| </html> | ||||
		Reference in New Issue
	
	Block a user