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

Migrate to Node.js v20 #71

Merged
merged 12 commits into from
Jul 14, 2024
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
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
12 changes: 6 additions & 6 deletions .github/workflows/azure-jam-comments-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ on:

env:
AZURE_FUNCTIONAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root
NODE_VERSION: '14.x' # set this to the node version to use (supports 8.x, 10.x, 12.x)
NODE_VERSION: '20.x' # set this to the node version to use (supports 8.x, 10.x, 12.x)
fullDeployment: ${{ github.event.inputs.fullDeployment || 'false' }}

defaults:
Expand All @@ -56,7 +56,7 @@ jobs:
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v2.3.4
uses: actions/checkout@v4
with:
persist-credentials: false
- name: setup environment variables
Expand Down Expand Up @@ -86,10 +86,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@master
uses: actions/checkout@v4

- name: Setup Node ${{ env.NODE_VERSION }} Environment
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'
Expand All @@ -114,10 +114,10 @@ jobs:
environment: ${{ needs.setupEnv.outputs.environment }}
steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@master
uses: actions/checkout@v4

- name: Setup Node ${{ env.NODE_VERSION }} Environment
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/azure-jam-comments-dashboard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ on:

env:
AZURE_WEBAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root
NODE_VERSION: '14.x' # set this to the node version to use
NODE_VERSION: '20.x' # set this to the node version to use
fullDeployment: ${{ github.event.inputs.fullDeployment || 'false' }}

