tempest.games 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # tempest.games
2
2
 
3
+ ## 0.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 47c52e1: ✨ Automatically ban suspicious IPs at the network level.
8
+
3
9
  ## 0.1.1
4
10
 
5
11
  ### Patch Changes
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env bun
2
+
3
+ import * as os from "node:os"
4
+
5
+ import postgres from "postgres"
6
+
7
+ import { env } from "../src/library/env.ts"
8
+
9
+ const PRETTY_PLEASE = process.env.PRETTY_PLEASE
10
+
11
+ if (!PRETTY_PLEASE) {
12
+ console.warn(`🚨 this is a dangerous script, please ask nicely`)
13
+ process.exit(1)
14
+ }
15
+
16
+ const osUser = os.userInfo().username
17
+ const user = osUser === `unknown` ? `postgres` : osUser
18
+
19
+ const sql = postgres({
20
+ user,
21
+ password: env.POSTGRES_PASSWORD,
22
+ database: `postgres`,
23
+ host: env.POSTGRES_HOST,
24
+ port: env.POSTGRES_PORT,
25
+ })
26
+
27
+ await sql.unsafe(`DROP DATABASE ${env.POSTGRES_DATABASE};`)
28
+
29
+ await sql.end()
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env bun
2
+
3
+ import * as os from "node:os"
4
+
5
+ import postgres from "postgres"
6
+
7
+ import { env } from "../src/library/env.ts"
8
+
9
+ const osUser = os.userInfo().username
10
+ const user = osUser === `unknown` ? `postgres` : osUser
11
+
12
+ const sql = postgres({
13
+ user,
14
+ password: env.POSTGRES_PASSWORD,
15
+ database: `postgres`,
16
+ host: env.POSTGRES_HOST,
17
+ port: env.POSTGRES_PORT,
18
+ })
19
+
20
+ try {
21
+ process.stdout.write(`🚀 Creating database ${env.POSTGRES_DATABASE}... `)
22
+ await sql`CREATE DATABASE ${sql(env.POSTGRES_DATABASE)}`
23
+ console.log(`Done!`)
24
+ } catch (thrown) {
25
+ if (thrown instanceof Error) {
26
+ console.error(`💥 Failed:`, thrown.message)
27
+ }
28
+ }
29
+
30
+ try {
31
+ process.stdout.write(`🚀 Creating user ${env.POSTGRES_USER}... `)
32
+ await sql.unsafe(
33
+ `CREATE USER ${env.POSTGRES_USER} WITH PASSWORD '${env.POSTGRES_PASSWORD}'`,
34
+ )
35
+ console.log(`Done!`)
36
+ } catch (thrown) {
37
+ if (thrown instanceof Error) {
38
+ console.error(`💥 Failed:`, thrown.message)
39
+ }
40
+ }
41
+
42
+ try {
43
+ process.stdout.write(
44
+ `🚀 Granting privileges to ${env.POSTGRES_USER} on ${env.POSTGRES_DATABASE}... `,
45
+ )
46
+ await sql`GRANT ALL PRIVILEGES ON DATABASE ${sql(env.POSTGRES_DATABASE)} TO ${sql(
47
+ env.POSTGRES_USER,
48
+ )}`
49
+ console.log(`Done!`)
50
+ } catch (thrown) {
51
+ if (thrown instanceof Error) {
52
+ console.error(`💥 Failed:`, thrown.message)
53
+ }
54
+ }
55
+
56
+ await sql.end()
57
+ console.log(`🚀 Database connection closed`)
@@ -0,0 +1,5 @@
1
+ import { execSync } from "node:child_process"
2
+
3
+ export default (): void => {
4
+ execSync(`pnpm db:up`)
5
+ }