Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ dist/
.index/
*.log
.idea/
.vscode/
coverage/
coverage/
.vscode/*
!.vscode/launch.json
29 changes: 29 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Docker: Attach to Node",
"remoteRoot": "/api",
"port": 9229,
"skipFiles": [
"<node_internals>/**"
],
"restart": true
},
{
"name": "Attach Locally",
"port": 9229,
"request": "attach",
"skipFiles": [
"<node_internals>/**"
],
"type": "node",
"restart": true
}
]
}
42 changes: 41 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,29 @@ This version of the boilerplate is still in beta, so might contain abstractions

## How to run the server

### Requisites
* To run the project wit Docker you need to have Docker installed in your computer: [Docker](https://docs.docker.com/engine/install/)
* To run locally you need to have project dependencies installed globally in your machine

During development, the project can be run in two different ways.

### With Docker

If you want to just run the application in development mode, use the following command:

```sh
$ docker compose up
```

To run the application in debug mode in a way that the execution will stop when a debugger statement is called, use:

```sh
$ docker-compose -f docker-compose.yaml -f docker-compose.debug.yaml up
```

### Locally

If you want to just run the application in development mode, use the following command:
```sh
$ yarn dev
```
Expand Down Expand Up @@ -44,9 +63,19 @@ $ yarn remote [server address] [REPL port]

## Tests

The boilerplate is prepared to run tests using Jest. We usually group the tests in folders called `__tests__` (following Jest convention) for each module of the application. To run the tests use the following command:
The boilerplate is prepared to run tests using Jest. We usually group the tests in folders called `__tests__` (following Jest convention) for each module of the application. To run the tests use the following commands:

### With Docker
```sh
$ docker compose up

$ yarn test
```

### Locally
```sh
$ yarn dev

$ yarn test
```

Expand Down Expand Up @@ -81,6 +110,17 @@ This boilerplate follows ideas from multiple good software development practices

To run your app in production mode, you'll need to follow these steps:

### With Docker

1. Define any environment variable important for production
2. Go to `docker-compose.production.yaml` file, and add necessary configurations
3. Run the following command:
```sh
$ docker-compose -f docker-compose.yaml -f docker-compose.production.yaml up
```

### Locally

1. Build the application with `yarn build`
2. Define any environment variable important for production
3. Start the app with `yarn start`
Expand Down
6 changes: 6 additions & 0 deletions docker-compose.debug.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
services:
api:
command: bash -c "yarn install && yarn debug"
ports:
- 9229:9229

3 changes: 3 additions & 0 deletions docker-compose.production.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
services:
api:
command: bash -c "yarn install && yarn build && yarn start"
1 change: 1 addition & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ services:
- .:/api
ports:
- 3000:3000
- 2580:2580
environment:
HOST: 0.0.0.0
DB_HOST: mongodb://node-api-boilerplate-mongodb:27017
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@
},
"scripts": {
"prebuild": "rimraf dist",
"start": "node . --transpile-only --files .| pino-pretty -c -l",
"build": "tsc -p tsconfig.prod.json",
"dev": "tsnd --transpile-only --files src/index.ts | pino-pretty -c -l",
"debug": "tsnd --transpile-only --inspect --files src/index.ts | pino-pretty -c -l",
"debug": "tsnd --transpile-only --inspect=0.0.0.0:9229 --nolazy --files src/index.ts | pino-pretty -c -l",
"cli": "tsnd --transpile-only --files src/index.ts --cli",
"remote": "ts-node bin/replClient.ts",
"test": "jest"
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"outDir": "./dist",
"rootDir": "./src",
"removeComments": false,
"inlineSourceMap": true,
"strict": true,
"noImplicitAny": false,
"noUnusedLocals": true,
Expand Down