Skip to content

Commit

Permalink
minor formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
morten-andersen committed Jan 25, 2025
1 parent 417dd02 commit 623a944
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Notes on programming languages, network, systems, calendars, etc.
### Programming Languages and Development Tools

* [**Programming Language Notes**](./programming) - notes on Java, JavaScript, node.js, etc.
* [SQL](./sql)
* [**git**](./git) - notes on git revision control

### Linux
Expand Down
1 change: 0 additions & 1 deletion programming/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

* [Java](./java)
* [Kotlin](./kotlin)
* [SQL](./sql)
* [JavaScript, TypeScript and Node.js](./javascript)
* [R Statistical Language](./rscript), which I used in my Master Thesis for generating a large number of graphs programmatically
* [Go notes](./go)
Expand Down
1 change: 1 addition & 0 deletions programming/javascript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

* [Node.js](./nodejs.md) information on **Node Version Manager** `nvm`
* [npm](./npm.md) information on **Node Package Manager** `npm`
* [NestJS](./nestjs.md) information on the **NestJS** framework

#### Resources

Expand Down
87 changes: 87 additions & 0 deletions programming/javascript/nestjs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
### NestJS

Running the nestjs binary without installing it globally

```bash
npx -p @nestjs/cli nest
```

#### Setup

```bash
npx -p @nestjs/cli nest new <app name>
```

##### Running the [CLI](https://docs.nestjs.com/cli/overview)

```bash
npx nest <command> <arguments>
```


#### Swagger documentation

https://docs.nestjs.com/openapi/introduction

```bash
npm install @nestjs/swagger swagger-ui-express
```

Setup CLI plugin
https://docs.nestjs.com/openapi/cli-plugin

#### Validation

https://docs.nestjs.com/techniques/validation

```bash
npm install class-validator class-transformer
npm install reflect-metadata --save
```

Add `app.useGlobalPipes(new ValidationPipe({transform: true}));`

uses class-validator https://github.com/typestack/class-validator

#### Logging

https://stackoverflow.com/questions/54101926/nestjs-middleware-get-request-response-body

#### [Documentation](https://docs.nestjs.com/recipes/documentation) for the project

Install

```bash
npm i -D @compodoc/compodoc
```

npm script command:

```
"doc": "compodoc -p tsconfig.json -s"
```

Generate and serve documentation from port 8080

```bash
npm run doc
```

#### Curl

```bash
curl --header "Content-Type: application/json" \
--request POST \
--data '{"orderNo": "3333", "customer": {"name": "benno","age":22}, "items": [{"name": "item1", "price": 27}, {"name": "item2", "price": 99}]}' \
http://localhost:3000/

curl --header "Content-Type: application/json" \
--request POST \
--data '{"orderNo": "3333", "customer": {"name": "benno","age":22}, "items": [{"name": "item1", "price": 27, "frameSize": 55}, {"name": "item2", "price": 99, "frameSize": 45}]}' \
http://localhost:3000/

curl --header "Content-Type: application/json" \
--request POST \
--data '{"orderNo": "3333", "customer": {"name": "benno","age":22}, "items": [{"name": "item1", "price": 27, "size": "medium"}, {"name": "item2", "price": 99, "size": "medium"}]}' \
http://localhost:3001/
```
File renamed without changes.

0 comments on commit 623a944

Please sign in to comment.