Compare commits
19 Commits
d75ea3f2aa
...
main
Author | SHA1 | Date | |
---|---|---|---|
|
5f0afdd23c | ||
|
ad24c4ac05 | ||
964867a3ab | |||
|
15d00ef352 | ||
|
e35ade1f3e | ||
|
3869e64ded | ||
|
9e5e4ae241 | ||
|
0f25746a87 | ||
|
40cec0dae1 | ||
|
7759fd246e | ||
|
d7042fbcc2 | ||
|
0209893e2d | ||
|
8dd7f53f07 | ||
|
7288f4c76c | ||
b9302a7fdf | |||
|
7e08c75d01 | ||
|
c8b48004f0 | ||
|
b87d40ade8 | ||
|
c7dc5314a1 |
61
.gitignore
vendored
61
.gitignore
vendored
@@ -132,4 +132,63 @@ dist
|
||||
.pnp.*
|
||||
|
||||
#보안관련해서..
|
||||
package-lock.json
|
||||
package-lock.json
|
||||
|
||||
# NestJS Ignore
|
||||
|
||||
# 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
|
||||
|
5
catDataMocking/package.json
Normal file → Executable file
5
catDataMocking/package.json
Normal file → Executable file
@@ -8,13 +8,14 @@
|
||||
"devDependencies": {
|
||||
"@types/cors": "^2.8.18",
|
||||
"@types/express": "^5.0.2",
|
||||
"@types/node": "^15.3.0",
|
||||
"@types/node": "^22.15.29",
|
||||
"prettier": "^2.2.1",
|
||||
"tsc": "^2.0.3",
|
||||
"tsc-watch": "^4.2.9",
|
||||
"typescript": "^4.3.4"
|
||||
"typescript": "^4.9.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/webgl2": "^0.0.11",
|
||||
"cors": "^2.8.5",
|
||||
"express": "^5.1.0"
|
||||
}
|
||||
|
@@ -1,76 +1,55 @@
|
||||
import * as express from "express";
|
||||
import * as cors from "cors";
|
||||
|
||||
import { CatType, Cat } from "./app.model";
|
||||
import catsRouter from "./cats/cats.route";
|
||||
|
||||
const app: express.Express = express();
|
||||
const port: number = 8000;
|
||||
class Server {
|
||||
public app: express.Application;
|
||||
|
||||
app.use(cors());
|
||||
constructor() {
|
||||
const app: express.Application = express();
|
||||
this.app = app;
|
||||
}
|
||||
|
||||
// * Logging Middleware
|
||||
app.use((req, res, next) => {
|
||||
console.log(req.rawHeaders[1]);
|
||||
next();
|
||||
});
|
||||
private setRoute() {
|
||||
// * router
|
||||
this.app.use(catsRouter);
|
||||
}
|
||||
|
||||
// * json middleware
|
||||
app.use(express.json());
|
||||
private setMiddleware() {
|
||||
this.app.use(cors());
|
||||
|
||||
// * C
|
||||
app.post("/cats", (req, res) => {
|
||||
try {
|
||||
const data = req.body;
|
||||
Cat.push(data);
|
||||
res.status(200).send({
|
||||
success: true,
|
||||
data: { data },
|
||||
// * Logging Middleware
|
||||
this.app.use((req, res, next) => {
|
||||
console.log(req.rawHeaders[1]);
|
||||
next();
|
||||
});
|
||||
} catch (error) {}
|
||||
});
|
||||
|
||||
// * R
|
||||
app.get("/cats", (req, res) => {
|
||||
try {
|
||||
const cats = Cat;
|
||||
res.status(200).send({
|
||||
success: true,
|
||||
data: { cats },
|
||||
});
|
||||
} catch (error) {
|
||||
res.status(400).send({
|
||||
success: false,
|
||||
error: error.message,
|
||||
// * json middleware
|
||||
this.app.use(express.json());
|
||||
|
||||
this.setRoute();
|
||||
|
||||
// * 404 middleware
|
||||
this.app.use((req, res, next) => {
|
||||
console.log(req.rawHeaders[1]);
|
||||
console.log("This is 404 middleware");
|
||||
res.send({ error: "404 not found error" });
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
app.get("/cats/:id", (req, res) => {
|
||||
try {
|
||||
const params = req.params;
|
||||
const cats = Cat.find((cat) => {
|
||||
return cat.id === params.id;
|
||||
});
|
||||
if (!cats) throw new Error("no matched data");
|
||||
res.status(200).send({
|
||||
success: true,
|
||||
data: { cats },
|
||||
});
|
||||
} catch (error) {
|
||||
res.status(400).send({
|
||||
success: false,
|
||||
error: error.message,
|
||||
public listen() {
|
||||
this.setMiddleware();
|
||||
this.app.listen(port, () => {
|
||||
console.log(`server is on ${port}`);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// * 404 middleware
|
||||
app.use((req, res, next) => {
|
||||
console.log(req.rawHeaders[1]);
|
||||
console.log("This is 404 middleware");
|
||||
res.send({ error: "404 not found error" });
|
||||
});
|
||||
function init() {
|
||||
const server = new Server();
|
||||
server.listen();
|
||||
}
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(`server is on ${port}`);
|
||||
});
|
||||
init();
|
||||
|
21
catDataMocking/src/cats/cats.route.ts
Normal file
21
catDataMocking/src/cats/cats.route.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { Router } from "express";
|
||||
import { CatType, Cat } from "./cats.model";
|
||||
import {
|
||||
createCat,
|
||||
deleteCat,
|
||||
readAllCat,
|
||||
readCat,
|
||||
updateCat,
|
||||
updatePartialCat,
|
||||
} from "./cats.service";
|
||||
|
||||
const router = Router();
|
||||
|
||||
router.post("/cats", createCat);
|
||||
router.get("/cats", readAllCat);
|
||||
router.get("/cats/:id", readCat);
|
||||
router.put("/cats/:id", updateCat);
|
||||
router.patch("/cats/:id", updatePartialCat);
|
||||
router.delete("/cats/:id", deleteCat);
|
||||
|
||||
export default router;
|
120
catDataMocking/src/cats/cats.service.ts
Normal file
120
catDataMocking/src/cats/cats.service.ts
Normal file
@@ -0,0 +1,120 @@
|
||||
import { Request, Response } from "express";
|
||||
import { CatType, Cat } from "./cats.model";
|
||||
|
||||
// * C
|
||||
export const createCat = (req: Request, res: Response) => {
|
||||
try {
|
||||
const data = req.body;
|
||||
Cat.push(data);
|
||||
res.status(200).send({
|
||||
success: true,
|
||||
data: { data },
|
||||
});
|
||||
} catch (error: any) {}
|
||||
};
|
||||
|
||||
// * R
|
||||
export const readAllCat = (req: Request, res: Response) => {
|
||||
try {
|
||||
const cats = Cat;
|
||||
res.status(200).send({
|
||||
success: true,
|
||||
data: { cats },
|
||||
});
|
||||
} catch (error: any) {
|
||||
res.status(400).send({
|
||||
success: false,
|
||||
error: error.message,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const readCat = (req: Request, res: Response) => {
|
||||
try {
|
||||
const params = req.params;
|
||||
const cats = Cat.find((cat) => {
|
||||
return cat.id === params.id;
|
||||
});
|
||||
if (!cats) throw new Error("no matched data");
|
||||
res.status(200).send({
|
||||
success: true,
|
||||
data: { cats },
|
||||
});
|
||||
} catch (error: any) {
|
||||
res.status(400).send({
|
||||
success: false,
|
||||
error: error.message,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// * U
|
||||
export const updateCat = (req: Request, res: Response) => {
|
||||
try {
|
||||
const params = req.params;
|
||||
const body = req.body;
|
||||
let result;
|
||||
const index = Cat.findIndex((cat) => cat.id === params.id);
|
||||
if (index !== -1) {
|
||||
const tempId = params.id;
|
||||
const newCat = { ...body, id: tempId };
|
||||
Cat[index] = newCat;
|
||||
result = newCat;
|
||||
}
|
||||
res.status(200).send({
|
||||
success: true,
|
||||
data: { cat: result },
|
||||
});
|
||||
} catch (error: any) {
|
||||
res.status(400).send({
|
||||
success: false,
|
||||
error: error.message,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const updatePartialCat = (req: Request, res: Response) => {
|
||||
try {
|
||||
const params = req.params;
|
||||
const body = req.body;
|
||||
let result;
|
||||
const index = Cat.findIndex((cat) => cat.id === params.id);
|
||||
if (index !== -1) {
|
||||
const tempId = params.id;
|
||||
const newCat = { ...Cat[index], ...body, id: tempId };
|
||||
Cat[index] = newCat;
|
||||
result = newCat;
|
||||
}
|
||||
res.status(200).send({
|
||||
success: true,
|
||||
data: { cat: result },
|
||||
});
|
||||
} catch (error: any) {
|
||||
res.status(400).send({
|
||||
success: false,
|
||||
error: error.message,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// * D
|
||||
export const deleteCat = (req: Request, res: Response) => {
|
||||
try {
|
||||
const params = req.params;
|
||||
const body = req.body;
|
||||
let result;
|
||||
const index = Cat.findIndex((cat) => cat.id === params.id);
|
||||
if (index !== -1) {
|
||||
Cat.splice(index, 1);
|
||||
}
|
||||
res.status(200).send({
|
||||
success: true,
|
||||
data: { cat: result },
|
||||
});
|
||||
} catch (error: any) {
|
||||
res.status(400).send({
|
||||
success: false,
|
||||
error: error.message,
|
||||
});
|
||||
}
|
||||
};
|
4
nest-start/.prettierrc
Normal file
4
nest-start/.prettierrc
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"singleQuote": false,
|
||||
"trailingComma": "all",
|
||||
}
|
98
nest-start/README.md
Normal file
98
nest-start/README.md
Normal file
@@ -0,0 +1,98 @@
|
||||
<p align="center">
|
||||
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" 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://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" alt="Donate us"/></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" alt="Follow us on Twitter"></a>
|
||||
</p>
|
||||
<!--[](https://opencollective.com/nest#backer)
|
||||
[](https://opencollective.com/nest#sponsor)-->
|
||||
|
||||
## Description
|
||||
|
||||
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
|
||||
|
||||
## Project setup
|
||||
|
||||
```bash
|
||||
$ npm install
|
||||
```
|
||||
|
||||
## Compile and run the project
|
||||
|
||||
```bash
|
||||
# development
|
||||
$ npm run start
|
||||
|
||||
# watch mode
|
||||
$ npm run start:dev
|
||||
|
||||
# production mode
|
||||
$ npm run start:prod
|
||||
```
|
||||
|
||||
## Run tests
|
||||
|
||||
```bash
|
||||
# unit tests
|
||||
$ npm run test
|
||||
|
||||
# e2e tests
|
||||
$ npm run test:e2e
|
||||
|
||||
# test coverage
|
||||
$ npm run test:cov
|
||||
```
|
||||
|
||||
## Deployment
|
||||
|
||||
When you're ready to deploy your NestJS application to production, there are some key steps you can take to ensure it runs as efficiently as possible. Check out the [deployment documentation](https://docs.nestjs.com/deployment) for more information.
|
||||
|
||||
If you are looking for a cloud-based platform to deploy your NestJS application, check out [Mau](https://mau.nestjs.com), our official platform for deploying NestJS applications on AWS. Mau makes deployment straightforward and fast, requiring just a few simple steps:
|
||||
|
||||
```bash
|
||||
$ npm install -g @nestjs/mau
|
||||
$ mau deploy
|
||||
```
|
||||
|
||||
With Mau, you can deploy your application in just a few clicks, allowing you to focus on building features rather than managing infrastructure.
|
||||
|
||||
## Resources
|
||||
|
||||
Check out a few resources that may come in handy when working with NestJS:
|
||||
|
||||
- Visit the [NestJS Documentation](https://docs.nestjs.com) to learn more about the framework.
|
||||
- For questions and support, please visit our [Discord channel](https://discord.gg/G7Qnnhy).
|
||||
- To dive deeper and get more hands-on experience, check out our official video [courses](https://courses.nestjs.com/).
|
||||
- Deploy your application to AWS with the help of [NestJS Mau](https://mau.nestjs.com) in just a few clicks.
|
||||
- Visualize your application graph and interact with the NestJS application in real-time using [NestJS Devtools](https://devtools.nestjs.com).
|
||||
- Need help with your project (part-time to full-time)? Check out our official [enterprise support](https://enterprise.nestjs.com).
|
||||
- To stay in the loop and get updates, follow us on [X](https://x.com/nestframework) and [LinkedIn](https://linkedin.com/company/nestjs).
|
||||
- Looking for a job, or have a job to offer? Check out our official [Jobs board](https://jobs.nestjs.com).
|
||||
|
||||
## 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).
|
35
nest-start/eslint.config.mjs
Normal file
35
nest-start/eslint.config.mjs
Normal file
@@ -0,0 +1,35 @@
|
||||
// @ts-check
|
||||
import eslint from '@eslint/js';
|
||||
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
|
||||
import globals from 'globals';
|
||||
import tseslint from 'typescript-eslint';
|
||||
|
||||
export default tseslint.config(
|
||||
{
|
||||
ignores: ['eslint.config.mjs'],
|
||||
},
|
||||
eslint.configs.recommended,
|
||||
...tseslint.configs.recommendedTypeChecked,
|
||||
eslintPluginPrettierRecommended,
|
||||
{
|
||||
languageOptions: {
|
||||
globals: {
|
||||
...globals.node,
|
||||
...globals.jest,
|
||||
},
|
||||
sourceType: 'commonjs',
|
||||
parserOptions: {
|
||||
projectService: true,
|
||||
tsconfigRootDir: import.meta.dirname,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
rules: {
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
'@typescript-eslint/no-floating-promises': 'warn',
|
||||
'@typescript-eslint/no-unsafe-argument': 'warn',
|
||||
'prettier/prettier': ['error', { endOfLine: 'auto', singleQuote: false }],
|
||||
},
|
||||
},
|
||||
);
|
8
nest-start/nest-cli.json
Normal file
8
nest-start/nest-cli.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/nest-cli",
|
||||
"collection": "@nestjs/schematics",
|
||||
"sourceRoot": "src",
|
||||
"compilerOptions": {
|
||||
"deleteOutDir": true
|
||||
}
|
||||
}
|
73
nest-start/package.json
Normal file
73
nest-start/package.json
Normal file
@@ -0,0 +1,73 @@
|
||||
{
|
||||
"name": "nest-start",
|
||||
"version": "0.0.1",
|
||||
"description": "",
|
||||
"author": "",
|
||||
"private": true,
|
||||
"license": "UNLICENSED",
|
||||
"scripts": {
|
||||
"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": "^11.0.1",
|
||||
"@nestjs/core": "^11.0.1",
|
||||
"@nestjs/platform-express": "^11.0.1",
|
||||
"reflect-metadata": "^0.2.2",
|
||||
"rxjs": "^7.8.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/eslintrc": "^3.2.0",
|
||||
"@eslint/js": "^9.18.0",
|
||||
"@nestjs/cli": "^11.0.0",
|
||||
"@nestjs/schematics": "^11.0.0",
|
||||
"@nestjs/testing": "^11.0.1",
|
||||
"@swc/cli": "^0.6.0",
|
||||
"@swc/core": "^1.10.7",
|
||||
"@types/express": "^5.0.0",
|
||||
"@types/jest": "^29.5.14",
|
||||
"@types/node": "^22.10.7",
|
||||
"@types/supertest": "^6.0.2",
|
||||
"eslint": "^9.18.0",
|
||||
"eslint-config-prettier": "^10.0.1",
|
||||
"eslint-plugin-prettier": "^5.2.2",
|
||||
"globals": "^16.0.0",
|
||||
"jest": "^29.7.0",
|
||||
"prettier": "^3.4.2",
|
||||
"source-map-support": "^0.5.21",
|
||||
"supertest": "^7.0.0",
|
||||
"ts-jest": "^29.2.5",
|
||||
"ts-loader": "^9.5.2",
|
||||
"ts-node": "^10.9.2",
|
||||
"tsconfig-paths": "^4.2.0",
|
||||
"typescript": "^5.7.3",
|
||||
"typescript-eslint": "^8.20.0"
|
||||
},
|
||||
"jest": {
|
||||
"moduleFileExtensions": [
|
||||
"js",
|
||||
"json",
|
||||
"ts"
|
||||
],
|
||||
"rootDir": "src",
|
||||
"testRegex": ".*\\.spec\\.ts$",
|
||||
"transform": {
|
||||
"^.+\\.(t|j)s$": "ts-jest"
|
||||
},
|
||||
"collectCoverageFrom": [
|
||||
"**/*.(t|j)s"
|
||||
],
|
||||
"coverageDirectory": "../coverage",
|
||||
"testEnvironment": "node"
|
||||
}
|
||||
}
|
22
nest-start/src/app.controller.spec.ts
Normal file
22
nest-start/src/app.controller.spec.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Test, TestingModule } from "@nestjs/testing";
|
||||
import { AppController } from "./app.controller";
|
||||
import { AppService } from "./app.service";
|
||||
|
||||
describe("AppController", () => {
|
||||
let appController: AppController;
|
||||
|
||||
beforeEach(async () => {
|
||||
const app: TestingModule = await Test.createTestingModule({
|
||||
controllers: [AppController],
|
||||
providers: [AppService],
|
||||
}).compile();
|
||||
|
||||
appController = app.get<AppController>(AppController);
|
||||
});
|
||||
|
||||
describe("root", () => {
|
||||
it('should return "Hello World!"', () => {
|
||||
expect(appController.getHello()).toBe("Hello World!");
|
||||
});
|
||||
});
|
||||
});
|
17
nest-start/src/app.controller.ts
Normal file
17
nest-start/src/app.controller.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { Body, Controller, Get } from "@nestjs/common";
|
||||
import { AppService } from "./app.service";
|
||||
import { CatsService } from "./cats/cats.service";
|
||||
|
||||
@Controller("")
|
||||
export class AppController {
|
||||
constructor(
|
||||
private readonly appService: AppService,
|
||||
private readonly catsService: CatsService,
|
||||
) {}
|
||||
|
||||
@Get()
|
||||
getHello(): string {
|
||||
// return this.appService.getHello();
|
||||
return this.catsService.hiCatServiceProduct();
|
||||
}
|
||||
}
|
16
nest-start/src/app.module.ts
Normal file
16
nest-start/src/app.module.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { MiddlewareConsumer, Module, NestModule } from "@nestjs/common";
|
||||
import { AppController } from "./app.controller";
|
||||
import { AppService } from "./app.service";
|
||||
import { CatsModule } from "./cats/cats.module";
|
||||
import { LoggerMiddleware } from "./logger/logger.middleware";
|
||||
|
||||
@Module({
|
||||
imports: [CatsModule],
|
||||
controllers: [AppController],
|
||||
providers: [AppService],
|
||||
})
|
||||
export class AppModule implements NestModule {
|
||||
configure(consumer: MiddlewareConsumer) {
|
||||
consumer.apply(LoggerMiddleware).forRoutes("*");
|
||||
}
|
||||
}
|
8
nest-start/src/app.service.ts
Normal file
8
nest-start/src/app.service.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { Injectable } from "@nestjs/common";
|
||||
|
||||
@Injectable()
|
||||
export class AppService {
|
||||
getHello(): string {
|
||||
return "Hello World!";
|
||||
}
|
||||
}
|
18
nest-start/src/cats/cats.controller.spec.ts
Normal file
18
nest-start/src/cats/cats.controller.spec.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { Test, TestingModule } from "@nestjs/testing";
|
||||
import { CatsController } from "./cats.controller";
|
||||
|
||||
describe("CatsController", () => {
|
||||
let controller: CatsController;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
controllers: [CatsController],
|
||||
}).compile();
|
||||
|
||||
controller = module.get<CatsController>(CatsController);
|
||||
});
|
||||
|
||||
it("should be defined", () => {
|
||||
expect(controller).toBeDefined();
|
||||
});
|
||||
});
|
54
nest-start/src/cats/cats.controller.ts
Normal file
54
nest-start/src/cats/cats.controller.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import {
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
HttpException,
|
||||
HttpStatus,
|
||||
Patch,
|
||||
Post,
|
||||
Put,
|
||||
UseFilters,
|
||||
} from "@nestjs/common";
|
||||
import { CatsService } from "./cats.service";
|
||||
import { HttpExceptionFilter } from "src/http-exception.filter";
|
||||
|
||||
@Controller("cats")
|
||||
export class CatsController {
|
||||
constructor(private readonly catsService: CatsService) {}
|
||||
|
||||
@Get()
|
||||
@UseFilters(HttpExceptionFilter)
|
||||
getAllCat() {
|
||||
// throw new HttpException(
|
||||
// { customized: true, success: false, message: "api is broken" },
|
||||
// HttpStatus.UNAUTHORIZED,
|
||||
// );
|
||||
throw new HttpException("api is broken", HttpStatus.UNAUTHORIZED);
|
||||
return "all cat";
|
||||
}
|
||||
|
||||
@Get(":id")
|
||||
getOneGat() {
|
||||
return "one cat";
|
||||
}
|
||||
|
||||
@Post()
|
||||
createCat() {
|
||||
return "create cat";
|
||||
}
|
||||
|
||||
@Put(":id")
|
||||
updateCat() {
|
||||
return "update cat";
|
||||
}
|
||||
|
||||
@Patch(":id")
|
||||
updatePartialCat() {
|
||||
return "update partial cat";
|
||||
}
|
||||
|
||||
@Delete(":id")
|
||||
deleteCat() {
|
||||
return "delete cat";
|
||||
}
|
||||
}
|
10
nest-start/src/cats/cats.module.ts
Normal file
10
nest-start/src/cats/cats.module.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Module } from "@nestjs/common";
|
||||
import { CatsController } from "./cats.controller";
|
||||
import { CatsService } from "./cats.service";
|
||||
|
||||
@Module({
|
||||
controllers: [CatsController],
|
||||
providers: [CatsService],
|
||||
exports: [CatsService],
|
||||
})
|
||||
export class CatsModule {}
|
18
nest-start/src/cats/cats.service.spec.ts
Normal file
18
nest-start/src/cats/cats.service.spec.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { Test, TestingModule } 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();
|
||||
});
|
||||
});
|
8
nest-start/src/cats/cats.service.ts
Normal file
8
nest-start/src/cats/cats.service.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { Injectable } from "@nestjs/common";
|
||||
|
||||
@Injectable()
|
||||
export class CatsService {
|
||||
hiCatServiceProduct() {
|
||||
return "hello cat!";
|
||||
}
|
||||
}
|
34
nest-start/src/http-exception.filter.ts
Normal file
34
nest-start/src/http-exception.filter.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import {
|
||||
ArgumentsHost,
|
||||
Catch,
|
||||
ExceptionFilter,
|
||||
HttpException,
|
||||
} from "@nestjs/common";
|
||||
import { Response, Request } from "express";
|
||||
|
||||
@Catch(HttpException)
|
||||
export class HttpExceptionFilter implements ExceptionFilter {
|
||||
catch(exception: HttpException, host: ArgumentsHost) {
|
||||
const ctx = host.switchToHttp();
|
||||
const response = ctx.getResponse<Response>();
|
||||
const request = ctx.getRequest<Request>();
|
||||
const status = exception.getStatus();
|
||||
const error = exception.getResponse() as
|
||||
| string
|
||||
| { error: string; statusCode: number; message: string | string[] };
|
||||
|
||||
if (typeof error === "string") {
|
||||
response.status(status).json({
|
||||
timestamp: new Date().toISOString(),
|
||||
path: request.url,
|
||||
error,
|
||||
});
|
||||
} else {
|
||||
response.status(status).json({
|
||||
timestamp: new Date().toISOString(),
|
||||
path: request.url,
|
||||
...error,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
7
nest-start/src/logger/logger.middleware.spec.ts
Normal file
7
nest-start/src/logger/logger.middleware.spec.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { LoggerMiddleware } from './logger.middleware';
|
||||
|
||||
describe('LoggerMiddleware', () => {
|
||||
it('should be defined', () => {
|
||||
expect(new LoggerMiddleware()).toBeDefined();
|
||||
});
|
||||
});
|
17
nest-start/src/logger/logger.middleware.ts
Normal file
17
nest-start/src/logger/logger.middleware.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { Injectable, Logger, NestMiddleware } from "@nestjs/common";
|
||||
import { Request, Response, NextFunction } from "express";
|
||||
|
||||
@Injectable()
|
||||
export class LoggerMiddleware implements NestMiddleware {
|
||||
private logger = new Logger("HTTP");
|
||||
|
||||
use(req: Request, res: Response, next: NextFunction) {
|
||||
res.on("finish", () => {
|
||||
this.logger.log(
|
||||
`${req.ip} ${req.method} ${res.statusCode} ${req.originalUrl}`,
|
||||
);
|
||||
});
|
||||
|
||||
next();
|
||||
}
|
||||
}
|
11
nest-start/src/main.ts
Normal file
11
nest-start/src/main.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { NestFactory } from "@nestjs/core";
|
||||
import { AppModule } from "./app.module";
|
||||
import { HttpExceptionFilter } from "./http-exception.filter";
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
app.enableCors();
|
||||
app.useGlobalFilters(new HttpExceptionFilter());
|
||||
await app.listen(process.env.PORT ?? 8000);
|
||||
}
|
||||
bootstrap();
|
4
nest-start/src/users/users.module.ts
Normal file
4
nest-start/src/users/users.module.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
|
||||
@Module({})
|
||||
export class UsersModule {}
|
25
nest-start/test/app.e2e-spec.ts
Normal file
25
nest-start/test/app.e2e-spec.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import * as request from 'supertest';
|
||||
import { App } from 'supertest/types';
|
||||
import { AppModule } from './../src/app.module';
|
||||
|
||||
describe('AppController (e2e)', () => {
|
||||
let app: INestApplication<App>;
|
||||
|
||||
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!');
|
||||
});
|
||||
});
|
9
nest-start/test/jest-e2e.json
Normal file
9
nest-start/test/jest-e2e.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"moduleFileExtensions": ["js", "json", "ts"],
|
||||
"rootDir": ".",
|
||||
"testEnvironment": "node",
|
||||
"testRegex": ".e2e-spec.ts$",
|
||||
"transform": {
|
||||
"^.+\\.(t|j)s$": "ts-jest"
|
||||
}
|
||||
}
|
4
nest-start/tsconfig.build.json
Normal file
4
nest-start/tsconfig.build.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
|
||||
}
|
21
nest-start/tsconfig.json
Normal file
21
nest-start/tsconfig.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"declaration": true,
|
||||
"removeComments": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"target": "ES2023",
|
||||
"sourceMap": true,
|
||||
"outDir": "./dist",
|
||||
"baseUrl": "./",
|
||||
"incremental": true,
|
||||
"skipLibCheck": true,
|
||||
"strictNullChecks": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noImplicitAny": false,
|
||||
"strictBindCallApply": false,
|
||||
"noFallthroughCasesInSwitch": false
|
||||
}
|
||||
}
|
4
nest-user-api/.prettierrc
Normal file
4
nest-user-api/.prettierrc
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"singleQuote": true,
|
||||
"trailingComma": "all"
|
||||
}
|
98
nest-user-api/README.md
Normal file
98
nest-user-api/README.md
Normal file
@@ -0,0 +1,98 @@
|
||||
<p align="center">
|
||||
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" 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://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" alt="Donate us"/></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" alt="Follow us on Twitter"></a>
|
||||
</p>
|
||||
<!--[](https://opencollective.com/nest#backer)
|
||||
[](https://opencollective.com/nest#sponsor)-->
|
||||
|
||||
## Description
|
||||
|
||||
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
|
||||
|
||||
## Project setup
|
||||
|
||||
```bash
|
||||
$ npm install
|
||||
```
|
||||
|
||||
## Compile and run the project
|
||||
|
||||
```bash
|
||||
# development
|
||||
$ npm run start
|
||||
|
||||
# watch mode
|
||||
$ npm run start:dev
|
||||
|
||||
# production mode
|
||||
$ npm run start:prod
|
||||
```
|
||||
|
||||
## Run tests
|
||||
|
||||
```bash
|
||||
# unit tests
|
||||
$ npm run test
|
||||
|
||||
# e2e tests
|
||||
$ npm run test:e2e
|
||||
|
||||
# test coverage
|
||||
$ npm run test:cov
|
||||
```
|
||||
|
||||
## Deployment
|
||||
|
||||
When you're ready to deploy your NestJS application to production, there are some key steps you can take to ensure it runs as efficiently as possible. Check out the [deployment documentation](https://docs.nestjs.com/deployment) for more information.
|
||||
|
||||
If you are looking for a cloud-based platform to deploy your NestJS application, check out [Mau](https://mau.nestjs.com), our official platform for deploying NestJS applications on AWS. Mau makes deployment straightforward and fast, requiring just a few simple steps:
|
||||
|
||||
```bash
|
||||
$ npm install -g @nestjs/mau
|
||||
$ mau deploy
|
||||
```
|
||||
|
||||
With Mau, you can deploy your application in just a few clicks, allowing you to focus on building features rather than managing infrastructure.
|
||||
|
||||
## Resources
|
||||
|
||||
Check out a few resources that may come in handy when working with NestJS:
|
||||
|
||||
- Visit the [NestJS Documentation](https://docs.nestjs.com) to learn more about the framework.
|
||||
- For questions and support, please visit our [Discord channel](https://discord.gg/G7Qnnhy).
|
||||
- To dive deeper and get more hands-on experience, check out our official video [courses](https://courses.nestjs.com/).
|
||||
- Deploy your application to AWS with the help of [NestJS Mau](https://mau.nestjs.com) in just a few clicks.
|
||||
- Visualize your application graph and interact with the NestJS application in real-time using [NestJS Devtools](https://devtools.nestjs.com).
|
||||
- Need help with your project (part-time to full-time)? Check out our official [enterprise support](https://enterprise.nestjs.com).
|
||||
- To stay in the loop and get updates, follow us on [X](https://x.com/nestframework) and [LinkedIn](https://linkedin.com/company/nestjs).
|
||||
- Looking for a job, or have a job to offer? Check out our official [Jobs board](https://jobs.nestjs.com).
|
||||
|
||||
## 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).
|
14
nest-user-api/data-source.ts
Executable file
14
nest-user-api/data-source.ts
Executable file
@@ -0,0 +1,14 @@
|
||||
import { DataSource } from "typeorm";
|
||||
|
||||
export default new DataSource({
|
||||
type: 'mysql',
|
||||
host: 'localhost',
|
||||
port: 3306,
|
||||
username: 'root',
|
||||
password: 'init00!!',
|
||||
database: 'test_db',
|
||||
entities: ['src/**/*.entity.ts'],
|
||||
migrations: ['src/database/migrations/*.ts'],
|
||||
migrationsTableName: 'migrations',
|
||||
synchronize: false
|
||||
});
|
34
nest-user-api/eslint.config.mjs
Normal file
34
nest-user-api/eslint.config.mjs
Normal file
@@ -0,0 +1,34 @@
|
||||
// @ts-check
|
||||
import eslint from '@eslint/js';
|
||||
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
|
||||
import globals from 'globals';
|
||||
import tseslint from 'typescript-eslint';
|
||||
|
||||
export default tseslint.config(
|
||||
{
|
||||
ignores: ['eslint.config.mjs'],
|
||||
},
|
||||
eslint.configs.recommended,
|
||||
...tseslint.configs.recommendedTypeChecked,
|
||||
eslintPluginPrettierRecommended,
|
||||
{
|
||||
languageOptions: {
|
||||
globals: {
|
||||
...globals.node,
|
||||
...globals.jest,
|
||||
},
|
||||
sourceType: 'commonjs',
|
||||
parserOptions: {
|
||||
projectService: true,
|
||||
tsconfigRootDir: import.meta.dirname,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
rules: {
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
'@typescript-eslint/no-floating-promises': 'warn',
|
||||
'@typescript-eslint/no-unsafe-argument': 'warn'
|
||||
},
|
||||
},
|
||||
);
|
8
nest-user-api/nest-cli.json
Normal file
8
nest-user-api/nest-cli.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/nest-cli",
|
||||
"collection": "@nestjs/schematics",
|
||||
"sourceRoot": "src",
|
||||
"compilerOptions": {
|
||||
"deleteOutDir": true
|
||||
}
|
||||
}
|
81
nest-user-api/package.json
Executable file
81
nest-user-api/package.json
Executable file
@@ -0,0 +1,81 @@
|
||||
{
|
||||
"name": "nest-user-api",
|
||||
"version": "0.0.1",
|
||||
"description": "",
|
||||
"author": "",
|
||||
"private": true,
|
||||
"license": "UNLICENSED",
|
||||
"scripts": {
|
||||
"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",
|
||||
"typeorm": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js --dataSource ./data-source.ts",
|
||||
"migration:create": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js migration:create ./src/database/migrations/Migration",
|
||||
"migration:generate": "npm run typeorm migration:generate ./src/database/migrations/Migration",
|
||||
"migration:run": "npm run typeorm migration:run",
|
||||
"migration:revert": "npm run typeorm migration:revert"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "^11.0.1",
|
||||
"@nestjs/core": "^11.0.1",
|
||||
"@nestjs/platform-express": "^11.0.1",
|
||||
"@nestjs/typeorm": "^11.0.0",
|
||||
"mysql2": "^3.14.1",
|
||||
"reflect-metadata": "^0.2.2",
|
||||
"rxjs": "^7.8.1",
|
||||
"typeorm": "^0.3.25"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/eslintrc": "^3.2.0",
|
||||
"@eslint/js": "^9.18.0",
|
||||
"@nestjs/cli": "^11.0.0",
|
||||
"@nestjs/schematics": "^11.0.0",
|
||||
"@nestjs/testing": "^11.0.1",
|
||||
"@swc/cli": "^0.6.0",
|
||||
"@swc/core": "^1.10.7",
|
||||
"@types/express": "^5.0.0",
|
||||
"@types/jest": "^29.5.14",
|
||||
"@types/node": "^22.10.7",
|
||||
"@types/supertest": "^6.0.2",
|
||||
"eslint": "^9.18.0",
|
||||
"eslint-config-prettier": "^10.0.1",
|
||||
"eslint-plugin-prettier": "^5.2.2",
|
||||
"globals": "^16.0.0",
|
||||
"jest": "^29.7.0",
|
||||
"prettier": "^3.4.2",
|
||||
"source-map-support": "^0.5.21",
|
||||
"supertest": "^7.0.0",
|
||||
"ts-jest": "^29.2.5",
|
||||
"ts-loader": "^9.5.2",
|
||||
"ts-node": "^10.9.2",
|
||||
"tsconfig-paths": "^4.2.0",
|
||||
"typescript": "^5.7.3",
|
||||
"typescript-eslint": "^8.20.0"
|
||||
},
|
||||
"jest": {
|
||||
"moduleFileExtensions": [
|
||||
"js",
|
||||
"json",
|
||||
"ts"
|
||||
],
|
||||
"rootDir": "src",
|
||||
"testRegex": ".*\\.spec\\.ts$",
|
||||
"transform": {
|
||||
"^.+\\.(t|j)s$": "ts-jest"
|
||||
},
|
||||
"collectCoverageFrom": [
|
||||
"**/*.(t|j)s"
|
||||
],
|
||||
"coverageDirectory": "../coverage",
|
||||
"testEnvironment": "node"
|
||||
}
|
||||
}
|
22
nest-user-api/src/app.controller.spec.ts
Normal file
22
nest-user-api/src/app.controller.spec.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { AppController } from './app.controller';
|
||||
import { AppService } from './app.service';
|
||||
|
||||
describe('AppController', () => {
|
||||
let appController: AppController;
|
||||
|
||||
beforeEach(async () => {
|
||||
const app: TestingModule = await Test.createTestingModule({
|
||||
controllers: [AppController],
|
||||
providers: [AppService],
|
||||
}).compile();
|
||||
|
||||
appController = app.get<AppController>(AppController);
|
||||
});
|
||||
|
||||
describe('root', () => {
|
||||
it('should return "Hello World!"', () => {
|
||||
expect(appController.getHello()).toBe('Hello World!');
|
||||
});
|
||||
});
|
||||
});
|
12
nest-user-api/src/app.controller.ts
Normal file
12
nest-user-api/src/app.controller.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { Controller, Get } from '@nestjs/common';
|
||||
import { AppService } from './app.service';
|
||||
|
||||
@Controller()
|
||||
export class AppController {
|
||||
constructor(private readonly appService: AppService) {}
|
||||
|
||||
@Get()
|
||||
getHello(): string {
|
||||
return this.appService.getHello();
|
||||
}
|
||||
}
|
24
nest-user-api/src/app.module.ts
Normal file
24
nest-user-api/src/app.module.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { AppController } from './app.controller';
|
||||
import { AppService } from './app.service';
|
||||
import { UsersModule } from './users/users.module';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { User } from './users/user.entity';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
TypeOrmModule.forRoot({
|
||||
type: 'mysql',
|
||||
host: 'localhost',
|
||||
port: 3306,
|
||||
username: 'root',
|
||||
password: 'init00!!',
|
||||
database: 'test_db',
|
||||
entities: ['src/**/*.entity.ts'],
|
||||
// synchronize: true //개발용
|
||||
}),
|
||||
UsersModule],
|
||||
controllers: [AppController],
|
||||
providers: [AppService],
|
||||
})
|
||||
export class AppModule {}
|
8
nest-user-api/src/app.service.ts
Normal file
8
nest-user-api/src/app.service.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class AppService {
|
||||
getHello(): string {
|
||||
return 'Hello World!';
|
||||
}
|
||||
}
|
11
nest-user-api/src/database/migrations/1750406542391-Migration.ts
Executable file
11
nest-user-api/src/database/migrations/1750406542391-Migration.ts
Executable file
@@ -0,0 +1,11 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class Migration1750406542391 implements MigrationInterface {
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
}
|
||||
|
||||
}
|
15
nest-user-api/src/database/migrations/1750406588424-Migration.ts
Executable file
15
nest-user-api/src/database/migrations/1750406588424-Migration.ts
Executable file
@@ -0,0 +1,15 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class Migration1750406588424 implements MigrationInterface {
|
||||
name = 'Migration1750406588424'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`CREATE TABLE \`user\` (\`id\` int NOT NULL AUTO_INCREMENT, \`name\` varchar(255) NOT NULL, \`email\` varchar(255) NOT NULL, UNIQUE INDEX \`IDX_e12875dfb3b1d92d7d7c5377e2\` (\`email\`), PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`DROP INDEX \`IDX_e12875dfb3b1d92d7d7c5377e2\` ON \`user\``);
|
||||
await queryRunner.query(`DROP TABLE \`user\``);
|
||||
}
|
||||
|
||||
}
|
14
nest-user-api/src/database/migrations/1750406841786-Migration.ts
Executable file
14
nest-user-api/src/database/migrations/1750406841786-Migration.ts
Executable file
@@ -0,0 +1,14 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class Migration1750406841786 implements MigrationInterface {
|
||||
name = 'Migration1750406841786'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`user\` ADD \`password\` varchar(255) NOT NULL`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`user\` DROP COLUMN \`password\``);
|
||||
}
|
||||
|
||||
}
|
9
nest-user-api/src/main.ts
Normal file
9
nest-user-api/src/main.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { AppModule } from './app.module';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
app.enableCors();
|
||||
await app.listen(process.env.PORT ?? 3000);
|
||||
}
|
||||
bootstrap();
|
16
nest-user-api/src/users/user.entity.ts
Executable file
16
nest-user-api/src/users/user.entity.ts
Executable file
@@ -0,0 +1,16 @@
|
||||
import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";
|
||||
|
||||
@Entity()
|
||||
export class User {
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
@Column()
|
||||
name: string;
|
||||
|
||||
@Column()
|
||||
password: string;
|
||||
|
||||
@Column({ unique: true })
|
||||
email: string;
|
||||
}
|
18
nest-user-api/src/users/users.controller.spec.ts
Executable file
18
nest-user-api/src/users/users.controller.spec.ts
Executable file
@@ -0,0 +1,18 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { UsersController } from './users.controller';
|
||||
|
||||
describe('UsersController', () => {
|
||||
let controller: UsersController;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
controllers: [UsersController],
|
||||
}).compile();
|
||||
|
||||
controller = module.get<UsersController>(UsersController);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(controller).toBeDefined();
|
||||
});
|
||||
});
|
33
nest-user-api/src/users/users.controller.ts
Executable file
33
nest-user-api/src/users/users.controller.ts
Executable file
@@ -0,0 +1,33 @@
|
||||
import { Body, Controller, Delete, Get, Param, Post, Put } from '@nestjs/common';
|
||||
import { UsersService } from './users.service';
|
||||
import { User } from './user.entity';
|
||||
|
||||
@Controller('users')
|
||||
export class UsersController {
|
||||
constructor(private userService: UsersService) {}
|
||||
|
||||
@Post()
|
||||
create(@Body() body: Partial<User>) {
|
||||
return this.userService.create(body);
|
||||
}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.userService.findAll();
|
||||
}
|
||||
|
||||
@Get(":id")
|
||||
findOne(@Param("id") id: string) {
|
||||
return this.userService.findOne(Number(id));
|
||||
}
|
||||
|
||||
@Put(":id")
|
||||
update(@Param("id") id: string, @Body() body: Partial<User>) {
|
||||
return this.userService.update(Number(id), body);
|
||||
}
|
||||
|
||||
@Delete(":id")
|
||||
delete(@Param("id") id: string) {
|
||||
return this.userService.delete(Number(id));
|
||||
}
|
||||
}
|
12
nest-user-api/src/users/users.module.ts
Executable file
12
nest-user-api/src/users/users.module.ts
Executable file
@@ -0,0 +1,12 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { UsersController } from './users.controller';
|
||||
import { UsersService } from './users.service';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { User } from './user.entity';
|
||||
|
||||
@Module({
|
||||
imports: [TypeOrmModule.forFeature([User])],
|
||||
controllers: [UsersController],
|
||||
providers: [UsersService]
|
||||
})
|
||||
export class UsersModule {}
|
18
nest-user-api/src/users/users.service.spec.ts
Executable file
18
nest-user-api/src/users/users.service.spec.ts
Executable file
@@ -0,0 +1,18 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { UsersService } from './users.service';
|
||||
|
||||
describe('UsersService', () => {
|
||||
let service: UsersService;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [UsersService],
|
||||
}).compile();
|
||||
|
||||
service = module.get<UsersService>(UsersService);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(service).toBeDefined();
|
||||
});
|
||||
});
|
36
nest-user-api/src/users/users.service.ts
Executable file
36
nest-user-api/src/users/users.service.ts
Executable file
@@ -0,0 +1,36 @@
|
||||
import { Injectable, NotFoundException } from '@nestjs/common';
|
||||
import { User } from './user.entity';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
|
||||
@Injectable()
|
||||
export class UsersService {
|
||||
constructor( @InjectRepository(User) private readonly userRepository: Repository<User>) {}
|
||||
|
||||
async create(user: Partial<User>): Promise<User> {
|
||||
const newUser = this.userRepository.create(user);
|
||||
return this.userRepository.save(newUser);
|
||||
}
|
||||
|
||||
async findAll(): Promise<User[]> {
|
||||
return this.userRepository.find();
|
||||
}
|
||||
|
||||
async findOne(id: number): Promise<User> {
|
||||
const user = await this.userRepository.findOneBy({ id });
|
||||
if (!user)
|
||||
throw new NotFoundException(`User with id ${id} not found`);
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
async update(id: number, update: Partial<User>): Promise<User> {
|
||||
const user = await this.findOne(id);
|
||||
Object.assign(user, update);
|
||||
return this.userRepository.save(user);
|
||||
}
|
||||
|
||||
async delete(id: number): Promise<void> {
|
||||
await this.userRepository.delete(id);
|
||||
}
|
||||
}
|
25
nest-user-api/test/app.e2e-spec.ts
Normal file
25
nest-user-api/test/app.e2e-spec.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import * as request from 'supertest';
|
||||
import { App } from 'supertest/types';
|
||||
import { AppModule } from './../src/app.module';
|
||||
|
||||
describe('AppController (e2e)', () => {
|
||||
let app: INestApplication<App>;
|
||||
|
||||
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!');
|
||||
});
|
||||
});
|
9
nest-user-api/test/jest-e2e.json
Normal file
9
nest-user-api/test/jest-e2e.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"moduleFileExtensions": ["js", "json", "ts"],
|
||||
"rootDir": ".",
|
||||
"testEnvironment": "node",
|
||||
"testRegex": ".e2e-spec.ts$",
|
||||
"transform": {
|
||||
"^.+\\.(t|j)s$": "ts-jest"
|
||||
}
|
||||
}
|
4
nest-user-api/tsconfig.build.json
Normal file
4
nest-user-api/tsconfig.build.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
|
||||
}
|
21
nest-user-api/tsconfig.json
Normal file
21
nest-user-api/tsconfig.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"declaration": true,
|
||||
"removeComments": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"target": "ES2023",
|
||||
"sourceMap": true,
|
||||
"outDir": "./dist",
|
||||
"baseUrl": "./",
|
||||
"incremental": true,
|
||||
"skipLibCheck": true,
|
||||
"strictNullChecks": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noImplicitAny": false,
|
||||
"strictBindCallApply": false,
|
||||
"noFallthroughCasesInSwitch": false
|
||||
}
|
||||
}
|
0
package-lock.json
generated
Normal file → Executable file
0
package-lock.json
generated
Normal file → Executable file
14
ts_playground/01-types.ts
Executable file
14
ts_playground/01-types.ts
Executable file
@@ -0,0 +1,14 @@
|
||||
let username: string = "User";
|
||||
let age: number = 36;
|
||||
let isActive: boolean = true;
|
||||
let tags: string[] = ["nestjs", "ts", "dotnet"];
|
||||
let anything: any = "any variable";
|
||||
|
||||
type User = {
|
||||
id: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
const user: User = { id: 135, name: "Test User"};
|
||||
|
||||
console.log(user);
|
12
ts_playground/02-functions.ts
Executable file
12
ts_playground/02-functions.ts
Executable file
@@ -0,0 +1,12 @@
|
||||
function great(name: string): string {
|
||||
return `안녕하세요, ${name}님!`;
|
||||
}
|
||||
|
||||
const add = (a: number, b: number): number => a + b;
|
||||
|
||||
function log(message: string, userId?: number): void {
|
||||
console.log(`[${userId ?? "Unknown"}] ${message}`);
|
||||
}
|
||||
|
||||
log(add(3, 4).toString());
|
||||
log(great("타입스크립트"), 135);
|
16
ts_playground/03-interfaces.ts
Executable file
16
ts_playground/03-interfaces.ts
Executable file
@@ -0,0 +1,16 @@
|
||||
interface Person {
|
||||
name: string;
|
||||
age: number;
|
||||
}
|
||||
|
||||
interface Developer extends Person {
|
||||
skills: string[];
|
||||
}
|
||||
|
||||
const dev: Developer = {
|
||||
name: "DevUser",
|
||||
age: 36,
|
||||
skills: ["TS", "DotNet", "MAUI"]
|
||||
};
|
||||
|
||||
console.log(dev);
|
17
ts_playground/04-classes.ts
Executable file
17
ts_playground/04-classes.ts
Executable file
@@ -0,0 +1,17 @@
|
||||
class Animal {
|
||||
constructor(public name: string) {}
|
||||
|
||||
speak(): void {
|
||||
console.log(`${this.name}이(가) 소리를 냅니다.`);
|
||||
}
|
||||
}
|
||||
|
||||
class Dog extends Animal {
|
||||
bark(): void {
|
||||
console.log("멍멍!");
|
||||
}
|
||||
}
|
||||
|
||||
const myDog = new Dog("바둑이");
|
||||
myDog.bark();
|
||||
myDog.speak();
|
9
ts_playground/05-generics.ts
Executable file
9
ts_playground/05-generics.ts
Executable file
@@ -0,0 +1,9 @@
|
||||
function wrapInArray<T>(value: T): T[] {
|
||||
return [value];
|
||||
}
|
||||
|
||||
const numArray = wrapInArray(123);
|
||||
const strArray = wrapInArray("NestJS");
|
||||
|
||||
console.log(numArray);
|
||||
console.log(strArray);
|
11
ts_playground/06-union-type.ts
Executable file
11
ts_playground/06-union-type.ts
Executable file
@@ -0,0 +1,11 @@
|
||||
type Input = string | number;
|
||||
|
||||
function double(input: Input): number {
|
||||
if (typeof input === "string")
|
||||
return parseFloat(input) * 2;
|
||||
|
||||
return input * 2;
|
||||
}
|
||||
|
||||
console.log(double(21));
|
||||
console.log(double("31"));
|
25
ts_playground/07-utility-types.ts
Executable file
25
ts_playground/07-utility-types.ts
Executable file
@@ -0,0 +1,25 @@
|
||||
type User2 = {
|
||||
id: number;
|
||||
name: string;
|
||||
email: string;
|
||||
password: string;
|
||||
};
|
||||
|
||||
// 수정용 DTO에서 Partial로 일부만 허용
|
||||
type UpdateUserDto = Partial<User2>;
|
||||
|
||||
// 공개용 DTO에서 비밀번호 제거
|
||||
type PublicUser = Omit<User2, 'password'>;
|
||||
|
||||
const updateUser: UpdateUserDto = {
|
||||
name: "update user",
|
||||
};
|
||||
|
||||
const publicUser: PublicUser = {
|
||||
id: 135,
|
||||
name: "public user",
|
||||
email: "pu@dor.com"
|
||||
};
|
||||
|
||||
console.log(updateUser);
|
||||
console.log(publicUser);
|
10
ts_playground/08-record.ts
Executable file
10
ts_playground/08-record.ts
Executable file
@@ -0,0 +1,10 @@
|
||||
type statusCode = "OK" | "ERROR" | "NOT_FOUND";
|
||||
|
||||
// 매핑
|
||||
const statMessage: Record<statusCode, string> = {
|
||||
OK: "정상 처리",
|
||||
ERROR: "에러 발생",
|
||||
NOT_FOUND: "찾을 수 없음"
|
||||
};
|
||||
|
||||
console.log(statMessage.NOT_FOUND);
|
10
ts_playground/09-narrowing.ts
Executable file
10
ts_playground/09-narrowing.ts
Executable file
@@ -0,0 +1,10 @@
|
||||
function print(value: string | string[]) {
|
||||
if (Array.isArray(value)) {
|
||||
console.log("Array: ", value.join(", "));
|
||||
} else {
|
||||
console.log("Single value: ", value);
|
||||
}
|
||||
}
|
||||
|
||||
print("hello");
|
||||
print(["hello", "world"]);
|
21
ts_playground/10-keyof-typeof.ts
Executable file
21
ts_playground/10-keyof-typeof.ts
Executable file
@@ -0,0 +1,21 @@
|
||||
type User3 = {
|
||||
id: number;
|
||||
name: string;
|
||||
};
|
||||
|
||||
type User3Keys = keyof User3;
|
||||
|
||||
function getValue(user: User3, key: User3Keys) {
|
||||
return user[key];
|
||||
}
|
||||
|
||||
const user3 = { id: 10, name: "dor" };
|
||||
console.log(getValue(user3, "name"));
|
||||
|
||||
const config = {
|
||||
port: 3000,
|
||||
debug: true
|
||||
};
|
||||
|
||||
type Config = typeof config;
|
||||
console.log(typeof config);
|
8
ts_playground/11-as-const.ts
Executable file
8
ts_playground/11-as-const.ts
Executable file
@@ -0,0 +1,8 @@
|
||||
const ROLES = ["admin", "user", "guest"] as const;
|
||||
type Role = typeof ROLES[number];
|
||||
|
||||
function checkRole(role: Role) {
|
||||
console.log(`${role} 권한 확인`);
|
||||
}
|
||||
|
||||
checkRole("admin");
|
18
ts_playground/12-unknown-never.ts
Executable file
18
ts_playground/12-unknown-never.ts
Executable file
@@ -0,0 +1,18 @@
|
||||
function safeParse(json: string): unknown {
|
||||
try {
|
||||
return JSON.parse(json);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
const result = safeParse('{"name":"Dorr"}');
|
||||
console.log(result);
|
||||
|
||||
if (typeof result === "object" && result !== null && "name" in result) {
|
||||
console.log((result as { name: string }).name);
|
||||
}
|
||||
|
||||
function fail(): never {
|
||||
throw new Error("Failed!");
|
||||
}
|
17
ts_playground/package.json
Executable file
17
ts_playground/package.json
Executable file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "ts_playground",
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"description": "",
|
||||
"devDependencies": {
|
||||
"@types/node": "^24.0.0",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.8.3"
|
||||
}
|
||||
}
|
113
ts_playground/tsconfig.json
Executable file
113
ts_playground/tsconfig.json
Executable file
@@ -0,0 +1,113 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
/* Visit https://aka.ms/tsconfig to read more about this file */
|
||||
|
||||
/* Projects */
|
||||
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
|
||||
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
||||
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
|
||||
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
|
||||
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
||||
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
||||
|
||||
/* Language and Environment */
|
||||
"target": "es2023", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
||||
"lib": ["ES2020"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
||||
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
||||
// "libReplacement": true, /* Enable lib replacement. */
|
||||
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
|
||||
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
||||
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
|
||||
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
||||
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
|
||||
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
|
||||
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
||||
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
||||
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
||||
|
||||
/* Modules */
|
||||
"module": "commonjs", /* Specify what module code is generated. */
|
||||
// "rootDir": "./", /* Specify the root folder within your source files. */
|
||||
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
|
||||
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
||||
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
||||
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
||||
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
||||
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
||||
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
||||
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
||||
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
|
||||
// "rewriteRelativeImportExtensions": true, /* Rewrite '.ts', '.tsx', '.mts', and '.cts' file extensions in relative import paths to their JavaScript equivalent in output files. */
|
||||
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
|
||||
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
|
||||
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
|
||||
// "noUncheckedSideEffectImports": true, /* Check side effect imports. */
|
||||
// "resolveJsonModule": true, /* Enable importing .json files. */
|
||||
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
|
||||
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
||||
|
||||
/* JavaScript Support */
|
||||
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
||||
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
||||
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
||||
|
||||
/* Emit */
|
||||
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
||||
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
||||
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
||||
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
||||
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
||||
// "noEmit": true, /* Disable emitting files from a compilation. */
|
||||
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
||||
// "outDir": "./", /* Specify an output folder for all emitted files. */
|
||||
// "removeComments": true, /* Disable emitting comments. */
|
||||
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
||||
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
||||
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
||||
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
||||
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
||||
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
||||
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
||||
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
||||
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
||||
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
||||
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
||||
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
||||
|
||||
/* Interop Constraints */
|
||||
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
||||
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
|
||||
// "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */
|
||||
// "erasableSyntaxOnly": true, /* Do not allow runtime constructs that are not part of ECMAScript. */
|
||||
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
||||
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
||||
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
||||
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
||||
|
||||
/* Type Checking */
|
||||
"strict": true, /* Enable all strict type-checking options. */
|
||||
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
||||
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
|
||||
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
||||
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
||||
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
||||
// "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */
|
||||
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
||||
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
||||
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
||||
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
||||
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
||||
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
||||
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
||||
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
||||
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
||||
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
||||
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
||||
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
||||
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
||||
|
||||
/* Completeness */
|
||||
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
||||
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user