jobs:
Expand All @@ -48,7 +48,7 @@ jobs:
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v2.3.4
uses: actions/checkout@v4
with:
persist-credentials: false
- name: setup environment variables
Expand Down Expand Up @@ -77,9 +77,9 @@ jobs:
environment: ${{ needs.setupEnv.outputs.environment }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'
Expand All @@ -103,10 +103,10 @@ jobs:
- build-and-test
steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@master
uses: actions/checkout@v4

- name: Setup Node ${{ env.NODE_VERSION }} Environment
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'
Expand Down
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Stage 1: Build the application
# Use a Node.js image
FROM node:20-alpine as builder

# Create app directory
WORKDIR /usr/src/app

# Copy package.json and package-lock.json
COPY package*.json ./
COPY yarn.lock ./

# Install dependencies
RUN yarn

# Copy the rest of your app's source code
COPY . .

# Build your TypeScript app
RUN yarn build
5 changes: 5 additions & 0 deletions Dockerfile-api
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM jcomments as api

EXPOSE 3000

CMD ["yarn", "start-api"]
5 changes: 5 additions & 0 deletions Dockerfile-app
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM jcomments as app

EXPOSE 3000

CMD ["yarn", "start"]
46 changes: 46 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
version: '3.8'

services:
app:
build:
context: .
dockerfile: Dockerfile-app
ports:
- "3030:3030"
networks:
- my_network
environment:
NODE_ENVIRONMENT: production
depends_on:
- db

api:
build:
context: .
dockerfile: Dockerfile-api
ports:
- "3000:3000"
networks:
- my_network
depends_on:
- db

db:
image: postgres:14-alpine
ports:
- "5432:5432"
environment:
POSTGRES_DB: master
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
networks:
- my_network
volumes:
- pgdata:/var/lib/postgresql/data

networks:
my_network:
driver: bridge

volumes:
pgdata:
2 changes: 1 addition & 1 deletion infra/azure/apps/admin/templates/webapp-dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"hyperV": false,
"siteConfig": {
"numberOfWorkers": 1,
"linuxFxVersion": "NODE|16-lts",
"linuxFxVersion": "NODE|20-lts",
"alwaysOn": false,
"functionAppScaleLimit": 0,
"minimumElasticInstanceCount": 0
Expand Down
2 changes: 1 addition & 1 deletion infra/azure/apps/api/templates/funcapp.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('servicePlanName'))]",
"siteConfig": {
"numberOfWorkers": 1,
"linuxFxVersion": "Node|14",
"linuxFxVersion": "Node|20",
"alwaysOn": false,
"functionAppScaleLimit": 200,
"minimumElasticInstanceCount": 0
Expand Down
118 changes: 59 additions & 59 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
"name": "jam-comments",
"version": "1.0.0",
"version": "1.0.1",
"description": "A commenting platform for self-hosted static websites.",
"main": "index.js",
"engines": {
"node": ">=12.20.0"
"node": ">=20.0.0"
},
"scripts": {
"generate": "json2ts -i schemas/**/* -o generated/ && ts-auto-guard --paths ./generated/*.ts --export-all && ts-auto-guard --paths ./src/**/*.interface.ts --export-all",
Expand All @@ -25,6 +24,7 @@
"lint-fix": "eslint \"./src/**/*.ts\" --fix",
"prestart": "node ./build/src/cli.js db:migrate",
"start": "node ./build/src/web.js",
"start-api": "node ./build/src/api.js",
"watch": "tsc -p tsconfig.json -w",
"func": "func start --verbose",
"zip:app": "zip -q -r webapp.zip . -x@.appserviceignore -x .appserviceignore",
Expand All @@ -41,85 +41,85 @@
"dependencies": {
"@azure/functions": "3.2.0",
"@azure/service-bus": "7.6.0",
"@nestjs/common": "9.0.1",
"@nestjs/core": "9.0.1",
"@nestjs/passport": "9.0.0",
"@nestjs/platform-express": "9.0.1",
"@nestjs/common": "10.*",
"@nestjs/core": "10.*",
"@nestjs/passport": "10.*",
"@nestjs/platform-express": "10.*",
"@ngneat/falso": "2.23.0",
"@pgtyped/cli": "1.0.0",
"@pgtyped/query": "1.0.0",
"@pgtyped/cli": "2.*",
"@pgtyped/query": "2.*",
"akismet-api": "5.1.0",
"class-transformer": "0.4.0",
"class-validator": "0.13.1",
"class-transformer": "0.5.*",
"class-validator": "0.14.*",
"commander": "7.2.0",
"connect-flash": "0.1.1",
"connect-pg-simple": "6.2.1",
"cookie-parser": "1.4.5",
"connect-pg-simple": "9.*",
"cookie-parser": "1.4.*",
"csurf": "1.11.0",
"dotenv": "10.0.0",
"express-handlebars": "6.0.6",
"express-session": "1.17.3",
"handlebars-dateformat": "1.1.2",
"express-handlebars": "7.*",
"express-session": "1.18.*",
"handlebars-dateformat": "1.1.3",
"handlebars-helpers": "0.10.0",
"hbs": "4.2.0",
"he": "1.2.0",
"jest": "27.0.4",
"jest": "29.*",
"jsdom": "16.6.0",
"lodash": "4.17.21",
"moment": "2.29.4",
"moment-timezone": "0.5.35",
"nestjs-console": "7.0.1",
"nestjs-pino": "2.6.0",
"nodemailer": "6.6.1",
"nodemailer-mailgun-transport": "2.1.4",
"passport": "0.6.0",
"nestjs-console": "9.*",
"nestjs-pino": "4.*",
"nodemailer": "6.*",
"nodemailer-mailgun-transport": "2.1.5",
"passport": "0.7.*",
"passport-local": "1.0.0",
"pg": "8.7.3",
"pg-boss": "7.4.0",
"pino": "8.1.0",
"pg": "8.*",
"pg-boss": "9.*",
"pino": "8.*",
"pino-colada": "2.2.2",
"pino-http": "7.0.0",
"pino-pretty": "8.1.0",
"pino-http": "9.*",
"pino-pretty": "10.*",
"postgres-migrations": "5.3.0",
"qs": "6.11.0",
"reflect-metadata": "0.1.13",
"rimraf": "3.0.2",
"rxjs": "7.5.5",
"showdown": "1.9.1",
"uuid": "8.3.2",
"xss": "1.0.9",
"yargs": "17.5.1"
"reflect-metadata": "0.2.*",
"rimraf": "5.*",
"rxjs": "7.*",
"showdown": "2.*",
"uuid": "9.*",
"xss": "1.0.*",
"yargs": "17.*"
},
"devDependencies": {
"@nestjs/cli": "9.0.0",
"@nestjs/schematics": "9.0.1",
"@nestjs/testing": "9.0.1",
"@types/connect-flash": "0.0.37",
"@types/express": "4.17.13",
"@types/express-session": "1.17.5",
"@nestjs/cli": "10.*",
"@nestjs/schematics": "10.*",
"@nestjs/testing": "10.*",
"@types/connect-flash": "0.0.40",
"@types/express": "4.*",
"@types/express-session": "1.18.*",
"@types/jest": "28.1.4",
"@types/jsdom": "16.2.11",
"@types/lodash": "4.14.170",
"@types/multer": "1.4.7",
"@types/node": "15.6.1",
"@types/nodemailer": "6.4.2",
"@types/passport": "1.0.9",
"@types/passport-local": "1.0.34",
"@types/pg": "8.6.5",
"@types/showdown": "1.9.3",
"@types/uuid": "8.3.0",
"@types/yargs": "17.0.10",
"@typescript-eslint/eslint-plugin": "5.30.5",
"@typescript-eslint/parser": "5.30.5",
"@types/multer": "1.4.*",
"@types/node": "20.*",
"@types/nodemailer": "6.4.*",
"@types/passport": "1.0.*",
"@types/passport-local": "1.0.*",
"@types/pg": "8.*",
"@types/showdown": "2.*",
"@types/uuid": "9.*",
"@types/yargs": "17.0.*",
"@typescript-eslint/eslint-plugin": "7.*",
"@typescript-eslint/parser": "7.*",
"copyfiles": "2.4.1",
"eslint": "8.19.0",
"json-schema-to-typescript": "10.1.5",
"node-sass": "7.0.1",
"eslint": "8.*",
"json-schema-to-typescript": "13.*",
"node-sass": "9.*",
"prettier": "2.3.0",
"ts-auto-guard": "2.4.1",
"ts-jest": "28.0.5",
"ts-node": "10.8.2",
"typescript": "4.7.4",
"webpack": "5.39.1"
"ts-auto-guard": "4.*",
"ts-jest": "29.*",
"ts-node": "10.*",
"typescript": "4.*",
"webpack": "5.*"
}
}
2 changes: 1 addition & 1 deletion src/api/api.queries.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** Types generated for queries found in "src/api/api.sql" */
import { PreparedQuery } from '@pgtyped/query'
import { PreparedQuery } from '@pgtyped/runtime'

/** 'LoginFromToken' parameters type */
export interface ILoginFromTokenParams {
Expand Down
2 changes: 1 addition & 1 deletion src/api/comments.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class CommentsController {
...comment,
postedAt: moment().utc().toDate(),
},
req.ip
req.ip ?? ''
)

if (req.headers['content-type'] !== 'application/json') {
Expand Down
2 changes: 1 addition & 1 deletion src/shared/accounts/accounts.queries.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** Types generated for queries found in "src/shared/accounts/accounts.sql" */
import { PreparedQuery } from '@pgtyped/query'
import { PreparedQuery } from '@pgtyped/runtime'

/** 'Signup' parameters type */
export interface ISignupParams {
Expand Down
2 changes: 1 addition & 1 deletion src/shared/auth/auth.queries.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** Types generated for queries found in "src/shared/auth/auth.sql" */
import { PreparedQuery } from '@pgtyped/query'
import { PreparedQuery } from '@pgtyped/runtime'

/** 'ExpirePendingTokens' parameters type */
export interface IExpirePendingTokensParams {
Expand Down
2 changes: 1 addition & 1 deletion src/shared/comments/comments.queries.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** Types generated for queries found in "src/shared/comments/comments.sql" */
import { PreparedQuery } from '@pgtyped/query'
import { PreparedQuery } from '@pgtyped/runtime'

/** 'PostCommentForUrl' parameters type */
export interface IPostCommentForUrlParams {
Expand Down
2 changes: 1 addition & 1 deletion src/shared/logging/logged-query.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import _ from 'lodash'
import { PreparedQuery } from '@pgtyped/query'
import { PreparedQuery } from '@pgtyped/runtime'

export function interpretedQuery(query: PreparedQuery<any, any>, params: Record<string, unknown>): string {
const templatedSql = (_.get(query, 'query.statement.body') as string) ?? ''
Expand Down
Loading
Loading