Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nest.js boilerplate #99

Merged
merged 23 commits into from
Aug 1, 2023
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
22 changes: 21 additions & 1 deletion .github/workflows/build_image.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Build and upload image

on:
on:
workflow_call:

jobs:
Expand All @@ -23,3 +23,23 @@ jobs:
with:
name: hybridilusmu
path: /tmp/hybridilusmu.tar

build-nest:
name: Build and upload image (Nest.js)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and export
uses: docker/build-push-action@v4
with:
context: app-nest
tags: hybridilusmu-nest
outputs: type=docker,dest=/tmp/hybridilusmu-nest.tar
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: hybridilusmu-nest
path: /tmp/hybridilusmu-nest.tar
75 changes: 47 additions & 28 deletions .github/workflows/run_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,35 +33,54 @@ jobs:
run: |
docker load --input /tmp/hybridilusmu.tar
docker image ls -a
- name: Start containers
run: docker compose -f compose.yaml -f compose-ci.yaml up -d lusmu
- name: Run unit tests
run: npm test
run: docker compose -f compose.yaml -f compose-ci.yaml run lusmu npm test
- name: Stop containers
if: always()
run: npm stop

unit-tests-nest:
name: Unit tests (Nest.js)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: hybridilusmu-nest
path: /tmp
- name: Load image
run: |
docker load --input /tmp/hybridilusmu-nest.tar
docker image ls -a
- name: Run unit tests
run: docker compose -f compose.yaml -f compose-ci.yaml run lusmu-nest npm test
- name: Stop containers
if: always()
run: npm stop

integration-tests-nest:
name: Integration tests (Nest.js)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: hybridilusmu-nest
path: /tmp
- name: Load image
run: |
docker load --input /tmp/hybridilusmu-nest.tar
docker image ls -a
- name: Run integration tests
run: docker compose -f compose.yaml -f compose-ci.yaml run lusmu-nest npm run test:integration
- name: Stop containers
if: always()
run: npm stop
# FIXME: Enable these once integration tests exit cleanly.
# integration-tests:
# name: Integration tests
# runs-on: ubuntu-latest
# needs: build
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v2
# - name: Download artifact
# uses: actions/download-artifact@v3
# with:
# name: hybridilusmu
# path: /tmp
# - name: Load image
# run: |
# docker load --input /tmp/hybridilusmu.tar
# docker image ls -a
# - name: Start containers
# run: docker compose -f compose.yaml -f compose-ci.yaml up -d lusmu
# - name: Run integration tests
# run: npm run test:integration
# - name: Stop containers
# run: npm stop
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ node_modules
**/.vuepress/.cache
**/.vuepress/.temp
docs/build
.vscode
1 change: 1 addition & 0 deletions app-nest/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
9 changes: 9 additions & 0 deletions app-nest/.eslintrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root: true
parser: "@typescript-eslint/parser"
extends:
- eslint:recommended
- plugin:@typescript-eslint/recommended
# Keep prettier last so it overrides other configs correctly!
- prettier
plugins:
- "@typescript-eslint"
35 changes: 35 additions & 0 deletions app-nest/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# compiled output
/dist
/node_modules

# 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
1 change: 1 addition & 0 deletions app-nest/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v18.16.0
1 change: 1 addition & 0 deletions app-nest/.prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
trailingComma: all
13 changes: 13 additions & 0 deletions app-nest/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Using alpine because GitHub artifact upload is very slow for big images...
FROM node:18.16-alpine

USER node

# Install dependencies.
WORKDIR /usr/src/app
COPY package.json package-lock.json ./
RUN npm ci

COPY . .

CMD npm --offline start
73 changes: 73 additions & 0 deletions app-nest/README.md
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).
8 changes: 8 additions & 0 deletions app-nest/nest-cli.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"deleteOutDir": true
}
}
Loading