Skip to content

Commit 3cce228

Browse files
committed
feat!: use bot-template
1 parent 2efbc8f commit 3cce228

26 files changed

+2829
-944
lines changed

.env.development

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
LOG_LEVEL='debug'

.env.production

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
LOG_LEVEL='info'

.env.template

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# ! DO NOT EDIT THIS FILE !
2+
# Copy it to .env.production, .env.test or .env.development, then edit it there.
3+
4+
# The token of the Discord bot application
5+
TOKEN=YOUR.DISCORD.TOKEN
6+
7+
# Connection data for the database
8+
DB_HOST=your.db.host
9+
DB_USER=your_db_user
10+
DB_PASS=your_db_pass
11+
DB_NAME=your_db_name
12+
DB_PORT=your_db_port
13+
14+
LOG_LEVEL='debug'

.gitignore

+259-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,260 @@
1-
.idea/
2-
.vscode/
3-
node_modules/
4-
build/
5-
tmp/
6-
temp/
1+
# Created by https://www.toptal.com/developers/gitignore/api/node,webstorm,dotenv
2+
# Edit at https://www.toptal.com/developers/gitignore?templates=node,webstorm,dotenv
3+
4+
### dotenv ###
75
.env
8-
*.lock
9-
/logs/
6+
7+
### Node ###
8+
# Logs
9+
logs
10+
*.log
11+
npm-debug.log*
12+
yarn-debug.log*
13+
yarn-error.log*
14+
lerna-debug.log*
15+
.pnpm-debug.log*
16+
17+
# Diagnostic reports (https://nodejs.org/api/report.html)
18+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
19+
20+
# Runtime data
21+
pids
22+
*.pid
23+
*.seed
24+
*.pid.lock
25+
26+
# Directory for instrumented libs generated by jscoverage/JSCover
27+
lib-cov
28+
29+
# Coverage directory used by tools like istanbul
30+
coverage
31+
*.lcov
32+
33+
# nyc test coverage
34+
.nyc_output
35+
36+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
37+
.grunt
38+
39+
# Bower dependency directory (https://bower.io/)
40+
bower_components
41+
42+
# node-waf configuration
43+
.lock-wscript
44+
45+
# Compiled binary addons (https://nodejs.org/api/addons.html)
46+
build/Release
47+
48+
# Dependency directories
49+
node_modules/
50+
jspm_packages/
51+
52+
# Snowpack dependency directory (https://snowpack.dev/)
53+
web_modules/
54+
55+
# TypeScript cache
56+
*.tsbuildinfo
57+
58+
# Optional npm cache directory
59+
.npm
60+
61+
# Optional eslint cache
62+
.eslintcache
63+
64+
# Optional stylelint cache
65+
.stylelintcache
66+
67+
# Microbundle cache
68+
.rpt2_cache/
69+
.rts2_cache_cjs/
70+
.rts2_cache_es/
71+
.rts2_cache_umd/
72+
73+
# Optional REPL history
74+
.node_repl_history
75+
76+
# Output of 'npm pack'
77+
*.tgz
78+
79+
# Yarn Integrity file
80+
.yarn-integrity
81+
82+
# dotenv environment variable files
83+
.env.development.local
84+
.env.test.local
85+
.env.production.local
86+
.env.local
87+
88+
# parcel-bundler cache (https://parceljs.org/)
89+
.cache
90+
.parcel-cache
91+
92+
# Next.js build output
93+
.next
94+
out
95+
96+
# Nuxt.js build / generate output
97+
.nuxt
98+
dist
99+
100+
# Gatsby files
101+
.cache/
102+
# Comment in the public line in if your project uses Gatsby and not Next.js
103+
# https://nextjs.org/blog/next-9-1#public-directory-support
104+
# public
105+
106+
# vuepress build output
107+
.vuepress/dist
108+
109+
# vuepress v2.x temp and cache directory
110+
.temp
111+
112+
# Docusaurus cache and generated files
113+
.docusaurus
114+
115+
# Serverless directories
116+
.serverless/
117+
118+
# FuseBox cache
119+
.fusebox/
120+
121+
# DynamoDB Local files
122+
.dynamodb/
123+
124+
# TernJS port file
125+
.tern-port
126+
127+
# Stores VSCode versions used for testing VSCode extensions
128+
.vscode-test
129+
130+
# yarn v2
131+
.yarn/cache
132+
.yarn/unplugged
133+
.yarn/build-state.yml
134+
.yarn/install-state.gz
135+
.pnp.*
136+
137+
### Node Patch ###
138+
# Serverless Webpack directories
139+
.webpack/
140+
141+
# Optional stylelint cache
142+
143+
# SvelteKit build / generate output
144+
.svelte-kit
145+
146+
### WebStorm ###
147+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
148+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
149+
150+
# User-specific stuff
151+
.idea/**/workspace.xml
152+
.idea/**/tasks.xml
153+
.idea/**/usage.statistics.xml
154+
.idea/**/dictionaries
155+
.idea/**/shelf
156+
157+
# AWS User-specific
158+
.idea/**/aws.xml
159+
160+
# Generated files
161+
.idea/**/contentModel.xml
162+
163+
# Sensitive or high-churn files
164+
.idea/**/dataSources/
165+
.idea/**/dataSources.ids
166+
.idea/**/dataSources.local.xml
167+
.idea/**/sqlDataSources.xml
168+
.idea/**/dynamic.xml
169+
.idea/**/uiDesigner.xml
170+
.idea/**/dbnavigator.xml
171+
172+
# Gradle
173+
.idea/**/gradle.xml
174+
.idea/**/libraries
175+
176+
# Gradle and Maven with auto-import
177+
# When using Gradle or Maven with auto-import, you should exclude module files,
178+
# since they will be recreated, and may cause churn. Uncomment if using
179+
# auto-import.
180+
# .idea/artifacts
181+
# .idea/compiler.xml
182+
# .idea/jarRepositories.xml
183+
# .idea/modules.xml
184+
# .idea/*.iml
185+
# .idea/modules
186+
# *.iml
187+
# *.ipr
188+
189+
# CMake
190+
cmake-build-*/
191+
192+
# Mongo Explorer plugin
193+
.idea/**/mongoSettings.xml
194+
195+
# File-based project format
196+
*.iws
197+
198+
# IntelliJ
199+
out/
200+
201+
# mpeltonen/sbt-idea plugin
202+
.idea_modules/
203+
204+
# JIRA plugin
205+
atlassian-ide-plugin.xml
206+
207+
# Cursive Clojure plugin
208+
.idea/replstate.xml
209+
210+
# SonarLint plugin
211+
.idea/sonarlint/
212+
213+
# Crashlytics plugin (for Android Studio and IntelliJ)
214+
com_crashlytics_export_strings.xml
215+
crashlytics.properties
216+
crashlytics-build.properties
217+
fabric.properties
218+
219+
# Editor-based Rest Client
220+
.idea/httpRequests
221+
222+
# Android studio 3.1+ serialized cache file
223+
.idea/caches/build_file_checksums.ser
224+
225+
### WebStorm Patch ###
226+
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
227+
228+
# *.iml
229+
# modules.xml
230+
# .idea/misc.xml
231+
# *.ipr
232+
233+
# Sonarlint plugin
234+
# https://plugins.jetbrains.com/plugin/7973-sonarlint
235+
.idea/**/sonarlint/
236+
237+
# SonarQube Plugin
238+
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
239+
.idea/**/sonarIssues.xml
240+
241+
# Markdown Navigator plugin
242+
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
243+
.idea/**/markdown-navigator.xml
244+
.idea/**/markdown-navigator-enh.xml
245+
.idea/**/markdown-navigator/
246+
247+
# Cache file creation bug
248+
# See https://youtrack.jetbrains.com/issue/JBR-2257
249+
.idea/$CACHE_FILE$
250+
251+
# CodeStream plugin
252+
# https://plugins.jetbrains.com/plugin/12206-codestream
253+
.idea/codestream.xml
254+
255+
# Azure Toolkit for IntelliJ plugin
256+
# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij
257+
.idea/**/azureSettings.xml
258+
259+
# End of https://www.toptal.com/developers/gitignore/api/node,webstorm,dotenv
260+

