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

Refactor Mc-Auth and introduce automated tests #182

Merged
merged 41 commits into from
Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
1d225f9
Partially recodes utils.ts and setup Jest to unit test it
SpraxDev Jan 18, 2022
995054a
Add snyk as dependency and add an npm script
SpraxDev Jan 18, 2022
4e84e82
Updates GitHub URLs in package.json
SpraxDev Jan 18, 2022
57c33ad
Update dependencies `typescript` and `ts-node`
SpraxDev Jan 18, 2022
a1e8495
Replace config.ts with ConfigFile.ts which supports lazy values
SpraxDev Jan 18, 2022
fbf962b
LICENSE: Switching from 'MIT' to 'GNU LGPLv3'
SpraxDev Jan 28, 2022
3ff7a7a
Updates dependencies `ts-deepmerge` and `typescript`
SpraxDev Jan 28, 2022
f84604f
Start project restructure and write some unit tests
SpraxDev Jan 28, 2022
f5c5314
Updates dependency `snyk`
SpraxDev Jan 28, 2022
6db43d7
Updates dependency `sharp`
SpraxDev Jan 28, 2022
d27c3f4
Updates dependency `nodemailer`
SpraxDev Jan 28, 2022
f765605
Updates some dependencies by running `npm update`
SpraxDev Jan 28, 2022
3f2e336
Updates dependency `connect-pg-simple`
SpraxDev Jan 28, 2022
5a8cc19
Updates dependency `rotating-file-stream`
SpraxDev Jan 28, 2022
4b2cef5
Updates dependency `superagent`
SpraxDev Jan 28, 2022
0d0c641
Removes deprecated dependency `request`
SpraxDev Feb 13, 2022
dd2bd52
Extracts some string utility methods into its own npm package
SpraxDev Feb 13, 2022
7db0eef
Moves the `MojangAPI` class into its own npm package
SpraxDev Feb 13, 2022
23583a5
Adds tests for the `Constants` class
SpraxDev Feb 13, 2022
09e1cd6
Requires Node.js v16 and restructures package.json, tsconfig, gitignore
SpraxDev Feb 13, 2022
f63d3bf
Introduces Docker support to the project (+restructure npm scripts)
SpraxDev Feb 13, 2022
56a2e61
Updates GitHub Actions configurations
SpraxDev Feb 13, 2022
e009262
Removes dependency `uuid` and make `nodemon` a dev dependency
SpraxDev Feb 13, 2022
f387987
Updates Dependabot configuration
SpraxDev Feb 13, 2022
c1ef466
GitHub Actions: Setup SonarCloud for coverage reports
SpraxDev Feb 13, 2022
65182d7
Removes unnecessary type cast
SpraxDev Feb 13, 2022
3b31ce6
Release v3.0.0-SNAPSHOT
SpraxDev Feb 13, 2022
8fb549e
Dockerfile: Makes sure the work-dir is writable by the node-user
SpraxDev Feb 13, 2022
3d32ea8
Dockerfile: Moves `prod` target to the bottom to be found easier
SpraxDev Feb 19, 2022
4d6cc9a
Automatically write config file changes on app start
SpraxDev Feb 19, 2022
5db6be4
Dockerfile: Makes sure that storage/ and logs/ are writeable
SpraxDev Feb 19, 2022
874b9d0
Dockerfile: Updates system packages and npm to the newest version
SpraxDev Feb 19, 2022
3d93981
Dockerfile: Adds a healthcheck to the production image
SpraxDev Feb 19, 2022
50c5162
Moves ConfigFile class to SpraxDev/Node-Commons repository
SpraxDev Feb 28, 2022
29bf183
GitHub Actions: Use Node.js v16 for SonarCloud workflow
SpraxDev Feb 28, 2022
976dd25
Updates some dependencies
SpraxDev Feb 28, 2022
a922250
Update all dependencies
SpraxDev May 20, 2022
a2f4e68
Remove one empty line
SpraxDev May 20, 2022
87a6937
Updates some dependencies
SpraxDev Jun 5, 2022
807fdf6
Updates some dependencies
SpraxDev Jun 15, 2022
4c3d3c1
Adds temporary rate limit
SpraxDev Jun 15, 2022
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
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*
!dist/
!resources/
!src/
!package.json
!package-lock.json
!tsconfig.json
!LICENSE
!README.md
11 changes: 7 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "npm" # See documentation for possible values
directory: "/" # Location of package manifests
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
10 changes: 7 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,22 @@ on:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '24 21 * * 5'
- cron: '32 3 * * 6'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
language: [ 'typescript' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support

steps:
- name: Checkout repository
Expand Down
24 changes: 9 additions & 15 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,29 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: TypeScript Compile
name: Node.js CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
types: [ opened, synchronize, reopened ]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [ 12.x, 14.x ] # Oldest 'Active' version: https://nodejs.org/en/about/releases/
node-version: [ 16.x, 17.x ] # Oldest 'Active' version: https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v2
- name: Use Node.js v${{ matrix.node-version }}
uses: actions/setup-node@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: 'Cache: npm-node_modules'
uses: actions/cache@v1
with:
path: ./node_modules/
key: ${{ runner.os }}-npm-${{ hashFiles('./package-lock.json') }}
- run: npm i
cache: 'npm'
- run: npm ci
- run: npm run build
#- run: npm test
env:
CI: true
- run: npm run test
31 changes: 31 additions & 0 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Sonarcloud

on:
push:
branches: [ master ]
pull_request:
types: [ opened, synchronize, reopened ]

jobs:
SonarCloud:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 16.x
cache: 'npm'

- name: Run Tests
run: npm ci && npm run test

- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
15 changes: 11 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
/node_modules/
/storage/
/build/
# Project
/dist/
/logs/
/storage/


# npm and other dependencies
/node_modules/
/coverage/


/.idea/
# JetBrains IDEs
/.idea/
64 changes: 64 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# syntax=docker/dockerfile:1
FROM node:16-alpine as base

LABEL maintainer="Christian Koop <contact@sprax2013.de>"

RUN apk --no-cache -U upgrade && \
npm i -g npm --update-notifier false && \
npm cache clean --force

RUN mkdir -p /app/storage/ /app/logs/ && \
chown -R node:node /app/
WORKDIR /app/

USER node

COPY --chown=node:node LICENSE README.md ./
COPY --chown=node:node package.json package-lock.json ./


##
# Builder: Compiles the project into js files (optionally generates source maps too)
##
FROM base as builder

ARG BUILD_SCRIPT=build

RUN npm ci
COPY --chown=node:node tsconfig.json ./tsconfig.json
COPY --chown=node:node src/ ./src/
RUN npm run $BUILD_SCRIPT


##
# Development: Copies the resources, compiled js files and source maps and starts the application with source map support
##
FROM base as dev

# TODO: Check if volume mounts could be beneficial for development
RUN npm ci

COPY --chown=node:node --from=builder /app/dist/ ./dist/
COPY --chown=node:node resources/ ./resources/

CMD ["node", "--enable-source-maps", "dist/index.js"]


##
# Production: Copies the resources and compiled js files and starts the application
##
FROM base as prod

# TODO: This heavily relies on hostname being set and the default port 8080 being used
HEALTHCHECK --interval=1m --timeout=30s --retries=3 \
CMD wget --spider $(hostname):8080

ENV NODE_ENV=production
RUN npm ci && \
npm cache clean --force && \
rm -Rf /home/node/.npm/

COPY --chown=node:node --from=builder /app/dist/ ./dist/
COPY --chown=node:node resources/ ./resources/

CMD ["node", "dist/index.js"]
Loading