-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
31 changed files
with
3,097 additions
and
165 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,4 @@ | ||
node_modules | ||
build | ||
public/build | ||
postgres-data |
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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
{ | ||
"extends": "@chenyueban" | ||
"extends": "@chenyueban", | ||
"rules": { | ||
"@typescript-eslint/consistent-type-imports": "off" | ||
} | ||
} |
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
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
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,73 @@ | ||
<p align="center"> | ||
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="200" 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> | ||
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer) | ||
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](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://kamilmysliwiec.com) | ||
- Website - [https://nestjs.com](https://nestjs.com/) | ||
- Twitter - [@nestframework](https://twitter.com/nestframework) | ||
|
||
## License | ||
|
||
Nest is [MIT licensed](LICENSE). |
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 @@ | ||
{ | ||
"$schema": "https://json.schemastore.org/nest-cli", | ||
"collection": "@nestjs/schematics", | ||
"sourceRoot": "src" | ||
} |
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,63 @@ | ||
{ | ||
"name": "server", | ||
"private": true, | ||
"sideEffects": false, | ||
"scripts": { | ||
"prebuild": "rimraf dist", | ||
"build": "nest build", | ||
"start": "nest start", | ||
"dev": "nest start --watch", | ||
"dev:debug": "nest start --debug --watch", | ||
"dev:prod": "node dist/main", | ||
"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.4.4", | ||
"@nestjs/core": "^8.4.4", | ||
"@nestjs/mapped-types": "^1.0.1", | ||
"@nestjs/platform-fastify": "^8.4.4", | ||
"@prisma/client": "^3.11.1", | ||
"class-transformer": "^0.5.1", | ||
"class-validator": "^0.13.2", | ||
"reflect-metadata": "^0.1.13", | ||
"rimraf": "^3.0.2", | ||
"rxjs": "^7.5.5" | ||
}, | ||
"devDependencies": { | ||
"@nestjs/cli": "^8.2.5", | ||
"@nestjs/schematics": "^8.0.10", | ||
"@nestjs/testing": "^8.4.4", | ||
"@types/express": "^4.17.13", | ||
"@types/jest": "27.4.1", | ||
"@types/supertest": "^2.0.12", | ||
"jest": "^27.5.1", | ||
"prisma": "^3.11.1", | ||
"source-map-support": "^0.5.21", | ||
"supertest": "^6.2.2", | ||
"ts-jest": "^27.1.4", | ||
"ts-loader": "^9.2.8", | ||
"ts-node": "^10.7.0", | ||
"tsconfig-paths": "^3.14.1" | ||
}, | ||
"jest": { | ||
"moduleFileExtensions": [ | ||
"js", | ||
"json", | ||
"ts" | ||
], | ||
"rootDir": "src", | ||
"testRegex": ".*\\.spec\\.ts$", | ||
"transform": { | ||
"^.+\\.(t|j)s$": "ts-jest" | ||
}, | ||
"collectCoverageFrom": [ | ||
"**/*.(t|j)s" | ||
], | ||
"coverageDirectory": "../coverage", | ||
"testEnvironment": "node" | ||
} | ||
} |
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 @@ | ||
import { Module } from '@nestjs/common' | ||
import { CatsModule } from './cats/cats.module' | ||
|
||
@Module({ imports: [CatsModule] }) | ||
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 type { TestingModule } from '@nestjs/testing' | ||
import { Test } from '@nestjs/testing' | ||
import { CatsController } from './cats.controller' | ||
import { CatsService } from './cats.service' | ||
|
||
describe('CatsController', () => { | ||
let controller: CatsController | ||
|
||
beforeEach(async() => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
controllers: [CatsController], | ||
providers: [CatsService], | ||
}).compile() | ||
|
||
controller = module.get<CatsController>(CatsController) | ||
}) | ||
|
||
it('should be defined', () => { | ||
expect(controller).toBeDefined() | ||
}) | ||
}) |
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,34 @@ | ||
import { Body, Controller, Delete, Get, Param, Patch, Post } from '@nestjs/common' | ||
import { CatsService } from './cats.service' | ||
import { CreateCatDto } from './dto/create-cat.dto' | ||
import { UpdateCatDto } from './dto/update-cat.dto' | ||
|
||
@Controller('cats') | ||
export class CatsController { | ||
constructor(private readonly catsService: CatsService) {} | ||
|
||
@Post() | ||
create(@Body() createCatDto: CreateCatDto) { | ||
return this.catsService.create(createCatDto) | ||
} | ||
|
||
@Get() | ||
findAll() { | ||
return this.catsService.findAll() | ||
} | ||
|
||
@Get(':id') | ||
findOne(@Param('id') id: string) { | ||
return this.catsService.findOne(+id) | ||
} | ||
|
||
@Patch(':id') | ||
update(@Param('id') id: string, @Body() updateCatDto: UpdateCatDto) { | ||
return this.catsService.update(+id, updateCatDto) | ||
} | ||
|
||
@Delete(':id') | ||
remove(@Param('id') id: string) { | ||
return this.catsService.remove(+id) | ||
} | ||
} |
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,9 @@ | ||
import { Module } from '@nestjs/common' | ||
import { CatsService } from './cats.service' | ||
import { CatsController } from './cats.controller' | ||
|
||
@Module({ | ||
controllers: [CatsController], | ||
providers: [CatsService], | ||
}) | ||
export class CatsModule {} |
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,17 @@ | ||
import type { TestingModule } from '@nestjs/testing' | ||
import { Test } from '@nestjs/testing' | ||
import { CatsService } from './cats.service' | ||
|
||
describe('CatsService', () => { | ||
let service: CatsService | ||
|
||
beforeEach(async() => { | ||
const module: TestingModule = await Test.createTestingModule({ providers: [CatsService] }).compile() | ||
|
||
service = module.get<CatsService>(CatsService) | ||
}) | ||
|
||
it('should be defined', () => { | ||
expect(service).toBeDefined() | ||
}) | ||
}) |
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 @@ | ||
import { Injectable } from '@nestjs/common' | ||
import type { CreateCatDto } from './dto/create-cat.dto' | ||
import type { UpdateCatDto } from './dto/update-cat.dto' | ||
|
||
@Injectable() | ||
export class CatsService { | ||
create(createCatDto: CreateCatDto) { | ||
console.warn(createCatDto) | ||
|
||
return 'This action adds a new cat' | ||
} | ||
|
||
findAll() { | ||
return 'This action returns all cats' | ||
} | ||
|
||
findOne(id: number) { | ||
return `This action returns a #${id} cat` | ||
} | ||
|
||
update(id: number, updateCatDto: UpdateCatDto) { | ||
console.warn(updateCatDto) | ||
|
||
return `This action updates a #${id} cat` | ||
} | ||
|
||
remove(id: number) { | ||
return `This action removes a #${id} cat` | ||
} | ||
} |
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 class CreateCatDto {} |
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 @@ | ||
import { PartialType } from '@nestjs/mapped-types' | ||
import { CreateCatDto } from './create-cat.dto' | ||
|
||
export class UpdateCatDto extends PartialType(CreateCatDto) {} |
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 class Cat {} |
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,22 @@ | ||
import { ValidationPipe } from '@nestjs/common' | ||
import { NestFactory } from '@nestjs/core' | ||
import type { NestFastifyApplication } from '@nestjs/platform-fastify' | ||
import { FastifyAdapter } from '@nestjs/platform-fastify' | ||
import { AppModule } from './app.module' | ||
|
||
async function bootstrap() { | ||
const app = await NestFactory.create<NestFastifyApplication>( | ||
AppModule, | ||
new FastifyAdapter(), | ||
) | ||
|
||
app.useGlobalPipes(new ValidationPipe()) | ||
|
||
await app.listen(4000, '0.0.0.0') | ||
console.warn(`Application is running on: ${await app.getUrl()}`) | ||
} | ||
bootstrap() | ||
.catch((error) => { | ||
console.error(error) | ||
process.exit(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,23 @@ | ||
import type { TestingModule } from '@nestjs/testing' | ||
import { Test } from '@nestjs/testing' | ||
import type { INestApplication } from '@nestjs/common' | ||
import * as request from 'supertest' | ||
import { AppModule } from './../src/app.module' | ||
|
||
describe('AppController (e2e)', () => { | ||
let app: INestApplication | ||
|
||
beforeEach(async() => { | ||
const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule] }).compile() | ||
|
||
app = moduleFixture.createNestApplication() | ||
await app.init() | ||
}) | ||
|
||
it('/ (GET)', () => { | ||
return request(app.getHttpServer()) | ||
.get('/') | ||
.expect(200) | ||
.expect('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,9 @@ | ||
{ | ||
"moduleFileExtensions": ["js", "json", "ts"], | ||
"rootDir": ".", | ||
"testEnvironment": "node", | ||
"testRegex": ".e2e-spec.ts$", | ||
"transform": { | ||
"^.+\\.(t|j)s$": "ts-jest" | ||
} | ||
} |
Oops, something went wrong.