Skip to content
Open
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
12 changes: 6 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js 18
- name: Use Node.js LTS
uses: actions/setup-node@v4
with:
node-version: 18
node-version: lts/*
- run: yarn
- run: yarn test
- uses: codecov/codecov-action@v3.1.1
lighthouse:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js 18
- name: Use Node.js LTS
uses: actions/setup-node@v4
with:
node-version: 18
node-version: lts/*
- run: yarn
- run: yarn build
- name: Run Lighthouse
Expand All @@ -33,10 +33,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js 18
- name: Use Node.js LTS
uses: actions/setup-node@v4
with:
node-version: 18
node-version: lts/*
- uses: cypress-io/github-action@v5
with:
build: yarn build
Expand Down
6 changes: 2 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:18 AS build
FROM node:lts AS build
WORKDIR /app
ENV CYPRESS_INSTALL_BINARY=0

Expand All @@ -7,13 +7,11 @@ COPY package.json /app
RUN yarn install --frozen-lockfile
COPY tsconfig.json /app
COPY rollup.config.js /app
COPY tailwind.config.js /app
COPY tailwind.config.js /app
COPY src /app/src
COPY index.html /app
RUN yarn build

FROM node:18
FROM node:lts
WORKDIR /app
COPY yarn.lock /app
COPY package.json /app
Expand Down
56 changes: 26 additions & 30 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,39 @@
"license": "MIT",
"private": true,
"devDependencies": {
"@rollup/plugin-commonjs": "^21.1.0",
"@rollup/plugin-node-resolve": "^13.3.0",
"@rollup/plugin-terser": "^0.4.0",
"@rollup/plugin-typescript": "^8.5.0",
"@tailwindcss/forms": "0.5.3",
"@types/crypto-js": "^4.1.1",
"@types/cypress": "^1.1.3",
"@types/express": "^4.17.17",
"@types/jest": "^27.5.2",
"@types/redis": "2.8.32",
"@types/xml2js": "^0.4.11",
"@rollup/plugin-commonjs": "^29.0.0",
"@rollup/plugin-node-resolve": "^16.0.3",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^12.3.0",
"@tailwindcss/forms": "^0.5.11",
"@tailwindcss/postcss": "^4.2.1",
"@types/crypto-js": "^4.2.2",
"@types/express": "^5.0.6",
"@types/jest": "^30.0.0",
"@types/xml2js": "^0.4.14",
"@whtsky/prettier-config": "^1.0.1",
"autoprefixer": "10.4.14",
"concurrently": "6.5.1",
"cypress": "^12.8.0",
"jest": "^28.1.3",
"postcss": "8.4.31",
"prettier": "^2.8.4",
"rollup": "^2.79.1",
"concurrently": "^9.2.1",
"cypress": "^15.11.0",
"jest": "^30.2.0",
"postcss": "^8.5.6",
"prettier": "^3.8.1",
"rollup": "^4.59.0",
"rollup-plugin-generate-html-template": "1.7.0",
"rollup-plugin-postcss": "^4.0.2",
"start-server-and-test": "^1.15.5",
"tailwindcss": "3.2.7",
"start-server-and-test": "^2.1.5",
"tailwindcss": "^4.2.1",
"ts-jest": "^29.4.6",
"ts-node": "^10.9.1",
"typescript": "^4.9.5"
"ts-node": "^10.9.2",
"typescript": "^5.9.3"
},
"dependencies": {
"@postlight/parser": "^2.2.3",
"@sentry/integrations": "^7.29.0",
"@sentry/node": "^7.29.0",
"crypto-js": "^4.1.1",
"express": "^4.18.2",
"@sentry/node": "^10.40.0",
"crypto-js": "^4.2.0",
"express": "^5.2.1",
"feed": "^4.2.2",
"redis": "3.1.2",
"rss-parser": "^3.12.0"
"redis": "^5.11.0",
"rss-parser": "^3.13.0"
},
"scripts": {
"start": "node src/server.js",
Expand All @@ -54,8 +51,7 @@
"prettier": "@whtsky/prettier-config",
"postcss": {
"plugins": {
"tailwindcss": {},
"autoprefixer": {}
"@tailwindcss/postcss": {}
}
}
}
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default {
}),
postcss({
extract: true,
minimize: true
minimize: false
}),
terser(),
htmlTemplate({
Expand Down
10 changes: 3 additions & 7 deletions src/app.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import express from 'express'
import bodyParser from 'body-parser'
import Parser from 'rss-parser'
import { Feed } from 'feed'
import type { FeedOptions, Item } from 'feed/lib/typings'
import * as Sentry from '@sentry/node'
import { RewriteFrames } from '@sentry/integrations'

import * as constants from './constants'
import { parsePageUsingMercury } from './parser'
Expand All @@ -27,7 +25,7 @@ if (constants.sentryDsn) {
Sentry.init({
dsn: constants.sentryDsn,
integrations: [
new RewriteFrames({
Sentry.rewriteFramesIntegration({
root: __dirname || process.cwd(),
}),
],
Expand All @@ -40,13 +38,11 @@ if (constants.sentryDsn) {
"read ECONNRESET",
]
})

app.use(Sentry.Handlers.requestHandler())
}

app.use(express.static(constants.publicPath))

app.use(bodyParser.urlencoded({ extended: false }))
app.use(express.urlencoded({ extended: false }))

async function getFullTextFeed(feedUrl: string, maxItemsPerFeed: number) {
const parser = new Parser()
Expand Down Expand Up @@ -163,7 +159,7 @@ app.get('/feed', async (req, res) => {
})

if (constants.sentryDsn) {
app.use(Sentry.Handlers.errorHandler())
Sentry.setupExpressErrorHandler(app)
}

export default app
29 changes: 9 additions & 20 deletions src/cache/redis.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { Cache } from './type'
import type { RedisClient } from 'redis'
import type { createClient } from 'redis'

export class RedisCache implements Cache {
redisUrl: string
client?: RedisClient
client?: ReturnType<typeof createClient>
ttl: number | undefined
constructor(url: string, ttl: number | undefined = undefined) {
this.redisUrl = url
Expand All @@ -13,32 +13,21 @@ export class RedisCache implements Cache {
if (!this.client) {
const redis = await import('redis')
this.client = redis.createClient({ url: this.redisUrl })
await this.client.connect()
}
}
get(url: string) {
return new Promise<string | undefined>(async (resolve, reject) => {
try {
await this.ensureClient()
this.client!.get(url, (err, data) => {
if (err) {
reject(err)
} else {
resolve(data || undefined)
}
})
} catch (e) {
reject(e)
}
})
async get(url: string): Promise<string | undefined> {
await this.ensureClient()
const data = await this.client!.get(url)
return data || undefined
}

async set(url: string, content: string) {
await this.ensureClient()
if (this.ttl !== undefined) {
this.client!.set(url, content, 'EX', this.ttl)
await this.client!.set(url, content, { EX: this.ttl })
} else {
this.client!.set(url, content)
await this.client!.set(url, content)
}
return Promise.resolve()
}
}
2 changes: 1 addition & 1 deletion src/frontend.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import "tailwindcss/tailwind.css"
import "./styles.css"

import { sign } from './sign'

Expand Down
18 changes: 18 additions & 0 deletions src/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@import "tailwindcss";
@plugin "@tailwindcss/forms";

@source "../index.html";

@theme {
--color-cyan-50: oklch(0.984 0.019 200.873);
--color-cyan-100: oklch(0.956 0.045 203.388);
--color-cyan-200: oklch(0.901 0.076 205.144);
--color-cyan-300: oklch(0.828 0.111 205.84);
--color-cyan-400: oklch(0.728 0.132 205.364);
--color-cyan-500: oklch(0.623 0.114 205.483);
--color-cyan-600: oklch(0.52 0.105 209.446);
--color-cyan-700: oklch(0.437 0.091 210.149);
--color-cyan-800: oklch(0.371 0.078 210.128);
--color-cyan-900: oklch(0.326 0.063 210.075);
--color-cyan-950: oklch(0.235 0.048 211.264);
}
15 changes: 0 additions & 15 deletions tailwind.config.js

This file was deleted.

2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
"allowSyntheticDefaultImports": true
},
"include": ["src/**/*", "api/*"],
"exclude": ["node_modules", "**/*.spec.ts"]
"exclude": ["node_modules", "**/*.spec.ts", "**/*.test.ts"]
}
Loading
Loading