Commit Graph

183 Commits

Author SHA1 Message Date
Guangcong Luo
a36804d03b
Support non-mainservers uploading replays
(Also refactor prepreplay a little.)
2023-03-26 02:55:44 -07:00
Guangcong Luo
a24041dec7
Database: Strict API for select/get functions 2023-03-26 02:54:50 -07:00
Mia
a56ac973ae Fix uploading replays 2023-03-26 03:41:39 -05:00
Guangcong Luo
d12a69dbbf
Fixes for actions.ts
No refactors here, either, just some basic changes.

A bug with `ladderget` was fixed, and `errorip` is now only used in
situations where it'd be recognized.
2023-03-26 00:56:11 -07:00
Mia
3b8515e814 Fix build 2023-03-26 02:14:24 -05:00
Mia
070affe960 Add standing endpoints for permalocks 2023-03-20 13:29:52 -05:00
Guangcong Luo
19c0ca9749
Improve replays.ts
I wouldn't call this a refactor; I'm just improving doc comments,
rearranging, and improving typing.
2023-03-16 03:31:16 -07:00
Mia
57521b3384 Add updatenamecolor action 2023-03-15 08:22:12 -05:00
Mia
9d8fd69b57
Fix uploading replays
toID was removing the dash in the replay's id, so it was looking for the wrong prepped replay entry.
2023-03-14 09:37:49 -05:00
Guangcong Luo
a5eb099668
Fix crash when inserting null values into mysql 2023-03-13 07:33:15 -07:00
Guangcong Luo
8046f6f417
Fix invalid database insertions 2023-03-13 02:17:03 -07:00
Guangcong Luo
988c28b360
Minor cleanup 2023-03-12 22:22:00 -07:00
Guangcong Luo
cd9d14a9e5
Remove unused interface DispatcherOpts
(Was refactored out in a previous refactor)
2023-03-12 16:13:49 -07:00
Mia
26641f8f1b Database: Fix crash in insertion 2023-03-12 17:30:28 -05:00
Guangcong Luo
c4c14018aa
Further fix name escaping in SQL 2023-03-12 15:01:17 -07:00
Mia
184dab72b1 Database: Fix crash and remove nullish coalescing 2023-03-12 16:50:11 -05:00
Guangcong Luo
64cddf4fda
Fix convering name lists to SQL 2023-03-12 14:46:24 -07:00
Guangcong Luo
81451173b7
Refactor server.ts 2023-03-11 23:41:50 -08:00
Guangcong Luo
a28d2c70b4
Actually shut down gracefully 2023-03-11 15:29:14 -08:00
Guangcong Luo
0da0e11f81
Space out actions.ts 2023-03-11 04:47:57 -08:00
Guangcong Luo
e4f5545074
Refactor ladder.ts
The PHP ladder implementation has been full of tech debt for a while.

Fortunately, TypeScript makes it _much_ easier to refactor this sort of
thing. This is the sort of refactor I never would have bothered
attempting in PHP, but TS makes it really easy to clear all the tech
debt.