.idea/.gitignore

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/soni-bot.iml

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Dockerfile

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
# syntax=docker/dockerfile:1
22
FROM node:18
33
WORKDIR /data
4-
COPY package.json .
5-
RUN yarn install
6-
COPY src ./src
7-
COPY .env .
8-
COPY tsconfig.json .
9-
RUN yarn run build
10-
RUN yarn run deploy
11-
CMD ["yarn", "run", "start"]
4+
COPY . .
5+
RUN npm install -g pnpm
6+
RUN pnpm install
7+
RUN rm .env.*.local
8+
RUN pnpm run build
9+
CMD ["pnpm", "run", "start"]

docker-compose.yml

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
version: "3.9"
22
services:
33
soni-bot:
4-
container_name: soni-bot
54
build: .
65
restart: always

ormconfig.ts

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { existsSync } from 'fs';
2+
import type { DataSourceOptions } from 'typeorm';
3+
import { SnakeNamingStrategy } from 'typeorm-naming-strategies';
4+
5+
import './src/util/dotenv';
6+
7+
const entities = process.env.NODE_ENV !== 'development' ? ['dist/**/*.entity.js'] : ['src/**/*.entity.ts'];
8+
const migrations = process.env.NODE_ENV !== 'development' ? ['dist/src/migration/*.js'] : ['src/migration/*.ts'];
9+
10+
/**
11+
* The typeorm config
12+
*
13+
* @type {DataSourceOptions}
14+
* @author theS1LV3R
15+
* @since 1.0.0
16+
* @see {@link DataSourceOptions}
17+
*/
18+
let ormConfig: DataSourceOptions = {
19+
type: 'postgres',
20+
host: process.env.DB_HOST ?? 'localhost',
21+
port: parseInt(process.env.DB_PORT ?? '5432', 10),
22+
username: process.env.DB_USER ?? 'postgres',
23+
password: process.env.DB_PASS ?? 'postgres',
24+
database: process.env.DB_NAME ?? 'discord_bot',
25+
synchronize: true,
26+
logging: ['error'],
27+
namingStrategy: new SnakeNamingStrategy(),
28+
29+
entities,
30+
migrations
31+
};
32+
33+
// If ormconfig.local.ts exists, merge these defaults with the values from it
34+
if (existsSync('./ormconfig.local.ts'))
35+
{
36+
// eslint-disable-next-line @typescript-eslint/no-var-requires
37+
const localConfig = require('./ormconfig.local.ts');
38+
ormConfig = Object.assign(ormConfig, localConfig);
39+
}
40+
41+
export default ormConfig;

0 commit comments

Comments
 (0)