> then if a hacker were to spam my service with a bunch of GET /documents/XXXXX calls trying to find
then if a hacker were to spam my service with a bunch of GET /documents/XXXXX calls trying to find a valid document, that every one of those invalid GETs would create a new DO that wouldn't be deleted because the SQLite database would be created simply by the act of accessing it, even if it returns a 404. Is that right?My own solution to that is to only run the migrations when they are needed.
In the constructor I do all the in-memory initializations, and read from the storage to see if there is any state already to load in-memory.
The actual SQL table creation (i.e. migrations) are ran when I actually want to access the storage with a valid request. The migrations keep in-memory state when applied, and also in storage, so it's a no-op once they run and has zero cost to check them.
See example in https://github.com/lambrospetrou/rediflare/blob/main/src/durable-objects.ts#L103 and https://github.com/lambrospetrou/tiddlyflare/blob/main/src/durable-objects.ts#L93
So, these spam requests will get to your DO and you can reject them without writing.
But, as others have said it's better to reject them earlier, with rate limiting or auth, etc.