The idea of caching a ladder entry in a user object may be useful
in the sim server, but it was really dumb here.
2023-03-11 04:43:57 -08:00
Guangcong Luo
1e6cf400e9
Create utils.ts
We have six util functions sort of haphazardly strewn around this
codebase; enough to make a utils.ts.
2023-03-11 03:30:49 -08:00
Guangcong Luo
b3a868ef99
Add new object SimServers for handling sim servers 2023-03-11 03:30:44 -08:00
Guangcong Luo
a3d871674e
Fully rename dispatcher -> context 2023-03-10 16:46:42 -08:00
Guangcong Luo
3d1a6ee89a
Optimize database.ts a little 2023-03-10 16:45:07 -08:00
Guangcong Luo
c352823556
Consolidate session.ts into user.ts 2023-03-10 05:10:47 -08:00
Guangcong Luo
79ec708196
Remove unused SQLName
It was left over from a previous refactor.
2023-03-10 04:54:06 -08:00
Guangcong Luo
8e5e7a85ee
Refactor session.ts
- Consolidate cookie code
- Consolidate how users are loaded
2023-03-10 04:49:33 -08:00
Guangcong Luo
4a878ae478
Rename Dispatcher to ActionContext
(Also some minor refactors.)
2023-03-10 03:12:49 -08:00
Guangcong Luo
4133ed815e
Combine server.ts and dispatcher.ts 2023-03-09 16:47:51 -08:00
Guangcong Luo
8623335804
Powerful SQL template strings (#11)
This commit adds a new SQL tagged template string syntax way more
powerful than the old one.

After discussion on Discord, I realized that requiring tagged template
strings and completely disallowing raw strings as SQL would make the
code a lot safer, but tagged template strings just needed a bit more
work to make them bearable for this purpose. I've now implemented said
tagged template strings.

Documentation in the jsdoc above the SQL tag function.
2023-03-08 22:53:05 -08:00
Guangcong Luo
aedfca83e2
Rename T to Row for readability 2023-03-07 20:34:43 -08:00
Mia
477b2d9c3f
Config-loader: Load from directory root 2023-03-07 10:20:32 -06:00
Guangcong Luo
af07c71f2e
Refactor database.ts 2023-03-07 02:07:29 -08:00
Guangcong Luo
c19522c9f7
Move PS-specific code from database to tables
database.ts is much cleaner as a generic database library that can be
used anywhere.

I'm also taking back the `@author` line - this file is based on a
database library I wrote for a different project:

2c55b7b09d/server/db.ts

The file will be mostly mine by the time I'm done with it.
2023-03-06 23:13:57 -08:00
Guangcong Luo
2b81372dc0
Rename database types/methods
The new names should be clearer. I wanted to do this as part of a
refactor, but doing the rename separately should make the refactor
diff more readable.
2023-03-06 22:31:47 -08:00
Guangcong Luo
317c0623db
Remove sql-template-strings dependency
Frivolous dependencies are bad for perf and bad for security.

The usual justification for frivolous dependencies is something like
"a community-maintained package is more likely to be bug-free and
maintained than something you wrote yourself", but:

1. frivolous dependencies are usually maintained by Just Some Random
   Guy, not by some community
2. you are probably more likely to introduce a bug using some guy's API
   incorrectly, than by writing a few lines of raw JavaScript that you
   understand inside and out
3. if that guy deprecates his package, or decides to ragequit, or
   whatever, you do not want to be depending on it
4. debugging becomes a lot more annoying
5. the dependency is full of unnecessary complexity to support use
   cases we're not even using

Anyway, yeah, there's no need for this dependency.
2023-03-06 21:31:35 -08:00
Guangcong Luo
f2dae2a3fc
Fix build errors 2023-03-06 21:20:48 -08:00
Mia
c8c50ea36d Use process.env more 2023-03-03 06:04:56 -06:00
Mia
ab5a71632a Ensure body params are always strings 2023-01-23 10:14:37 -06:00
Mia
5eeb00f2a6 Remove unnecessary catch 2023-01-23 10:12:06 -06:00
Mia
14175a5ba6 Use async/await in shutdown hook 2023-01-23 10:10:08 -06:00
Mia
193a91053a Fix tsc 2023-01-23 10:09:23 -06:00
Mia
c18270aa63 Replace more any uses with unknown, don't copy config in tests 2023-01-23 10:04:16 -06:00
Mia
dd454bced4 Remove unnecessary any uses 2023-01-22 13:58:36 -06:00
Mia
8308148fde Add package-lock.json 2023-01-22 13:54:23 -06:00
Mia
d091015f00 Database: Remove any uses 2023-01-22 13:54:15 -06:00
Mia
af61b92184 Actions: Load custom actions outside of config-loader 2023-01-22 13:51:24 -06:00
Mia
f3155415b1 Support specifying the directory for custom CSS 2023-01-22 13:50:23 -06:00
Mia
55496326f4 Support older node versions
Node 14 doesn't support static {} syntax.
2023-01-04 15:40:22 -06:00