Skip to content

Commit eeab4da

Browse files
denolfeAlessioGr
andauthored
chore: update deps for security (#2)
* chore: pin deps * chore: pnpm import * chore: add build command * chore: upgrade discord.js, add axios peer dep * move from langchain to ai sdk * remove unused axios package * move to bun, update eslint and prettier dependencies * run lint and prettier * fix build * back to pnpm, as bun does not have audit command. fix dockerfile --------- Co-authored-by: Alessio Gravili <[email protected]>
1 parent 63e479c commit eeab4da

34 files changed

+4030
-2679
lines changed

.prettierignore

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,13 @@
1-
dist/
2-
build/
1+
.tmp
2+
**/.git
3+
**/.hg
4+
**/.pnp.*
5+
**/.svn
6+
**/.yarn/**
7+
**/build
8+
**/dist/**
9+
**/node_modules
10+
**/temp
11+
tsconfig.json
12+
payload-types.ts
13+
tsconfig.tsbuildinfo

.prettierrc.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"singleQuote": true,
33
"trailingComma": "all",
4-
"printWidth": 100
4+
"printWidth": 100,
5+
"semi": false
56
}

.vscode/extensions.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"recommendations": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode"]
2+
"recommendations": ["esbenp.prettier-vscode", "dbaeumer.vscode-eslint"]
33
}

.vscode/launch.json

-15
This file was deleted.

.vscode/settings.json

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"npm.packageManager": "bun",
23
"editor.defaultFormatter": "esbenp.prettier-vscode",
34
"[typescript]": {
45
"editor.defaultFormatter": "esbenp.prettier-vscode",
@@ -14,6 +15,13 @@
1415
"source.fixAll.eslint": "explicit"
1516
}
1617
},
18+
"[javascript]": {
19+
"editor.defaultFormatter": "esbenp.prettier-vscode",
20+
"editor.formatOnSave": true,
21+
"editor.codeActionsOnSave": {
22+
"source.fixAll.eslint": "explicit"
23+
}
24+
},
1725
"[json]": {
1826
"editor.defaultFormatter": "esbenp.prettier-vscode",
1927
"editor.formatOnSave": true
@@ -23,6 +31,10 @@
2331
"editor.formatOnSave": true
2432
},
2533
"editor.formatOnSaveMode": "file",
26-
"eslint.rules.customizations": [{ "rule": "*", "severity": "warn" }],
27-
"typescript.tsdk": "node_modules/typescript/lib"
34+
"typescript.tsdk": "node_modules/typescript/lib",
35+
"[javascript][typescript][typescriptreact]": {
36+
"editor.codeActionsOnSave": {
37+
"source.fixAll.eslint": "explicit"
38+
}
39+
}
2840
}

Dockerfile

+30-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,36 @@
1-
FROM node:20-alpine AS builder
1+
# use the official Bun image
2+
# see all versions at https://hub.docker.com/r/oven/bun/tags
3+
FROM oven/bun:1 AS base
4+
WORKDIR /usr/src/app
25

3-
RUN mkdir -p /app
4-
WORKDIR /app
6+
# Install pnpm globally
7+
RUN bun install -g pnpm
58

6-
COPY package.json .
7-
COPY yarn.lock .
9+
# install dependencies into temp directory
10+
# this will cache them and speed up future builds
11+
FROM base AS install
12+
RUN mkdir -p /temp/dev
13+
COPY package.json pnpm-lock.yaml /temp/dev/
14+
RUN cd /temp/dev && pnpm install --frozen-lockfile
815

9-
RUN yarn install
16+
# install with --production (exclude devDependencies)
17+
RUN mkdir -p /temp/prod
18+
COPY package.json pnpm-lock.yaml /temp/prod/
19+
RUN cd /temp/prod && pnpm install --frozen-lockfile --production
1020

21+
# copy node_modules from temp directory
22+
# then copy all (non-ignored) project files into the image
23+
FROM base AS prerelease
24+
COPY --from=install /temp/dev/node_modules node_modules
1125
COPY . .
1226

13-
EXPOSE 3000
14-
CMD [ "yarn", "run", "start" ]
27+
# copy production dependencies and source code into final image
28+
FROM base AS release
29+
COPY --from=install /temp/prod/node_modules node_modules
30+
COPY --from=prerelease /usr/src/app/package.json .
31+
COPY --from=prerelease /usr/src/app/src src
32+
33+
# run the app
34+
USER bun
35+
EXPOSE 3000/tcp
36+
ENTRYPOINT [ "bun", "start" ]

eslint.config.js

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import payloadEsLintConfig from '@payloadcms/eslint-config';
2+
import payloadPlugin from '@payloadcms/eslint-plugin';
3+
4+
export const defaultESLintIgnores = [
5+
'**/.temp',
6+
'**/.*', // ignore all dotfiles
7+
'**/.git',
8+
'**/.hg',
9+
'**/.pnp.*',
10+
'**/.svn',
11+
'**/playwright.config.ts',
12+
'**/jest.config.js',
13+
'**/tsconfig.tsbuildinfo',
14+
'**/README.md',
15+
'**/eslint.config.js',
16+
'**/payload-types.ts',
17+
'**/dist/',
18+
'**/.yarn/',
19+
'**/build/',
20+
'**/node_modules/',
21+
'**/temp/',
22+
];
23+
24+
/** @typedef {import('eslint').Linter.Config} Config */
25+
26+
export const rootParserOptions = {
27+
sourceType: 'module',
28+
ecmaVersion: 'latest',
29+
projectService: true,
30+
};
31+
32+
/** @type {Config[]} */
33+
export const rootEslintConfig = [
34+
...payloadEsLintConfig,
35+
{
36+
plugins: {
37+
payload: payloadPlugin,
38+
},
39+
rules: {
40+
'payload/no-jsx-import-statements': 'warn',
41+
},
42+
},
43+
];
44+
45+
export default [
46+
...rootEslintConfig,
47+
{
48+
languageOptions: {
49+
parserOptions: {
50+
...rootParserOptions,
51+
projectService: true,
52+
tsconfigRootDir: import.meta.dirname,
53+
},
54+
},
55+
},
56+
];

eslintrc.cjs

-71
This file was deleted.

nodemon.json

-4
This file was deleted.

package.json

+15-20
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,26 @@
11
{
22
"name": "payloadbot",
33
"version": "1.0.0",
4-
"main": "index.js",
4+
"main": "src/Bot.ts",
55
"license": "MIT",
6+
"type": "module",
67
"scripts": {
7-
"dev": "nodemon",
8-
"start": "ts-node src/Bot.ts"
8+
"build": "tsc",
9+
"dev": "bun --watch src/Bot.ts",
10+
"start": "bun src/Bot.ts"
911
},
1012
"dependencies": {
11-
"algoliasearch": "^4.19.1",
12-
"discord.js": "14.14.1",
13-
"dotenv": "^16.3.1",
14-
"langchain": "^0.0.118",
15-
"node-fetch": "^3.3.2",
16-
"ts-node": "^10.9.1"
13+
"@ai-sdk/openai": "1.2.5",
14+
"ai": "4.1.61",
15+
"algoliasearch": "4.19.1",
16+
"discord.js": "14.18.0"
1717
},
1818
"devDependencies": {
19-
"@types/node": "^20.4.5",
20-
"@typescript-eslint/eslint-plugin": "6.2.0",
21-
"@typescript-eslint/parser": "6.2.0",
22-
"eslint": "^8.45.0",
23-
"eslint-plugin-jsonc": "^2.8.0",
24-
"eslint-plugin-simple-import-sort": "^10.0.0",
25-
"eslint-plugin-typescript-sort-keys": "^2.3.0",
26-
"jsonc-eslint-parser": "^2.3.0",
27-
"nodemon": "^3.0.1",
28-
"prettier": "^3.0.0",
29-
"typescript": "^5.1.6"
19+
"@types/bun": "1.2.5",
20+
"@payloadcms/eslint-config": "3.28.0",
21+
"@payloadcms/eslint-plugin": "3.28.0",
22+
"eslint": "9.22.0",
23+
"prettier": "3.5.3",
24+
"typescript": "5.7.3"
3025
}
3126
}

0 commit comments

Comments
 (0)